Boost logo

Boost Users :

Subject: Re: [Boost-users] operator<< for std::vector< boost::variant< type_a, type_b >>
From: Maarten Verhage (m_r_verhage_at_[hidden])
Date: 2018-06-18 21:22:44


----- Original Message -----
From: "Michael Powell via Boost-users" <boost-users_at_[hidden]>
To: <boost-users_at_[hidden]>
Cc: "Michael Powell" <mwpowellhtx_at_[hidden]>
Sent: Monday, June 18, 2018 23:00
Subject: Re: [Boost-users] operator<< for std::vector< boost::variant<
type_a, type_b >>

> On Mon, Jun 18, 2018 at 4:51 PM, Chris Cleeland via Boost-users
> <boost-users_at_[hidden]> wrote:
>>
>>
>> On Mon, Jun 18, 2018 at 3:20 PM Maarten Verhage via Boost-users
>> <boost-users_at_[hidden]> wrote:
>>>
>>>
>>>
>>> boost::variant is obviously part of boost. And the compiler error is
>>> pointing in a variant header. So I'm pretty confident "Boost users" in
>>> the
>>> appropriate mailing list for this issue.
>>
>>
>> Except for the fact that it's not. I looked at the code, and I suspect
>> you've ended up confusing yourself.
>>
>> In particular, your typedefs are confusing. Are you sure you didn't mean
>> this? It looks like you did based on the rest of the code.
>>
>> typedef boost::variant< int, double > parameter_t;
>> typedef std::vector< parameter_t > employee_t;

I'm actually pursuing this tree-like hierarchy. I might even need to make it
recursive. But I want to start easy.

typedef std::vector< boost::variant< int, double >> parameter_t;
typedef std::vector< boost::variant< int, double, parameter_t >> employee_t;

Have you looked into the stackoverflow answer by: Richard Hodges? The poster
had the same compiler error and the solution Richard presented is
significantly more complicated than a single operator<< overload.

>> In other words, a vector (type `employee_t`) where each element is a
>> variant
>> of either `int` or `double`.
>>
>> If that's what you meant to type, then compiling with clang++ -std=c++14
>> creates an a.out that prints "306000" as expected.
>>
>>>
>>>
>>> You know, I sense some resentment against me. Can you clarify please?
>>
>>
>> I didn't. In fact, he answered your question by giving you references to
>> documentation based on the error message you presented. Unfortunately I
>> think that error message was a red herring.
>
> Glad to help. Consider it on the table, rule it out if it isn't useful
> to you, or in this case helps to narrow the root cause, or whatever.
> Completely up to you.
>
>>> If you opened the attachment you can see I'm already at that level. And
>>> according to the stackoverflow answer for a very much related issue the
>>> solution is some next level stuff.
>>
>>
>> Fortunately, I suspect that the solution really just involves fixing your
>> types.
>>
>> --
>> Chris Cleeland
>>
>> _______________________________________________
>> Boost-users mailing list
>> Boost-users_at_[hidden]
>> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net