Skip to content

Commit 4d034f3

Browse files
committed
Add comment documenting why copy is =delete'd, closes #400
1 parent 768f125 commit 4d034f3

10 files changed

+18
-17
lines changed

regression-tests/test-results/pure2-defaulted-comparisons-and-final-types.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class widget final
2727

2828
public: [[nodiscard]] auto operator<=>(widget const& that) const -> std::strong_ordering = default;
2929

30-
public: widget(widget const&) = delete;
30+
public: widget(widget const&) = delete; /* No 'that' constructor, suppress copy */
3131
public: auto operator=(widget const&) -> void = delete;
3232
#line 11 "pure2-defaulted-comparisons-and-final-types.cpp2"
3333
};

regression-tests/test-results/pure2-requires-clauses.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ template<typename T, typename U>
2525
class X {
2626
public: X();
2727

28-
public: X(X const&) = delete;
28+
public: X(X const&) = delete; /* No 'that' constructor, suppress copy */
2929
public: auto operator=(X const&) -> void = delete;
3030
#line 8 "pure2-requires-clauses.cpp2"
3131
};

regression-tests/test-results/pure2-type-and-namespace-aliases.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class myclass {
3333
private: using str2 = std::string;
3434

3535
public: myclass() = default;
36-
public: myclass(myclass const&) = delete;
36+
public: myclass(myclass const&) = delete; /* No 'that' constructor, suppress copy */
3737
public: auto operator=(myclass const&) -> void = delete;
3838
#line 13 "pure2-type-and-namespace-aliases.cpp2"
3939
};

