Home | Libraries | People | FAQ | More |
template <class D> struct get_position;
This is a lazy template metafunction.
Returns the source position information of a parsing result.
#include <boost/metaparse/get_position.hpp>
#include <boost/metaparse/get_position.hpp> #include <boost/metaparse/start.hpp> #include <boost/metaparse/accept.hpp> #include <boost/metaparse/reject.hpp> #include <boost/metaparse/string.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 { using type = reject<sample_error, start>; }; static_assert( std::is_same< start, get_position<reject<sample_error, start>>::type >::type::value, "It should return the position of a reject" ); static_assert( std::is_same< start, get_position< accept<sample_error, BOOST_METAPARSE_STRING("foo"), start> >::type >::type::value, "It should return the position of an accept" ); static_assert( std::is_same<start, get_position<returns_reject>::type>::type::value, "It should support lazy evaluation" );