1 2 // Copyright 2017 Peter Dimov. 3 // 4 // Distributed under the Boost Software License, Version 1.0. 5 // 6 // See accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt 8 9 10 #include <boost/mp11/detail/config.hpp> 11 12 #if BOOST_MP11_MSVC 13 # pragma warning( disable: 4503 ) // decorated name length exceeded 14 #endif 15 16 #include <boost/mp11/algorithm.hpp> 17 #include <boost/mp11/detail/config.hpp> 18 #include <boost/core/lightweight_test.hpp> 19 #include <tuple> 20 21 using boost::mp11::mp_size_t; 22 using boost::mp11::mp_for_each; 23 using boost::mp11::mp_with_index; 24 using boost::mp11::mp_iota_c; 25 26 struct F 27 { 28 std::size_t i_; 29 FF30 explicit F( std::size_t i ): i_( i ) {} 31 operator ()F32 template<std::size_t I> bool operator()( mp_size_t<I> ) const 33 { 34 BOOST_TEST_EQ( I, i_ ); 35 return false; 36 } 37 }; 38 39 struct G 40 { operator ()G41 void operator()( mp_size_t<0> ) const 42 { 43 } 44 operator ()G45 template<std::size_t N> void operator()( mp_size_t<N> ) const 46 { 47 for( std::size_t i = 0; i < N; ++i ) 48 { 49 mp_with_index<N>( i, F(i) ); 50 mp_with_index<mp_size_t<N>>( i, F(i) ); 51 } 52 } 53 }; 54 main()55int main() 56 { 57 #if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1900 ) 58 59 G()( mp_size_t<1>{} ); 60 G()( mp_size_t<2>{} ); 61 G()( mp_size_t<3>{} ); 62 G()( mp_size_t<4>{} ); 63 G()( mp_size_t<5>{} ); 64 G()( mp_size_t<6>{} ); 65 G()( mp_size_t<7>{} ); 66 G()( mp_size_t<8>{} ); 67 G()( mp_size_t<9>{} ); 68 G()( mp_size_t<10>{} ); 69 G()( mp_size_t<11>{} ); 70 G()( mp_size_t<12>{} ); 71 G()( mp_size_t<13>{} ); 72 G()( mp_size_t<14>{} ); 73 G()( mp_size_t<15>{} ); 74 G()( mp_size_t<16>{} ); 75 76 G()( mp_size_t<32+1>{} ); 77 78 G()( mp_size_t<48+2>{} ); 79 80 G()( mp_size_t<64+3>{} ); 81 82 G()( mp_size_t<96+4>{} ); 83 84 G()( mp_size_t<112+5>{} ); 85 86 G()( mp_size_t<128+6>{} ); 87 88 #else 89 90 mp_for_each<mp_iota_c<134>>( G() ); 91 92 #endif 93 94 return boost::report_errors(); 95 } 96