• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016-2021 Antony Polukhin
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 #include <boost/pfr/core.hpp>
7 
8 #include <boost/core/lightweight_test.hpp>
9 
10 namespace helper {
11     template <std::size_t I, class T>
get(T && v)12     decltype(auto) get(T&& v) {
13         return boost::pfr::get<I>(std::forward<T>(v));
14     }
15 }
16 
main()17 int main() {
18     using namespace std;
19     using namespace helper;
20     struct foo { int i; short s;};
21 
22     foo f{1, 2};
23     BOOST_TEST_EQ(get<0>(f), 1);
24 
25     const foo cf{1, 2};
26     BOOST_TEST_EQ(get<1>(cf), 2);
27 
28     std::tuple<int, short> t{10, 20};
29     BOOST_TEST_EQ(get<0>(t), 10);
30 
31     const std::tuple<int, short> ct{10, 20};
32     BOOST_TEST_EQ(get<1>(ct), 20);
33 
34     return boost::report_errors();
35 }
36 
37