1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- [#get_position]
- [section get_position]
- [h1 Synopsis]
- template <class D>
- struct get_position;
- This is a [link lazy_metafunction lazy template metafunction].
- [table Arguments
- [[Name] [Type]]
- [[`D`] [[link accept accept] or [link reject reject] value]]
- ]
- [h1 Description]
- Returns the source position information of a parsing result.
- [h1 Header]
- #include <boost/metaparse/get_position.hpp>
- [h1 Example]
- #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"
- );
- [endsect]
|