On Mon, Jun 18, 2018 at 4:23 PM Maarten Verhage via Boost-users < boost-users@lists.boost.org> wrote:
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;
Strange structure, but okay.
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.
Yes I did. He tells you the answer--that boost::variant's auto-io visit looks for an ADL-found operator<< for the types, and, as your compiler tells you, it can't find one for std::vector<blah>. Because it's ADL-found, the operators you defined at global scope will never match. They will only be found if they are defined in namespace std or in whatever namespace contains the compile-time invocation of operator<<. As the stackoverflow answer indicates, neither is a really great idea, because it's a violation of the standard to introduce anything into namespace std, and introducing it into the invoking namespace requires knowing the invoking namespace--which is an implementation detail of boost::variant and may change or may even vary depending on the types used. For grins I used your original and put two operator<< inside `namespace std`--one for each of your typedefs. The compiler found them both and created an executable that ran. Good luck. -- Chris Cleeland