Skip to content

Commit e1d492b

Browse files
committed
Reparent aggregate limitations section to nested templates
1 parent 2c0d274 commit e1d492b

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

spec/template.dd

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,26 @@ $(H2 $(LNAME2 nested-templates, Nested Templates))
15071507
of class $(D C), and $(D Bar!().bar) will work just the same as a nested
15081508
function within function $(D main$(LPAREN)$(RPAREN)).)
15091509

1510+
$(H3 $(LNAME2 limitations, Limitations))
1511+
1512+
$(P Templates cannot be used to add non-static fields or
1513+
virtual functions to classes or interfaces.
1514+
For example:)
1515+
1516+
------
1517+
class Foo
1518+
{
1519+
template TBar(T)
1520+
{
1521+
T xx; // becomes a static field of Foo
1522+
int func(T) { ... } // non-virtual
1523+
1524+
static T yy; // Ok
1525+
static int func(T t, int y) { ... } // Ok
1526+
}
1527+
}
1528+
------
1529+
15101530
$(H3 $(LNAME2 implicit-nesting, Implicit Nesting))
15111531

15121532
$(P If a template has a $(RELATIVE_LINK2 aliasparameters, template alias parameter),
@@ -1730,26 +1750,6 @@ $(GNAME Constraint):
17301750
auto y = Bar!double; // Error, double does not satisfy constraint
17311751
---
17321752

1733-
$(H2 $(LNAME2 limitations, Limitations))
1734-
1735-
$(P Templates cannot be used to add non-static fields or
1736-
virtual functions to classes or interfaces.
1737-
For example:)
1738-
1739-
------
1740-
class Foo
1741-
{
1742-
template TBar(T)
1743-
{
1744-
T xx; // becomes a static field of Foo
1745-
int func(T) { ... } // non-virtual
1746-
1747-
static T yy; // Ok
1748-
static int func(T t, int y) { ... } // Ok
1749-
}
1750-
}
1751-
------
1752-
17531753
$(SPEC_SUBNAV_PREV_NEXT operatoroverloading, Operator Overloading, template-mixin, Template Mixins)
17541754
)
17551755

0 commit comments

Comments
 (0)