Const sucks

Janice Caron caron800 at googlemail.com
Tue Sep 11 02:10:33 PDT 2007


On 9/11/07, Derek Parnell <derek at nomail.afraid.org> wrote:
>
> In other words, if I have a struct with three members, each of a different
> type, I need to code ...
>
> struct S3(T, U, V)
> {
>    T member1;
>    U member2;
>    V member3;
> }
>
> S3!(const(int), const(float), const(bool));
>
> and so on for 4, 5, 6, .... 23 member structs.
>
> I'm sure I'm misunderstanding you, because this is really silly.
>

I don't think you're misunderstanding. I think that's what Walter is saying.

But here's another idea. If it were allowable that
(1) an alias template parameter could accept a type constructor, and
(2) "auto" were accepted as a do-nothing type constructor
then you would be able to do this:

 struct S(alias X)
 {
     X(int)* pi;
     X(float)* pf;
     X(double)* pd;
 };

 S(const) k; // k's members are tail-const
 S(auto) m; // m's members are mutable
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20070911/959768a6/attachment.html>


More information about the Digitalmars-d mailing list