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 20:19:47


----- 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 21:51
Subject: Re: [Boost-users] operator<< for std::vector< boost::variant<
type_a, type_b >>

> On Mon, Jun 18, 2018 at 2:55 PM, Maarten Verhage via Boost-users
> <boost-users_at_[hidden]> wrote:
>> Dear boost-savvy people,
>>
>> I fail to understand how I need to write a working ostream overload for a
>> type I have. I've read the boost::variant documentation. As well as
>> stackoverflow question:
>
> Not really a Boost question, per se:
>
> See "Stream extraction and insertion" in:
>
> http://en.cppreference.com/w/cpp/language/operators
>
> Basically, you need the stream reference as the first parameter,
> followed by whatever it is you are inserting, etc. Remember to return
> the stream reference.
>
> After that, decompose as needed for the complexity of your subject.
>
>> https://stackoverflow.com/questions/46343138/using-stdvectorboostvariant-with-google-mock-causes-a-compilation-err
>>

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.

You know, I sense some resentment against me. Can you clarify please?

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.

>> Still I fail to understand how to make it work for the type I have. In
>> the
>> code you can see parameter_t is an element in the employee_t. I need to
>> keep
>> this data structure this way.
>>
>> Attached is my single 30 line problem code. I do compile with gcc 5.1.0
>> with
>> C++14 support.
>>
>> It doesn't compile. The important part of the compiler output might be:
>> C:\dev\boost_1_67_0/boost/variant/detail/variant_io.hpp:64:14: error: no
>> match for 'operator<<' (operand types are 'std::basic_ostream<char>' and
>> 'const std::vector<boost::variant<int, double> >')
>> out_ << operand;
>>
>> My overload is obviously wrong. I would be very happy if someone can show
>> me
>> how to make it work.
>>
>> Best regards,
>> Maarten Verhage
>>
>> _______________________________________________
>> 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