How can I initialize a shared pointer in the initialization list of a constructor?
I have this:
Foo::Foo (const callback &cb)
{
Bar bar;
bar.m_callback = cb;
m_ptr = std::make_shared<Bar>(bar);
//...
}
I would like to put this into the initializer list of the contructor. Something like:
Foo::Foo (const callback &cb) :
m_ptr(std::make_shared<Bar>(?????))
{
// ...
}
Bar is a struct
:
struct Bar
{
callback_type m_callback;
// etc.
};