prog.cpp: In function ‘int main(int, const char**)’:
prog.cpp:23:8: error: invalid initialization of non-const reference of type ‘std::shared_ptr<Base>&’ from an rvalue of type ‘std::shared_ptr<Base>’
f(b);
^
In file included from /usr/include/c++/6/memory:82:0,
from prog.cpp:2:
/usr/include/c++/6/bits/shared_ptr.h:221:2: note: after user-defined conversion: std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Tp1>&) [with _Tp1 = Derived; <template-parameter-2-2> = void; _Tp = Base]
shared_ptr(const shared_ptr<_Tp1>& __r) noexcept
^~~~~~~~~~
prog.cpp:8:6: note: initializing argument 1 of ‘void f(std::shared_ptr<Base>&)’
void f(std::shared_ptr<Base>& x)
^