Boost logo

Boost :

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


On 4/6/19 8:44 AM, Peter Dimov via Boost wrote:
> Larry Evans wrote:
>> The documents here:
>>
>>    https://pdimov.github.io/variant2/doc/html/variant2.html#ref_visit
>>
>> suggest visit can take any number of arguments.  However, the attached
>> fails to compile when defined(ARGS5).  The user docs should make clear
>> that there is a limit to the number of arguments.
>
> The error has nothing to do with number of arguments. The function
> object needs to be callable with any combination of types; the first
> variant, for instance, may hold a string, and therefore, the function
> object must be able to accept a string as its first argument.

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`?

Hmmm. Changed the all types of the lamba args to auto and
it still fails to compile :( Why is that?

It would illustrate better how to use `visit` if you provided
some examples other than those in the test directory.

I'm also having a hard time understanding how the implementation
at
https://github.com/pdimov/variant2/blob/develop/include/boost/variant2/variant.hpp#L1832
  works. Maybe some in source comments
would help there.

-regards,
Larry


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk