Home | Libraries | People | FAQ | More |
template <class C> struct is_error;
This is a lazy template metafunction that supports currying.
Determines if C
is a parsing
error or not. Returns a boxed boolean
value.
#include <boost/metaparse/is_error.hpp>
For any e
parsing error
is_error<c>::type
is a wrapped compile-time true
value, for any other c
class is_error<c>::type
is a wrapped compile-time false
value.
#include <boost/metaparse/is_error.hpp> #include <boost/metaparse/accept.hpp> #include <boost/metaparse/reject.hpp> #include <boost/metaparse/string.hpp> #include <boost/metaparse/start.hpp> #include <boost/metaparse/define_error.hpp> #include <type_traits> using namespace boost::metaparse; BOOST_METAPARSE_DEFINE_ERROR(sample_error, "Sample error message"); struct returns_reject { typedef reject<sample_error, start> type; }; static_assert( !is_error< accept< std::integral_constant<int, 13>, BOOST_METAPARSE_STRING("foo"), start > >::type::value, "an accept should not be an error" ); static_assert( is_error<reject<sample_error, start>>::type::value, "an reject should be an error" ); static_assert( is_error<>::type::apply<reject<sample_error, start>>::type::value, "it should support currying" ); static_assert( is_error<returns_reject>::type::value, "it should support lazy evaluation" );