[Issue 5934] New: Finite recursive templates are not allowed
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri May 6 06:26:39 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5934
Summary: Finite recursive templates are not allowed
Product: D
Version: D2
Platform: x86_64
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: maximzms at gmail.com
--- Comment #0 from Maksim Zholudev <maximzms at gmail.com> 2011-05-06 06:22:45 PDT ---
Finite recursion in parametrized structures produces compilation errors.
This kind of recursion could be used to implement custom compile-time
expression parsing for user-defined types.
It should be limited but not forbidden.
Example:
----------
struct Foo
{
auto opUnary(string op)()
if(op == "-")
{
return Negation!(typeof(this))(this);
}
}
struct Negation(T)
{
T statement;
auto opUnary(string op)()
if(op == "-")
{
return Negation!(typeof(this))(this);
}
}
void main()
{
Foo a;
auto b = -a; // no errors
auto c = -(-a); /* Error: recursive template expansion for template
* argument Negation!(Foo)
*/
}
----------
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list