Код: Выделить всё
shared_ptrКод: Выделить всё
#include
#include
#include
#include
#include
#include
#include
#include
using namespace boost::type_erasure;
// PROBLEM DOMAIN - disparate hierarchies of classes:
struct Base {
virtual ~Base() {}
virtual void f() = 0;
};
struct Derived : Base {
void f() override {
std::cout get(b);
if (b) b->f();
}
< /code>
Этот код компилируется и работает под Visual Studio 2022, но он не ведет себя так, как я желаю, потому что я прокомментировал эту строку: < /p>
//x = d;
< /code>
Когда я расстроен эту строку, компиляция не удается со следующей ошибкой: < /p>
Build started at 11:38...
1>------ Build started: Project: test, Configuration: Debug x64 ------
1>test.cpp
1>C:\bob\projects\boost\boost\type_erasure\any.hpp(2270,9): error C2672: 'boost::type_erasure::any::_boost_type_erasure_assign_impl': no matching overloaded function found
1>(compiling source file 'test.cpp')
1>C:\bob\projects\boost\boost\type_erasure\any.hpp(2321,10):
1>could be 'void boost::type_erasure::any::_boost_type_erasure_assign_impl(Other &&,const void *,boost::mpl::true_)'
1> C:\bob\projects\boost\boost\type_erasure\any.hpp(2293,14):
1> 'initializing': cannot convert from 'boost::mpl::and_' to 'boost::mpl::true_'
1> with
1> [
1> Concept=wrapper_base::requirements,
1> Other=std::shared_ptr &
1> ]
1> C:\bob\projects\boost\boost\type_erasure\any.hpp(2293,14):
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>C:\bob\projects\boost\boost\type_erasure\any.hpp(2307,10):
1>or 'void boost::type_erasure::any::_boost_type_erasure_assign_impl(Other &&,const boost::type_erasure::assignable *,boost::mpl::true_)'
1> with
1> [
1> T=_x
1> ]
1> C:\bob\projects\boost\boost\type_erasure\any.hpp(2270,9):
1> 'void boost::type_erasure::any::_boost_type_erasure_assign_impl(Other &&,const boost::type_erasure::assignable *,boost::mpl::true_)': could not deduce template argument for 'const boost::type_erasure::assignable *' from 'void *'
1> with
1> [
1> T=_x
1> ]
1>C:\bob\projects\boost\boost\type_erasure\any.hpp(2298,10):
1>or 'void boost::type_erasure::any::_boost_type_erasure_assign_impl(Other &&,const boost::type_erasure::assignable *,boost::mpl::false_)'
1> with
1> [
1> T=_x
1> ]
1> C:\bob\projects\boost\boost\type_erasure\any.hpp(2270,9):
1> 'void boost::type_erasure::any::_boost_type_erasure_assign_impl(Other &&,const boost::type_erasure::assignable *,boost::mpl::false_)': could not deduce template argument for 'const boost::type_erasure::assignable *' from 'void *'
1> with
1> [
1> T=_x
1> ]
1>C:\bob\projects\boost\boost\type_erasure\any.hpp(2270,9):
1>the template instantiation context (the oldest one first) is
1> C:\bob\projects\test\test.cpp(54,11):
1> see reference to function template instantiation 'boost::type_erasure::any &boost::type_erasure::any::operator =(U)' being compiled
1> with
1> [
1> U=std::shared_ptr &
1> ]
1> C:\bob\projects\test\test.cpp(54,11):
1> see the first reference to 'boost::type_erasure::any::operator =' in 'wrapper_derived::do_get'
1> C:\bob\projects\boost\boost\type_erasure\any.hpp(2234,9):
1> see reference to function template instantiation 'void boost::type_erasure::any::_boost_type_erasure_resolve_assign(Other)' being compiled
1> with
1> [
1> Other=std::shared_ptr &
1> ]
1>Done building project "test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 11:38 and took 01.500 seconds ==========
Подробнее здесь: https://stackoverflow.com/questions/794 ... hared-ptrt