Re: Using Tuple and bind in Spirit causes compiler error

Joel de Guzman <[email protected]> Mon, 26 Oct 2020 08:18:28 +0800
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
On 10/26/20 12:55 am, Larry Evans wrote:
> On 10/23/20 8:49 PM, Joel de Guzman wrote:
>> On 10/24/20 1:50 am, Juan Dent wrote:
>>> Hi,
>>>
>>> I produced a MVCE with the error at compile time (see line 22 of
>>> MVCE.cpp). REMOVING the semantic action deletes the compiler error!
>>> The source is as follows:
>>> -------------------------------------------------------------------------------------------------------------------------------------
>>>
>>
>> If you use clang or g++, this is the error that you will get:
>>
>> /usr/local/include/boost/spirit/home/qi/detail/assign_to.hpp:153:20:
>> error: no matching conversion for static_cast from 'const
>> boost::fusion::vector<boost::optional<double>, boost::optional<int> >'
>> to 'boost::tuples::tuple<boost::optional<double>, boost::optional<int>,
>> ...>'
>>
>> Why is that happening? If you are using semantic actions, the semantic
>> action **WILL**
>> synthesize a suitable attribute for you. In this case, the synthesized
>> attribute is
>> a boost::fusion::vector which **IS NOT*** assignable to a boost::tuple.
>>
>> Suggestion 1: Avoid mixing semantic actions with attributes, unless you
>> really know
>> what you are doing and already gained more proficiency with Spirit. In
>> most cases,
>> you can live without semantic actions.
>>
>>
>> Suggestion 2: Try other compilers. Error messages generated by Visual
>> Studio are
>> often tough to decipher.
>>
>> Regards,
> Suggestion 3: Use transform_attribute:
> 

Suggestion 4: Just use fusion vector. It is a lot more powerful than the older
boost.tuple. To be honest, I don't understand why you are insisting on using it.

Regards,
-- 
Joel