tail const
Simen kjaeraas
simen.kjaras at gmail.com
Sun Dec 5 06:24:01 PST 2010
Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> 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.
--
Simen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tailconst.d
Type: application/octet-stream
Size: 7787 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20101205/ef46a352/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tailconst2.d
Type: application/octet-stream
Size: 1257 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20101205/ef46a352/attachment-0003.obj>
More information about the Digitalmars-d
mailing list