Compile-Time Interfaces (Concepts)

bossfong via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 23 07:46:20 PDT 2014


Am 23.07.2014 16:27, schrieb H. S. Teoh via Digitalmars-d-learn:
>
> We could, though it's not quite the same as a native concepts
> implementation where the compiler can check templates for code that
> wrongly makes assumptions about the incoming type that aren't defined by
> the concept.
>
>
> T
>
true.

Still, maybe compiler errors could be provided by a library that defines 
an "Concept(Interface)" UDA that you could use to annotate 
implementations of "Concepts"?

import concepts;

@Concept(InputRange)
struct MyInputRange
{
// ...
}

verifyConcepts();

Is it that what you mean?

Just thinking things through here...


More information about the Digitalmars-d-learn mailing list