is_letter.qbk 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. [#is_letter]
  2. [section is_letter]
  3. [h1 Synopsis]
  4. namespace util
  5. {
  6. template <class C>
  7. struct is_letter;
  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 letter. Returns a boxed boolean value.
  17. [h1 Header]
  18. #include <boost/metaparse/util/is_letter.hpp>
  19. [h1 Expression semantics]
  20. The following expressions are equivalent:
  21. is_letter<>::apply<boost::mpl::char_<'a'>>::type
  22. boost::mpl::true_
  23. is_letter<>::apply<boost::mpl::char_<'z'>>::type
  24. boost::mpl::true_
  25. is_letter<>::apply<boost::mpl::char_<'A'>>::type
  26. boost::mpl::true_
  27. is_letter<>::apply<boost::mpl::char_<'Z'>>::type
  28. boost::mpl::true_
  29. is_letter<>::apply<c>::type
  30. boost::mpl::false_
  31. [h1 Example]
  32. #include <boost/metaparse/util/is_letter.hpp>
  33. #include <type_traits>
  34. using namespace boost::metaparse;
  35. struct returns_char
  36. {
  37. using type = std::integral_constant<char, 'A'>;
  38. };
  39. static_assert(
  40. util::is_letter<std::integral_constant<char, 'A'>>::type::value,
  41. "A should be a letter"
  42. );
  43. static_assert(
  44. !util::is_letter<std::integral_constant<char, '0'>>::type::value,
  45. "a number should not be a letter"
  46. );
  47. static_assert(
  48. util::is_letter<>::type
  49. ::apply<std::integral_constant<char, 'A'>>::type::value,
  50. "it should support currying"
  51. );
  52. static_assert(
  53. util::is_letter<returns_char>::type::value,
  54. "it should support lazy evaluation"
  55. );
  56. [endsect]