regression-tests/test-results/pure2-types-basics.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class myclass {
6565
public: static auto g() -> void;
6666

6767
public: nested() = default;
68-
public: nested(nested const&) = delete;
68+
public: nested(nested const&) = delete; /* No 'that' constructor, suppress copy */
6969
public: auto operator=(nested const&) -> void = delete;
7070

7171
#line 51 "pure2-types-basics.cpp2"
@@ -76,7 +76,7 @@ class myclass {
7676
public: template<auto T, auto U> [[nodiscard]] static auto f3() -> auto;
7777
public: template<cpp2::i8 T, cpp2::i16 U> [[nodiscard]] static auto f4() -> auto;
7878

79-
public: myclass(myclass const&) = delete;
79+
public: myclass(myclass const&) = delete; /* No 'that' constructor, suppress copy */
8080
public: auto operator=(myclass const&) -> void = delete;
8181
#line 58 "pure2-types-basics.cpp2"
8282
};

regression-tests/test-results/pure2-types-inheritance.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Human {
3232
public: virtual ~Human();
3333

3434
public: Human() = default;
35-
public: Human(Human const&) = delete;
35+
public: Human(Human const&) = delete; /* No 'that' constructor, suppress copy */
3636
public: auto operator=(Human const&) -> void = delete;
3737
#line 4 "pure2-types-inheritance.cpp2"
3838
};
@@ -44,7 +44,7 @@ namespace N {
4444

4545
public: virtual ~Machine();
4646

47-
public: Machine(Machine const&) = delete;
47+
public: Machine(Machine const&) = delete; /* No 'that' constructor, suppress copy */
4848
public: auto operator=(Machine const&) -> void = delete;
4949

5050
#line 10 "pure2-types-inheritance.cpp2"
@@ -72,7 +72,7 @@ class Cyborg: public Cyborg_name_as_base, public Human, public Cyborg_address_as
7272

7373
public: ~Cyborg();
7474

75-
public: Cyborg(Cyborg const&) = delete;
75+
public: Cyborg(Cyborg const&) = delete; /* No 'that' constructor, suppress copy */
7676
public: auto operator=(Cyborg const&) -> void = delete;
7777

7878
#line 36 "pure2-types-inheritance.cpp2"

regression-tests/test-results/pure2-types-order-independence-and-nesting.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class X {
5353
// X::exx member function description here
5454
public: auto exx(cpp2::in<int> count) const -> void;
5555

56-
public: X(X const&) = delete;
56+
public: X(X const&) = delete; /* No 'that' constructor, suppress copy */
5757
public: auto operator=(X const&) -> void = delete;
5858

5959

@@ -71,7 +71,7 @@ class Y {
7171

7272
public: auto why(cpp2::in<int> count) const -> void;
7373

74-
public: Y(Y const&) = delete;
74+
public: Y(Y const&) = delete; /* No 'that' constructor, suppress copy */
7575
public: auto operator=(Y const&) -> void = delete;
7676

7777
#line 53 "pure2-types-order-independence-and-nesting.cpp2"
@@ -85,14 +85,14 @@ template<typename T, typename U> class A {
8585
public: template<typename V, int J, typename W> static auto f(W const& w) -> void;
8686

8787
public: B() = default;
88-
public: B(B const&) = delete;
88+
public: B(B const&) = delete; /* No 'that' constructor, suppress copy */
8989
public: auto operator=(B const&) -> void = delete;
9090

9191
#line 61 "pure2-types-order-independence-and-nesting.cpp2"
9292
};
9393

9494
public: A() = default;
95-
public: A(A const&) = delete;
95+
public: A(A const&) = delete; /* No 'that' constructor, suppress copy */
9696
public: auto operator=(A const&) -> void = delete;
9797
#line 62 "pure2-types-order-independence-and-nesting.cpp2"
9898
};

regression-tests/test-results/pure2-types-ordering-via-meta-functions.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class my_integer {
3535

3636
public: [[nodiscard]] auto operator<=>(my_integer const& that) const -> std::strong_ordering = default;
3737

38-
public: my_integer(my_integer const&) = delete;
38+
public: my_integer(my_integer const&) = delete; /* No 'that' constructor, suppress copy */
3939
public: auto operator=(my_integer const&) -> void = delete;
4040
#line 5 "pure2-types-ordering-via-meta-functions.cpp2"
4141
};
@@ -48,7 +48,7 @@ class case_insensitive_string {
4848

4949
public: [[nodiscard]] auto operator<=>(case_insensitive_string const& that) const -> std::weak_ordering = default;
5050

51-
public: case_insensitive_string(case_insensitive_string const&) = delete;
51+
public: case_insensitive_string(case_insensitive_string const&) = delete; /* No 'that' constructor, suppress copy */
5252
public: auto operator=(case_insensitive_string const&) -> void = delete;
5353
#line 10 "pure2-types-ordering-via-meta-functions.cpp2"
5454
};
@@ -61,7 +61,7 @@ class person_in_family_tree {
6161

6262
public: [[nodiscard]] auto operator<=>(person_in_family_tree const& that) const -> std::partial_ordering = default;
6363

64-
public: person_in_family_tree(person_in_family_tree const&) = delete;
64+
public: person_in_family_tree(person_in_family_tree const&) = delete; /* No 'that' constructor, suppress copy */
6565
public: auto operator=(person_in_family_tree const&) -> void = delete;
6666
#line 15 "pure2-types-ordering-via-meta-functions.cpp2"
6767
};

regression-tests/test-results/version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
cppfront compiler v0.2.1 Build 8429:1224
2+
cppfront compiler v0.2.1 Build 8505:0902
33
Copyright(c) Herb Sutter All rights reserved
44

55
SPDX-License-Identifier: CC-BY-NC-ND-4.0

source/common.h

+1
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ class cmdline_processor
758758
ret += ":";
759759
ret += b.substr(0,2);
760760
ret += b.substr(3,2);
761+
for (auto& c : ret) { if (c == ' ') { c = '0'; } }
761762
return ret;
762763
};
763764

source/cppfront.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5097,7 +5097,7 @@ class cppfront
50975097
// If no 'that' constructor was defined, disable copy/move
50985098
// so that Cpp1 doesn't silently generate it anyway
50995099
if (!found_that_constructor) {
5100-
printer.print_extra( prefix + id + "(" + id + " const&) = delete;" );
5100+
printer.print_extra( prefix + id + "(" + id + " const&) = delete; /* No 'that' constructor, suppress copy */" );
51015101
printer.print_extra( prefix + "auto operator=(" + id + " const&) -> void = delete;" );
51025102
}
51035103

0 commit comments

Comments
 (0)