jeudi 26 avril 2018

Error passing boost::variant derived class to lambda

Why passing foo instance to lambda generates error: error: call of overloaded 'convert_construct(foo&, long int)' is ambiguous ?

#include <iostream>
#include <string>
#include <boost/variant.hpp>

struct foo : public boost::variant<int, std::string>
{
    using boost::variant<int, std::string>::variant;
};

int main()
{
  foo f(111);
  std::cout << f << std::endl;
  //[f](){std::cout << f << std::endl;}();  // ERROR -> call of overloaded 'convert_construct(foo&, long int)' is ambiguous
}

Live example http://cpp.sh/2k5td

Aucun commentaire:

Enregistrer un commentaire