I constantly encounter an error that makes sense no matching constructor for initialization of 'std::shared_ptr<void>', but I don’t know where to start.
no matching constructor for initialization of 'std::shared_ptr<void>'
Here is what I work for.
#include <memory> struct Container { int type; std::shared_ptr<void> payload; Container(int t, const void *p) : type(t), payload(p) { } }; int main() { return 0; }
I am trying to create a generic container using shared_ptrwith a type void. I was going to make a type switch, and then just pass the payload to the appropriate type.
shared_ptr
void
I decided that I could just do something like Container ctn(1, new Data());that, but I think I might have it wrong too.
Container ctn(1, new Data());
Thank.
void const void, . "" , .
const void
payload std::shared_ptr<const void>, (, , ) p void*.
payload
std::shared_ptr<const void>
p
void*
, , , , . payload , , Data, . , , .
Data
: Boost.Any, , , , .
, void shared_ptr, void . shared_ptr , deleter . :
struct Container { int type; std::shared_ptr<void> payload; template<typename T> Container(int t, T* p) : type(t), payload(p) { } };
, , , , .
shared_ptr<T>
, , , , ( java-).