Compiling this:
#include <iostream>
#include <memory>
template <auto val = 42>
struct A
{
A()
{
std::cerr << val << "\n";
}
};
int main(int argc, const char* argv[])
{
std::shared_ptr<A> a_ptr {new A {}};
return 0;
}
gives error: use of class template 'A' requires template arguments. Although I provide a default value for non-type template parameter and expect it to be seen and used by compiler somehow. What do I miss here ?
Thanks.
A a;will be fine, butstd::shared_ptr<A<>> ptr;requires more.