Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

is_whitespace

Synopsis

namespace util
{
  template <class C>
  struct is_whitespace;
}

This is a lazy template metafunction that supports currying.

Table 50. Arguments

Name

Type

C

boxed character value


Description

Checks if C is a whitespace character. Returns a boxed boolean value.

Header

#include <boost/metaparse/util/is_whitespace.hpp>

Expression semantics

For any C nullary template metafunction returning a wrapped character value the following are equivalent:

is_whitespace<C>::type
is_whitespace<>::type::apply<C>::type
is_whitespace_c<C::type::value>::type

Example

#include <boost/metaparse/util/is_whitespace.hpp>

#include <type_traits>

using namespace boost::metaparse;

struct returns_char
{
  using type = std::integral_constant<char, ' '>;
};

static_assert(
  util::is_whitespace<std::integral_constant<char, ' '>>::type::value,
  "a space should be a whitespace character"
);

static_assert(
  !util::is_whitespace<std::integral_constant<char, '0'>>::type::value,
  "a number should not be a whitespace character"
);

static_assert(
  util::is_whitespace<>::type
    ::apply<std::integral_constant<char, '\t'>>::type::value,
  "it should support currying"
);

static_assert(
  util::is_whitespace<returns_char>::type::value,
  "it should support lazy evaluation"
);

PrevUpHomeNext