Larry Evans wrote:
I only drew that conclusion because the number of args seems the only
difference between the test that compiles OK and the one that doesn't. The
code was copy&pasted from:
https://github.com/pdimov/variant2/blob/develop/test/variant_visit.cpp#L105
and the function object there only accepts `int` as it's first argument.
So, does that compile because any of the alternative types can be
converted to `int`?
Yes.
Hmmm. Changed the all types of the lamba args to auto and it still fails
to compile :( Why is that?
If we're talking about this program:
#include
#include <string>
using namespace boost::variant2;
int main()
{
variant v1( 1 );
variant const v2( 3.14f );
variant v3( 6.28 );
variant const v4( 'A' );
variant const v5( "xxx" );
visit( []( auto x1, auto x2, auto x3, auto x4, auto x5 ){}, v1, v2, v3,
v4, v5 );
}
it compiles with g++/clang++ -std=c++14, and doesn't with -std=c++11. It
also doesn't compile on VS2017 but compiles on VS2019. That's because the
unlimited argument implementation is disabled on C++11 or VS2017 here:
https://github.com/pdimov/variant2/blob/develop/include/boost/variant2/varia...
and, you're right, the workaround only supports up to four arguments.