Skip to content

Commit 6454e44

Browse files
committed
Change T.46 to not require copyability, and to account for traits types (see #2281)
Closes #2281
1 parent 1731b46 commit 6454e44

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

CppCoreGuidelines.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17074,7 +17074,7 @@ Template interface rule summary:
1707417074
* [T.42: Use template aliases to simplify notation and hide implementation details](#rt-alias)
1707517075
* [T.43: Prefer `using` over `typedef` for defining aliases](#rt-using)
1707617076
* [T.44: Use function templates to deduce class template argument types (where feasible)](#rt-deduce)
17077-
* [T.46: Require template arguments to be at least semiregular](#rt-regular)
17077+
* [T.46: Prefer template arguments to be movable and default-constructible](#rt-regular)
1707817078
* [T.47: Avoid highly visible unconstrained templates with common names](#rt-visible)
1707917079
* [T.48: If your compiler does not support concepts, fake them with `enable_if`](#rt-concept-def)
1708017080
* [T.49: Where possible, avoid type-erasure](#rt-erasure)
@@ -18110,7 +18110,7 @@ For example:
1811018110

1811118111
Flag uses where an explicitly specialized type exactly matches the types of the arguments used.
1811218112

18113-
### <a name="rt-regular"></a>T.46: Require template arguments to be at least semiregular
18113+
### <a name="rt-regular"></a>T.46: Prefer template arguments to be movable and default-constructible
1811418114

1811518115
##### Reason
1811618116

@@ -18120,6 +18120,7 @@ Most uses support that anyway.
1812018120

1812118121
##### Example
1812218122

18123+
// X is not default constructible
1812318124
class X {
1812418125
public:
1812518126
explicit X(int);
@@ -18135,13 +18136,13 @@ Most uses support that anyway.
1813518136
X y = x; // fine
1813618137
std::vector<X> v(10); // error: no default constructor
1813718138

18138-
##### Note
18139+
##### Exceptions
1813918140

18140-
Semiregular requires default constructible.
18141+
A trait type is not necessarily movable and default-constructible. Templates that use trait types usually use them with `Trait::something` scope resolution syntax, rather than using objects of the trait type.
1814118142

1814218143
##### Enforcement
1814318144

18144-
* Flag types used as template arguments that are not at least semiregular.
18145+
* Flag types used as template arguments that do not satisfy both `std::movable` and `std::default_constructible` and that are using in the template without `::` scope resolution syntax.
1814518146

1814618147
### <a name="rt-visible"></a>T.47: Avoid highly visible unconstrained templates with common names
1814718148

0 commit comments

Comments
 (0)