I have the following structure:
class A { A(const A&) {...} virtual int member() = 0; virtual ~A() {}; } class B : public A { virtual int member(){... } virtual ~B(){} } class C : public A { virtual int member(){... } virtual ~C(){} } And use std::shared_ptr<A> as return type of my factory.
std::shared_prt<A> Factory::get(params...) { ... return std::make_shared<B>(params); } std::shared_ptr<A> Aptr = Factory::get(params...) Now I try to pass it to an external method:
boost::iostreams::filtering_istream void push( const T& t, std::streamsize buffer_size = default value, std::streamsize pback_size = default value ); this call fails at compile time because some_external_function tries to call the pure member() of A and not of B.
concept_adapter.hpp:122: Error:cannot declare field 'boost::iostreams::detail::concept_adapter::t_' to be of abstract type 'A'
some_external_function? Does it get parameter by value? You should get it either by reference or pointer if you want polymorphism to work.some_external_functionand the exact details of the failure this question is off-topic and should be closed, please provide the information requested by Joachim Pileborg in the comment above.some_external_functiontries to call the puremember()ofA". It would appear thatAdoes not satisfy a requirement of the Boost code to which you are passing it - most like copy constructibility. Indeed, the documentation ofboost::iostreams::filtering_istream::pushrequires the first argument to be CopyConstructible.