RFC: A tailconst template
Sönke Ludwig
ludwig at informatik_dot_uni-luebeck.de
Sat Feb 23 04:17:23 PST 2008
Since tailconst support for class types is still missing, I decided to try and
clean up the many related workarounds in my code. The result after a few hours
of trying to get the templates/ctfe-functions do what I want is a template
which casts the const/invariant class reference to void* internally and defines
proxy methods for all methods of the original class. This is already pretty
transparent in usage. But there are some issues left:
1. __traits(allMembers, T) does not seem to list methods which have only const
or invariant overloads:
class C {
const int myfunc();
}
in this case __traits(allMembers, C) would be empty. If there is no specific
reason for this, I'll file a bug report for this.
2. Support for public member variables is missing
Currently, only methods are supported. Personally, I'm using public variables
in classes pretty seldom. So this will come later.
3. Enums are reported as "int" by stringof
Is there some other way to get the type identifier as a string at compile
time? typeid(T).toString() works fine at runtime - but that doesn't help
for compile-time code generation.
(this would be http://d.puremagic.com/issues/show_bug.cgi?id=1610)
PS: ignore the copyright notice in the attached code - this is public domain
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tailconst.d
Type: text/x-dsrc
Size: 6557 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20080223/8e5b6ed9/attachment.d>
More information about the Digitalmars-d
mailing list