Static inheritance (proof of concept)
Iakh via Digitalmars-d
digitalmars-d at puremagic.com
Sat Feb 27 05:35:30 PST 2016
There was discussion and proposal to extend D with static
inheritance:
http://forum.dlang.org/thread/jwzxngccuwwizyivpeaf@forum.dlang.org
But it could be done just with mixins, UDAs and some rewriting of
predicates.
Exaple:
@concept!isInputRange()
struct Range
{
mixin checkConcepts;
int front()
{
return 0;
}
}
concept-check ~master: building configuration "application"...
source/app.d(73,0): Error: can't test for empty
source/app.d(73,0): Error: can't invoke popFront()
source/app.d(67,5): Error: static assert "Range is not a
concept!(isInputRange)"
checker function prototype:
bool checkConcept(Flag!"verbose" verbose = No.verbose,
string file = "", size_t line = "")()
if verbose==false this function could be used in template
constraint
just to check is template parameter match conditions without
printing errors
full code:
http://dpaste.dzfl.pl/5056ad68c7b4
More information about the Digitalmars-d
mailing list