If I remember correctly (and according to this question), std::shared_ptr<Derived>
cannot be bind to const std::shared_ptr<Base>&
. But when I tried the following code, it doesn't give me even any warnings.
#include <memory>
struct A{};
struct B:A{};
void Do(const std::shared_ptr<A>&){}
template<typename T>
struct C{};
void DoC(const C<A>&){}
int main()
{
std::shared_ptr<B> b = std::make_shared<B>();
Do(b); //accept ?
/*following lines generate error
C<B> c;
DoC(c); //error
//*/
}
compiler is mingw g++ 5.3.0
with flag -std=c++14 -Wall -Wextra -pedantic -Werror
Same result with Coliru and many other online compiler.
Is there something I missed?