is_whitespace.qbk 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. [#is_whitespace]
  2. [section is_whitespace]
  3. [h1 Synopsis]
  4. namespace util
  5. {
  6. template <class C>
  7. struct is_whitespace;
  8. }
  9. This is a [link lazy_metafunction lazy template metafunction] that supports
  10. [link currying currying].
  11. [table Arguments
  12. [[Name] [Type]]
  13. [[`C`] [[link boxed_value boxed] character value]]
  14. ]
  15. [h1 Description]
  16. Checks if `C` is a whitespace character. Returns a boxed boolean value.
  17. [h1 Header]
  18. #include <boost/metaparse/util/is_whitespace.hpp>
  19. [h1 Expression semantics]
  20. For any `C` nullary template metafunction returning a wrapped character value
  21. the following are equivalent:
  22. is_whitespace<C>::type
  23. is_whitespace<>::type::apply<C>::type
  24. is_whitespace_c<C::type::value>::type
  25. [h1 Example]
  26. #include <boost/metaparse/util/is_whitespace.hpp>
  27. #include <type_traits>
  28. using namespace boost::metaparse;
  29. struct returns_char
  30. {
  31. using type = std::integral_constant<char, ' '>;
  32. };
  33. static_assert(
  34. util::is_whitespace<std::integral_constant<char, ' '>>::type::value,
  35. "a space should be a whitespace character"
  36. );
  37. static_assert(
  38. !util::is_whitespace<std::integral_constant<char, '0'>>::type::value,
  39. "a number should not be a whitespace character"
  40. );
  41. static_assert(
  42. util::is_whitespace<>::type
  43. ::apply<std::integral_constant<char, '\t'>>::type::value,
  44. "it should support currying"
  45. );
  46. static_assert(
  47. util::is_whitespace<returns_char>::type::value,
  48. "it should support lazy evaluation"
  49. );
  50. [endsect]