get_line.qbk 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. [#get_line]
  2. [section get_line]
  3. [h1 Synopsis]
  4. template <class SourcePosition>
  5. struct get_line;
  6. This is a [link lazy_metafunction lazy template metafunction].
  7. [table Arguments
  8. [[Name] [Type]]
  9. [[`SourcePosition`] [[link source_position source position]]]
  10. ]
  11. [h1 Description]
  12. Returns the line of a source position.
  13. [h1 Header]
  14. #include <boost/metaparse/get_line.hpp>
  15. [h1 Expression semantics]
  16. For any `l`, `c` compile-time wrapped integral values and `ch` compile-time
  17. wrapped character the following are equivalent
  18. get_line<source_position<l, c, ch>>::type
  19. l::type
  20. [h1 Example]
  21. #include <boost/metaparse/get_line.hpp>
  22. #include <boost/metaparse/source_position.hpp>
  23. #include <type_traits>
  24. using namespace boost::metaparse;
  25. struct returns_source_position
  26. {
  27. using type =
  28. source_position<
  29. std::integral_constant<int, 11>,
  30. std::integral_constant<int, 13>,
  31. std::integral_constant<char, 0>
  32. >;
  33. };
  34. static_assert(
  35. get_line<
  36. source_position<
  37. std::integral_constant<int, 11>,
  38. std::integral_constant<int, 13>,
  39. std::integral_constant<char, 0>
  40. >
  41. >::type::value == 11,
  42. "It should return the line of a source position"
  43. );
  44. static_assert(
  45. get_line<returns_source_position>::type::value == 11,
  46. "It should support lazy evaluation"
  47. );
  48. [endsect]