Skip to content

Commit 5bbf843

Browse files
authored
T.61 example fixes (#1813)
1 parent fa726d5 commit 5bbf843

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

CppCoreGuidelines.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -18034,14 +18034,14 @@ This limits use and typically increases code size.
1803418034

1803518035
##### Example, bad
1803618036

18037-
template<typename T, typename A = std::allocator{}>
18037+
template<typename T, typename A = std::allocator<T>>
1803818038
// requires Regular<T> && Allocator<A>
1803918039
class List {
1804018040
public:
1804118041
struct Link { // does not depend on A
1804218042
T elem;
18043-
T* pre;
18044-
T* suc;
18043+
Link* pre;
18044+
Link* suc;
1804518045
};
1804618046

1804718047
using iterator = Link*;
@@ -18062,11 +18062,11 @@ Typically, the solution is to make what would have been a nested class non-local
1806218062
template<typename T>
1806318063
struct Link {
1806418064
T elem;
18065-
T* pre;
18066-
T* suc;
18065+
Link* pre;
18066+
Link* suc;
1806718067
};
1806818068

18069-
template<typename T, typename A = std::allocator{}>
18069+
template<typename T, typename A = std::allocator<T>>
1807018070
// requires Regular<T> && Allocator<A>
1807118071
class List2 {
1807218072
public:
@@ -18076,11 +18076,11 @@ Typically, the solution is to make what would have been a nested class non-local
1807618076

1807718077
// ...
1807818078
private:
18079-
Link* head;
18079+
Link<T>* head;
1808018080
};
1808118081

18082-
List<int> lst1;
18083-
List<int, My_allocator> lst2;
18082+
List2<int> lst1;
18083+
List2<int, My_allocator> lst2;
1808418084

1808518085
Some people found the idea that the `Link` no longer was hidden inside the list scary, so we named the technique
1808618086
[SCARY](http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2009/n2911.pdf). From that academic paper:

0 commit comments

Comments
 (0)