On Sat, Aug 6, 2011 at 22:19, Sean Eskapp <[email protected]> wrote:
> If I have something like
>
>    struct S(T)
>    {
>        T data;
>    }
>
>   I can't make a struct literal with
>
>    int mystuff;
>    someFunc(S(mystuff));
>
> I have to use
>
>    int mystuff;
>    someFunc(S!(int)(mystuff));
>
> Why is this?

Yeah, function templates have a way to automatically determine their
template parameters (IFTI : Implicit Function Template
Instantiation?), but that doesn't work with struct and class
constructors. Too bad.

You can use a factory function to do just that, it's a one-liner:

auto s(T)(T t) { return S!(T)(t); }

and then:

someFunc(s(mystuff));

Reply via email to