Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

is_letter

Synopsis

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

This is a lazy template metafunction that supports currying.

Table 47. Arguments

Name

Type

C

boxed character value


Description

Checks if C is a letter. Returns a boxed boolean value.

Header

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

Expression semantics

The following expressions are equivalent:

is_letter<>::apply<boost::mpl::char_<'a'>>::type
boost::mpl::true_

is_letter<>::apply<boost::mpl::char_<'z'>>::type
boost::mpl::true_

is_letter<>::apply<boost::mpl::char_<'A'>>::type
boost::mpl::true_

is_letter<>::apply<boost::mpl::char_<'Z'>>::type
boost::mpl::true_

is_letter<>::apply<c>::type
boost::mpl::false_

Example

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

#include <type_traits>

using namespace boost::metaparse;

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

static_assert(
  util::is_letter<std::integral_constant<char, 'A'>>::type::value,
  "A should be a letter"
);

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

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

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

PrevUpHomeNext