Simen kjaeraas <[email protected]> wrote:

Andrei Alexandrescu <[email protected]> wrote:

On 12/4/10 12:23 PM, Simen kjaeraas wrote:

To expound further on this, I have created the attached module.
Critique wanted.


Looks promising. A few comments.

* For TailXxx you need to handle built-in simple types (int, float...)
to return themselves. Also, structs for which hasIndirections returns
false also return themselves.

Done.

* tailconst_t does not obey Phobos' naming convention. I think it's fine
to use TailConst in spite of the apparent ambiguity.

It adds some .'s:
     alias SimpleRange!(.TailConst!T) TailConst;
     static if ( !is( T == .TailMutable!T ) ) {
     this( SimpleRange.TailImmutable r ) {

Not sure if this is a problem.


* You may want to add more stringent checks for tailconst_t (well
TailConst etc) to make sure it's not bogus - has the same size,
compatible members etc.

I've tried, and it seems adding
       static assert( T.sizeof == T.TailConst.sizeof );
does not work (no size yet for forward reference).

Checking that all members are the same type and order is easy and
works. Comparing member names bumped me into bug 5079. Likely related
to the above, seeing as both have to do with unfinished types.



I've also considered a template on the form

     mixin tailConst!( SimpleRange, SimpleRange!( Tail!T ) );
or
     mixin tailConst!( SimpleRange, Tail!T );

which would automagically define aliases. More work for me, perhaps
less work for users.

This could not define constructors, as overloads from inside template
mixins don't work with overloads outside.


Nobody ever commented on this. Figured I'd poke around with a stick
and see if there were any opinions. IOW: bump.

--
Simen

Reply via email to