Stroustrup's talk on C++0x

James Dennett jdennett at acm.org
Sun Aug 26 15:11:01 PDT 2007


Walter Bright wrote:
> Sean Kelly wrote:
>> The obvious disadvantage to this approach is that is requires
>> implementation of an interface by the creator of the object.  More
>> often, I use an additional value parameter to specialize against:
>>
>> template Foo(T, bool isValid : true = PassesSomeTest!(T)) {}
>>
>> This also works for non-class types.  I'm not sure I like the syntax
>> quite as much as concepts here, but it's good enough that I haven't
>> really missed them.
> 
> This is a brilliant idea. It would make for a great article! Can I press
> you to write it? Doesn't have to be long, just explain the concept(!)
> and flesh it out with a few examples.

Is this largely comparable to C++0x's enable_if (except that, as
I understand it, D appears to be more flexible in how the compile-
time test can work/be expressed)?  enable_if certainly covers many
of the simple use cases for Concepts (though not so elegantly as
C++0x Concepts do).

-- James



More information about the Digitalmars-d mailing list