Skip to content

recursive_wrapper fail to compile when used with 2 classes which are base and derived #146

@BlueSolei

Description

@BlueSolei

The following code fails to compile (Visual Studio 2015 update 3):

#include <mapbox/variant.hpp>
using namespace mapbox::util;

struct Base;
struct Derived;
using Variant = variant<recursive_wrapper<Base>, recursive_wrapper<Derived>>;

struct Base { };
struct Derived : public Base { };

void TestMultipleRecursiveWrappers()
{
	Base base;
	Derived derived;
	Variant v;
 	v = base;
 	v = derived; // error
}

void OrEvenShorterExample()
{
        Derived derived;
	Variant v(derived); // error
}

error C2664: 'mapbox::util::variant<mapbox::util::recursive_wrapper,mapbox::util::recursive_wrapper>::variant(mapbox::util::variant<mapbox::util::recursive_wrapper,mapbox::util::recursive_wrapper> &&) noexcept()': cannot convert argument 1 from 'Derived' to 'mapbox::util::no_init'
note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions