id summary reporter owner description type status milestone component version severity resolution keywords cc 11602 boost.variant constructor accepts any type as parameter piotrwn1@… Antony Polukhin "There is one ""converting constructor"" in boost.variant which accepts any type - even those which are not convertible to instantiation types of boost.variant. This causes that writing function accepting some specific variant instantiation cause that this function is on candidate list of any type in your program. The problem is with this constructor: {{{ template variant(const T& operand) { convert_construct(operand, 1L); } }}} And the small code presenting the issue: {{{ #include #include // types not related in any way class A {}; class B {}; class C {}; class D {}; using ABC_variant = boost::variant; std::ostream& operator << (std::ostream& os, const ABC_variant&) { return os << ""ABC""; } int main() { D d; std::cout << d; } }}} As described in [http://stackoverflow.com/questions/32275725/boostvariant-construction-weirdness-its-ctor-accepts-everything] compiler (gcc4.9) tries to use ostream operator with this diagnostic: /usr/include/boost/variant/variant.hpp:1591:38: error: no matching function for call to 'boost::variant::initializer::initialize(void*, D&)' initializer::initialize( However it should simple report that ostream operator for D is missing. One simple way is to declare this boost.variant constructor as explicit (what probably would impact to many client code) or to make some restriction in this constructor like this C++11 way: {{{ template struct IsAnyOf; template struct IsAnyOf : std::true_type {}; template struct IsAnyOf : std::false_type {}; template struct IsAnyOf : IsAnyOf {}; template ::value>::type> variant(const T& operand) }}} BR, Piotr Nycz (piotrwn1 @ gmail com) " Bugs closed Boost 1.62.0 variant Boost 1.58.0 Problem fixed raad@…