2

Why copying foo instance 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);
  // auto g = f;  // ERROR -> call of overloaded 'convert_construct(foo&, long int)' is ambiguous
}

Live example: cpp.sh/7f3xy

sehe
  • 374,641
  • 47
  • 450
  • 633
Michal
  • 2,078
  • 19
  • 29
  • 2
    gcc accepts it, but not clang [Demo](http://coliru.stacked-crooked.com/a/c78620c2fd71ac92). No need of lambda btw, any copy constructed object reproduce the issue: `auto g = f;`. – Jarod42 Apr 26 '18 at 16:24
  • @Jarod42 applied simplification to example code – Michal Apr 26 '18 at 16:32

0 Answers0