Boost logo

Boost :

Subject: Re: [boost] [review][variant2] visit needs better user documentation
From: Larry Evans (cppljevans_at_[hidden])
Date: 2019-04-06 17:20:15

On 4/6/19 10:51 AM, Peter Dimov via Boost wrote:
> 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:
>> 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 <boost/variant2/variant.hpp>
> #include <string>
> using namespace boost::variant2;
> int main()
> {
>    variant<int, float, double, char, std::string> v1( 1 );
>    variant<int, float, double, char, std::string> const v2( 3.14f );
>    variant<int, float, double, char, std::string> v3( 6.28 );
>    variant<int, float, double, char, std::string> const v4( 'A' );
>    variant<int, float, double, char, std::string> 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:
> and, you're right, the workaround only supports up to four arguments.
Thanks for clearing that up.

However, I did some more exploring, and with the attached:

when only defined(UNSIGNED_I4), it compiles within a few secs.
when only defined(UNSIGNED_I5), it times several seconds consuming
100% of one of my cpu's, but eventually compiles.
OTOH, when onely UNSIGNED_I5) is defined, it never terminates:
--{--cut here--
-*- mode: compilation; default-directory:
Compilation started at Sat Apr 6 12:13:45

make -k run
/usr/bin/clang++ -c -O0 -gdwarf-2 -std=c++17
-ftemplate-backtrace-limit=0 -fdiagnostics-show-template-tree
-fno-elide-type -fmacro-backtrace-limit=0 -I../variant2/include
-ftemplate-depth=200 visit_unsigned_i.cpp -MMD -o

/home/evansl/prog_dev/root.imk:182: recipe for target
make: ***

Compilation interrupt at Sat Apr 6 12:14:33
--}--cut here--

Have you any idea why?


Boost list run by bdawes at, gregod at, cpdaniel at, john at