1[#get_prev_char] 2[section get_prev_char] 3 4[h1 Synopsis] 5 6 template <class SourcePosition> 7 struct get_prev_char; 8 9This is a [link lazy_metafunction lazy template metafunction]. 10 11[table Arguments 12 [[Name] [Type]] 13 [[`SourcePosition`] [[link source_position source position]]] 14] 15 16[h1 Description] 17 18Returns the last character the source position was updated with. The value it 19returns for [link start `start`] is unspecified. 20 21[h1 Header] 22 23 #include <boost/metaparse/get_prev_char.hpp> 24 25[h1 Expression semantics] 26 27For any `l`, `c` compile-time wrapped integral values and `ch` compile-time 28wrapped character the following are equivalent 29 30 get_prev_char<source_position<l, c, ch>>::type 31 32 ch::type 33 34[h1 Example] 35 36 #include <boost/metaparse/get_prev_char.hpp> 37 #include <boost/metaparse/source_position.hpp> 38 39 #include <type_traits> 40 41 using namespace boost::metaparse; 42 43 struct returns_source_position 44 { 45 using type = 46 source_position< 47 std::integral_constant<int, 11>, 48 std::integral_constant<int, 13>, 49 std::integral_constant<char, 'x'> 50 >; 51 }; 52 53 static_assert( 54 get_prev_char< 55 source_position< 56 std::integral_constant<int, 11>, 57 std::integral_constant<int, 13>, 58 std::integral_constant<char, 'x'> 59 > 60 >::type::value == 'x', 61 "It should return the prev. char of a source position" 62 ); 63 64 static_assert( 65 get_prev_char<returns_source_position>::type::value == 'x', 66 "It should support lazy evaluation" 67 ); 68 69[endsect] 70 71