Proposal: Static Invariant (C++ concept in D)
davidl
davidl at 126.com
Mon Sep 17 05:04:16 PDT 2007
I've read a little bit stuff of C++ concept, and find it has some
similarity with
D's runtime invariant in some abstraction. In some extent , we can imagine
C++
concept is kind of compile time invariant.
So the following:
class TemplateClass(T)
{
static invariant() // reuse keywords, nothing more get introduced
{
// prerequisite checking, does T have foo , does T have bar
Base_Concept_check(); // these emulate the inheritance of concept
Derived_Concept_check();
}
}
Thanks for the great discussion & help from h3r3tic, LeoD, Alexander,
Larsivi
They gave me some comments, and ideas.
Though it might not functionate all possiblities of C++ concept , but it
brings
us a little bit more powerful way to make sure our templates go all fine.
Hope
people love this idea :D
DavidL
More information about the Digitalmars-d
mailing list