//OriginalSource: // https://github.com/pdimov/variant2/blob/develop/test/variant_visit.cpp //Purpose: // See if 5 argument visitor will work. //ChangeLog // rm'ed all tests except the one with 4 args // ; then added another arg (to make it 5 args). //Result: // when #defined(ARGS5), get compile error: /* In file included from visit5.cpp:16: ../variant2/include/boost/variant2/variant.hpp:1700:47: error: no matching function for call to object of type '(lambda at visit5.cpp:47:16)' template using fn = decltype( std::declval()( std::declval()... ) ); */ //====================== // Copyright 2017 Peter Dimov. // // Distributed under the Boost Software License, Version 1.0. // // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt #include #include #include #include #include template struct unsigned_i { unsigned_i(unsigned i=I) : value(i) {} unsigned value; }; using namespace boost::variant2; int main() { //#define UNSIGNED_I4 #ifdef UNSIGNED_I4 { std::cout<<"***UNSIGNED_I4.\n"; using vt= variant < unsigned_i<1> , unsigned_i<2> , unsigned_i<3> , unsigned_i<4> > ; vt v1( unsigned_i<1>{} ); vt v2( unsigned_i<2>{} ); vt v3( unsigned_i<3>{} ); vt v4( unsigned_i<4>{} ); visit( []( auto x1, auto x2, auto x3, auto x4){}, v1, v2, v3, v4 ); } #endif //#define UNSIGNED_I5 #ifdef UNSIGNED_I5 { std::cout<<"***UNSIGNED_I5.\n"; using vt= variant < unsigned_i<1> , unsigned_i<2> , unsigned_i<3> , unsigned_i<4> , unsigned_i<5> > ; vt v1( unsigned_i<1>{} ); vt v2( unsigned_i<2>{} ); vt v3( unsigned_i<3>{} ); vt v4( unsigned_i<4>{} ); vt v5( unsigned_i<5>{} ); visit( []( auto x1, auto x2, auto x3, auto x4, auto x5){}, v1, v2, v3, v4, v5 ); } #endif #define UNSIGNED_I6 #ifdef UNSIGNED_I6 { std::cout<<"***UNSIGNED_I6.\n"; using vt= variant < unsigned_i<1> , unsigned_i<2> , unsigned_i<3> , unsigned_i<4> , unsigned_i<5> , unsigned_i<6> > ; vt v1( unsigned_i<1>{} ); vt v2( unsigned_i<2>{} ); vt v3( unsigned_i<3>{} ); vt v4( unsigned_i<4>{} ); vt v5( unsigned_i<5>{} ); vt v6( unsigned_i<6>{} ); visit( []( auto x1, auto x2, auto x3, auto x4, auto x5, auto x6){}, v1, v2, v3, v4, v5, v6 ); } #endif return boost::report_errors(); }