• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 Peter Dimov.
2 // Distributed under the Boost Software License, Version 1.0.
3 
4 #include <boost/tuple/tuple.hpp>
5 #include <boost/core/lightweight_test.hpp>
6 #include <boost/config.hpp>
7 #include <boost/config/pragma_message.hpp>
8 
9 #if defined(BOOST_NO_CXX11_HDR_TUPLE)
10 
11 BOOST_PRAGMA_MESSAGE("Skipping std::tuple_size tests for lack of <tuple>")
main()12 int main() {}
13 
14 #else
15 
16 #include <tuple>
17 
test(std::size_t x)18 template<class Tp> void test( std::size_t x )
19 {
20     BOOST_TEST_EQ( std::tuple_size< Tp >::value, x );
21     BOOST_TEST_EQ( std::tuple_size< typename Tp::inherited >::value, x );
22 }
23 
24 struct V
25 {
26 };
27 
main()28 int main()
29 {
30     test< boost::tuple<> >( 0 );
31     test< boost::tuple<V> >( 1 );
32     test< boost::tuple<V, V> >( 2 );
33     test< boost::tuple<V, V, V> >( 3 );
34     test< boost::tuple<V, V, V, V> >( 4 );
35     test< boost::tuple<V, V, V, V, V> >( 5 );
36     test< boost::tuple<V, V, V, V, V, V> >( 6 );
37     test< boost::tuple<V, V, V, V, V, V, V> >( 7 );
38     test< boost::tuple<V, V, V, V, V, V, V, V> >( 8 );
39     test< boost::tuple<V, V, V, V, V, V, V, V, V> >( 9 );
40     test< boost::tuple<V, V, V, V, V, V, V, V, V, V> >( 10 );
41 
42 #if !defined(BOOST_NO_CXX11_DECLTYPE)
43 
44     BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple())>::value, 0 );
45     BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1))>::value, 1 );
46     BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2))>::value, 2 );
47     BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3))>::value, 3 );
48     BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3, 4))>::value, 4 );
49     BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3, 4, 5))>::value, 5 );
50     BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3, 4, 5, 6))>::value, 6 );
51     BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3, 4, 5, 6, 7))>::value, 7 );
52     BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3, 4, 5, 6, 7, 8))>::value, 8 );
53     BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3, 4, 5, 6, 7, 8, 9))>::value, 9 );
54     BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))>::value, 10 );
55 
56 #endif
57 
58     return boost::report_errors();
59 }
60 
61 #endif
62