Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
March 09, 2008 [Issue 1900] New: Template overload sets & traits templates | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=1900 Summary: Template overload sets & traits templates Product: D Version: 2.012 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: wbaxter@gmail.com I'm not sure this kind of thing is supposed to work with template overload sets, but I hope it is supposed to, as it is a pattern I see often in C++ code. The idea is to define some "Traits" templates that define various compile-time aspects of a particular type. ---- module main; import std.stdio; import A; import B; import generic; void main() { AClass a; BClass b; writefln("Traits!(AClass).name: ", Traits!(AClass).name); writefln("Traits!(BClass).name: ", Traits!(BClass).name); writefln("Traits!(int).name: ", Traits!(int).name); } ---- module A; class AClass { } template Traits(T : AClass) { enum string name = "AClass"; } ---- module B; class BClass { } string func(BClass b) { return "BClass"; } template Traits(T : BClass) { enum string name = "BClass"; } ---- module generic; struct Traits(T) { const string name = "any"; } ---- Right now I get: main.d(18): template instance Traits is not a template declaration, it is a overloadset main.d(18): Error: undefined identifier Traits!(AClass).name (Also note the grammar error in the message "it is a overload set".) -- |
August 09, 2008 [Issue 1900] Template overload sets & traits templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1900 ------- Comment #1 from samukha@voliacable.com 2008-08-09 06:20 ------- At least, there should be a way to merge template overload sets as it is the case with function overload sets. alias A.Traits Traits; alias B.Traits Traits; alias generic.Traits Traits; Error: declaration Traits is already defined Another use case: ---- template Foo(T) { template Bar(U : T) { } } mixin Foo!(int) A; mixin Foo!(char) B; alias Bar!(int) bar; //error ---- Error: template instance Bar is not a template declaration, it is a overloadset -- |
November 10, 2009 [Issue 1900] Template overload sets & traits templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1900 Eldar Insafutdinov <e.insafutdinov@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |e.insafutdinov@gmail.com --- Comment #2 from Eldar Insafutdinov <e.insafutdinov@gmail.com> 2009-11-09 22:34:01 PST --- Seems like there has not been an update on this one for quite along time. That is obviously a big issue, there should be a way to merge template overload sets, otherwise some great opportunities in using templates are lost. I am using templates in Qt bindings for specifying some compile-time information for types. My usecase is very similar to that provided by Bill. I would really like for this one to be resolved. Thanks. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 10, 2009 [Issue 1900] Template overload sets & traits templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1900 --- Comment #3 from Bill Baxter <wbaxter@gmail.com> 2009-11-10 03:59:01 PST --- (In reply to comment #2) > Seems like there has not been an update on this one for quite along time. That > is obviously a big issue, there should be a way to merge template overload > sets, otherwise some great opportunities in using templates are lost. I am > using templates in Qt bindings for specifying some compile-time information for > types. My usecase is very similar to that provided by Bill. I would really like > for this one to be resolved. > Thanks. I think I ended up working around this by putting the essential information into the classes themselves, and then having one Traits template that covered built-in types. Another big template did bunches of static structural tests to tease the needed information out of a class. In my case that was sufficient. But it's certainly more cumbersome to deal with. Perhaps you can explain your case in a little more detail and we might be able to come up with some workaround? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 14, 2013 [Issue 1900] Template overload sets & traits templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1900 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull Platform|x86 |All OS/Version|Windows |All --- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2013-02-14 08:05:16 PST --- https://github.com/D-Programming-Language/dmd/pull/1660 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 17, 2013 [Issue 1900] Template overload sets & traits templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1900 --- Comment #5 from github-bugzilla@puremagic.com 2013-07-16 18:35:45 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/e59a33f2b639dc9a6eb431ebcf694f533916f038 fix Issue 1900 - Template overload sets & traits templates https://github.com/D-Programming-Language/dmd/commit/cc6b7372f2efffd4c5c0314373af3b595ba06a2c Merge pull request #1660 from 9rnsr/fix1900 Issue 1900 & 8352 & 9235 - Implement Template Overload Set -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 17, 2013 [Issue 1900] Template overload sets & traits templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1900 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rejects-valid Status|NEW |RESOLVED Depends on| |10658 Resolution| |FIXED --- Comment #6 from Kenji Hara <k.hara.pg@gmail.com> 2013-07-17 00:10:39 PDT --- Template overload set has been implemented in git head. But, merging overload set by using alias declaration is not yet implemented. See bug 10658. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 17, 2013 [Issue 1900] Template overload sets & traits templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1900 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED | -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation