//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 #include #include #include #include using namespace boost::variant2; int main() { { variant v1( 1 ); variant const v2( 3.14f ); variant v3( 6.28 ); variant const v4( 'A' ); visit( []( int x1, float x2, double x3, char x4 ){ BOOST_TEST_EQ( x1, 1 ); BOOST_TEST_EQ( x2, 3.14f ); BOOST_TEST_EQ( x3, 6.28 ); BOOST_TEST_EQ( x4, 'A' ); }, v1, v2, v3, v4 ); } #define ARGS5 #ifdef ARGS5 { variant v1( 1 ); variant const v2( 3.14f ); variant v3( 6.28 ); variant const v4( 'A' ); variant const v5( "xxx" ); visit( []( int x1, float x2, double x3, char x4, std::string x5 ){ BOOST_TEST_EQ( x1, 1 ); BOOST_TEST_EQ( x2, 3.14f ); BOOST_TEST_EQ( x3, 6.28 ); BOOST_TEST_EQ( x4, 'A' ); BOOST_TEST_EQ( x4, "xxx" );}, v1, v2, v3, v4, v5 ); } #endif return boost::report_errors(); }