Any word on the return-type const syntax?

Bill Baxter dnewsgroup at billbaxter.com
Sun Dec 9 10:41:18 PST 2007


Sean Kelly wrote:
> Walter Bright wrote:
>> Janice Caron wrote:
>>> But I think there's still a problem. If I write
>>>
>>>     class MyArray(T)
>>>     {
>>>         T[] a;
>>>         TransferConst!(U,T*) ptr(this U)()
>>>         {
>>>             return a.ptr;
>>>         }
>>>     }
>>>
>>>     const MyArray!(int) aa;
>>>     auto p = aa.ptr;
>>>
>>> Then presumably it won't compile, becase aa is not mutable,
>>
>> Template member functions are not instantiated until they are called.
> 
> Or until they are aliased, to be pedantic.

It's an important point though.  Does C++ behave that way?  I was under 
the impression that in C++ I could create typedefs of templated structs 
and classes that wouldn't get instantiated unless actually used.

--bb



More information about the Digitalmars-d mailing list