Glen Stark schreef op 27-May-15 om 2:55 PM:
> Hi everyone
>
> I have something like the following:
>
> template <typename T>
> class Foo
> {
> Foo(std::vector<T*>);
> /*...*/
> }
>
> Now I'd like to be able to instantiate Foo without specifying the type,
> since I already have the type available to the constructor... For
> example, if I were so inclined, I could write the following:
>
> std::vector<some_component_type> components;
> Foo<std::remove_pointer<decltype(components)::value_type>::type>
> cm(components);
>
> and it would compile.
>
> I'm doing a refactoring where this obviously that's a silly way of doing
> this. I'd like to be able to do
> Foo f(components);
It seems that you (IMO rightly) object to mentioning T both explictily
in the type and implicitly in the parameter. Maybe a good alternative is:
auto f = Foo( components );
?
Wouter van Ooijen