[RFC] std.experimental.concepts
Martin Nowak via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jul 25 07:14:51 PDT 2015
On Saturday, 25 July 2015 at 14:06:05 UTC, Daniel N wrote:
> On Friday, 24 July 2015 at 19:56:55 UTC, Shammah Chancellor
> wrote:
>> I put up a PR for phobos awhile ago for concepts as a library
>> to kind of start the discussion around concepts. There
>> seemed to be some interest around the PR, so I have rebased it
>> and fixed the formatting.
>>
>> Please take a look:
>> https://github.com/D-Programming-Language/phobos/pull/2627
>>
>> -Shammah
>
> For those who are on a sugar-rush from Concepts, maybe this is
> a fun trick?
>
> It almost works, if only IFTI was smart enough to deal with
> eponymous identity templates.
>
> ========================================
> int fun(T)(T t) if(is(typeof(T.Put)))
> {
> }
> ========================================
> template Putty(T)
> {
> static assert(is(typeof(T.Put)));
>
> alias Putty = T;
> }
> void fun(T)(Putty!T t)
> {
> }
> ========================================
Templates are not bijective, so we'll never be generally able to
determine T by matching Putty, i.e. 2 different T could have the
same Putty!T type.
Adding an exception for identity templates seems to be a hack.
More information about the Digitalmars-d
mailing list