I'm very new to C++11, 'still very much experimenting with the extensions. I find the auto
keyword very convenient, particularly when dealing with template variables. This means that given
template<typename ... Types>
struct Foo
{
};
template<typename ... Types>
Foo<Types ...>* create( Types ... types ... )
{
return new Foo<Types ...>;
}
I can now make the assignment
auto t1 = create( 'a' , 42 , true , 1.234 , "str" );
instead of
Foo<char, int, bool, double , const char*>* t2 = create( 'a' , 42 , true , 1.234 , "str" );
The problem now is that because t1
is a pointer I'd like to hold it in a shared_ptr
as Herb Sutter recommended. Therefore, I'd like to store the return value of create()
in a shared_ptr
without having to name the template argument types, as in t2
.