73 lines
1.5 KiB
Plaintext
73 lines
1.5 KiB
Plaintext
[#is_whitespace]
|
|
[section is_whitespace]
|
|
|
|
[h1 Synopsis]
|
|
|
|
namespace util
|
|
{
|
|
template <class C>
|
|
struct is_whitespace;
|
|
}
|
|
|
|
This is a [link lazy_metafunction lazy template metafunction] that supports
|
|
[link currying currying].
|
|
|
|
[table Arguments
|
|
[[Name] [Type]]
|
|
[[`C`] [[link boxed_value boxed] character value]]
|
|
]
|
|
|
|
[h1 Description]
|
|
|
|
Checks if `C` is a whitespace character. Returns a boxed boolean value.
|
|
|
|
[h1 Header]
|
|
|
|
#include <boost/metaparse/util/is_whitespace.hpp>
|
|
|
|
[h1 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
|
|
|
|
[h1 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"
|
|
);
|
|
|
|
[endsect]
|
|
|