Let this() figure out T implicitly?

Kevin Cox kevincox.ca at gmail.com
Fri Feb 17 05:07:34 PST 2012


Yes.  At least as the compiler would say.  It's a little odd but I believe
that is how the D Nam mangling works.  I personally just think of
Foo!(Class) as the type.
On Feb 17, 2012 8:05 AM, "kraybourne" <stdin at kraybourne.com> wrote:

> On 2/17/12 1:51 PM, Kevin Cox wrote:
>
>> The error message is saying that you are trying to use Foo as a type but
>> Foo is not a type, it is a template for a type.
>>
>>
> Ah, so module.Foo is really not a class, but a template? I think I get it!
> Thanks!
>
> (Is then module.Foo(int).Foo the actual class type? I think I've seen
> errors like that pop up...)
>
>
>  On Feb 17, 2012 7:20 AM, "kraybourne" <stdin at kraybourne.com
>> <mailto:stdin at kraybourne.com>> wrote:
>>
>>    Hi!
>>
>>    This doesn't work:
>>
>>            import std.stdio;
>>            class Foo(T)
>>            {
>>                    T t;
>>                    this(T val)
>>                    {
>>                            t = val;
>>                    }
>>            }
>>
>>            void main()
>>            {
>>                    auto o = new Foo(5);
>>            }
>>            _____
>>
>>            $ dmd foo
>>            foo.d(13): Error: class foo.Foo(T) is used as a type
>>            $ _
>>
>>    So I must
>>
>>            auto o = new Foo!(int)(5);
>>
>>    Then it compiles. Is it possible to have this() figure out the type
>>    some way? (In this particular example it's perhaps not such a big
>>    deal. But imagine a lot more args.)
>>
>>    (Side note: What _does_ that error message mean? I don't get it.)
>>
>>    thanks
>>    /krbrn
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20120217/5d265b2e/attachment-0001.html>


More information about the Digitalmars-d-learn mailing list