Skip to content

Commit 9907337

Browse files
committed
Add printing for (multiple, flag, values)
And add support for reflecting aliases (though I ended up not using it in the final version this commit)
1 parent c2e0778 commit 9907337

File tree

45 files changed

+380
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+380
-198
lines changed

include/cpp2util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,8 @@ class strict_value {
15991599
auto operator& ( strict_value const& that ) const -> strict_value requires BitwiseOps { return strict_value(t & that.t); }
16001600
auto operator^ ( strict_value const& that ) const -> strict_value requires BitwiseOps { return strict_value(t ^ that.t); }
16011601

1602+
auto has ( strict_value const& that ) const -> bool requires BitwiseOps { return t & that.t; }
1603+
16021604
auto set ( strict_value const& that ) -> void requires BitwiseOps { t |= that.t; }
16031605
auto clear ( strict_value const& that ) -> void requires BitwiseOps { t &= ~that.t; }
16041606
};

regression-tests/pure2-enum.cpp2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ main: () = {
7777
f |= file_attributes::obsolete;
7878
f2 |= file_attributes::current;
7979

80+
std::cout << "f is " << f << "\n";
81+
std::cout << "f2 is " << f2 << "\n";
8082
std::cout << "f as int is (f as int )$\n";
8183
std::cout << "f2 as int is (f2 as int )$\n";
8284
std::cout << "f == f2 is (f == f2 )$\n";

regression-tests/test-results/clang-12/pure2-enum.cpp.execution

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ f2 as int is 1
88
f is (f2) is 1
99
f2 is (f ) is 1
1010

11+
f is (cached, current, obsolete)
12+
f2 is (cached, current)
1113
f as int is 7
1214
f2 as int is 3
1315
f == f2 is 0
Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
1-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:36: error: expected ‘;’ at end of member declaration
1+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:16:36: error: expected ‘;’ at end of member declaration
2+
16 | public: explicit element(auto&& n)
3+
| ^
4+
| ;
25
In file included from pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:7:
3-
../../../include/cpp2util.h:1802:47: error: static assertion failed: GCC 11 or higher is required to support variables and type-scope functions that have a 'requires' clause. This includes a type-scope 'forward' parameter of non-wildcard type, such as 'func: (this, forward s: std::string)', which relies on being able to add a 'requires' clause - in that case, use 'forward s: _' instead if you need the result to compile with GCC 10.
4-
1802 | #define CPP2_REQUIRES_(...) static_assert(false, "GCC 11 or higher is required to support variables and type-scope functions that have a 'requires' clause. This includes a type-scope 'forward' parameter of non-wildcard type, such as 'func: (this, forward s: std::string)', which relies on being able to add a 'requires' clause - in that case, use 'forward s: _' instead if you need the result to compile with GCC 10.")
6+
../../../include/cpp2util.h:1804:47: error: static assertion failed: GCC 11 or higher is required to support variables and type-scope functions that have a 'requires' clause. This includes a type-scope 'forward' parameter of non-wildcard type, such as 'func: (this, forward s: std::string)', which relies on being able to add a 'requires' clause - in that case, use 'forward s: _' instead if you need the result to compile with GCC 10.
7+
1804 | #define CPP2_REQUIRES_(...) static_assert(false, "GCC 11 or higher is required to support variables and type-scope functions that have a 'requires' clause. This includes a type-scope 'forward' parameter of non-wildcard type, such as 'func: (this, forward s: std::string)', which relies on being able to add a 'requires' clause - in that case, use 'forward s: _' instead if you need the result to compile with GCC 10.")
58
| ^~~~~
6-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:4:1: note: in expansion of macro ‘CPP2_REQUIRES_’
9+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:17:1: note: in expansion of macro ‘CPP2_REQUIRES_’
10+
17 | CPP2_REQUIRES_ (std::is_same_v<CPP2_TYPEOF(n), std::string>)
11+
| ^~~~~~~~~~~~~~
712
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:46: error: expected ‘;’ at end of member declaration
813
In file included from pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:7:
9-
../../../include/cpp2util.h:1802:47: error: static assertion failed: GCC 11 or higher is required to support variables and type-scope functions that have a 'requires' clause. This includes a type-scope 'forward' parameter of non-wildcard type, such as 'func: (this, forward s: std::string)', which relies on being able to add a 'requires' clause - in that case, use 'forward s: _' instead if you need the result to compile with GCC 10.
10-
1802 | #define CPP2_REQUIRES_(...) static_assert(false, "GCC 11 or higher is required to support variables and type-scope functions that have a 'requires' clause. This includes a type-scope 'forward' parameter of non-wildcard type, such as 'func: (this, forward s: std::string)', which relies on being able to add a 'requires' clause - in that case, use 'forward s: _' instead if you need the result to compile with GCC 10.")
14+
../../../include/cpp2util.h:1804:47: error: static assertion failed: GCC 11 or higher is required to support variables and type-scope functions that have a 'requires' clause. This includes a type-scope 'forward' parameter of non-wildcard type, such as 'func: (this, forward s: std::string)', which relies on being able to add a 'requires' clause - in that case, use 'forward s: _' instead if you need the result to compile with GCC 10.
15+
1804 | #define CPP2_REQUIRES_(...) static_assert(false, "GCC 11 or higher is required to support variables and type-scope functions that have a 'requires' clause. This includes a type-scope 'forward' parameter of non-wildcard type, such as 'func: (this, forward s: std::string)', which relies on being able to add a 'requires' clause - in that case, use 'forward s: _' instead if you need the result to compile with GCC 10.")
1116
| ^~~~~
1217
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:4:1: note: in expansion of macro ‘CPP2_REQUIRES_’
1318
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:3: error: no declaration matches ‘element::element(auto:80&&) requires is_same_v<typename std::remove_cv<typename std::remove_reference<decltype(element::__ct ::n)>::type>::type, std::__cxx11::string>’
1419
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:5:11: note: candidates are: ‘element::element(const element&)’
15-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:20: note: ‘template<class auto:78> element::element(auto:78&&)’
16-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:1:7: note: ‘class element’ defined here
20+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:16:20: note: ‘template<class auto:78> element::element(auto:78&&)’
21+
16 | public: explicit element(auto&& n)
22+
| ^~~~~~~
23+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:14:7: note: ‘class element’ defined here
24+
14 | class element {
25+
| ^~~~~~~
1726
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:3: error: expected unqualified-id before ‘{’ token
1827
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:8: error: no declaration matches ‘element& element::operator=(auto:81&&) requires is_same_v<typename std::remove_cv<typename std::remove_reference<decltype(element::operator=::n)>::type>::type, std::__cxx11::string>’
1928
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:6:16: note: candidates are: ‘void element::operator=(const element&)’
2029
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:16: note: ‘template<class auto:79> element& element::operator=(auto:79&&)’
21-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:1:7: note: ‘class element’ defined here
30+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:14:7: note: ‘class element’ defined here
31+
14 | class element {
32+
| ^~~~~~~

regression-tests/test-results/gcc-10/pure2-enum.cpp.execution

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ f2 as int is 1
88
f is (f2) is 1
99
f2 is (f ) is 1
1010

11+
f is (cached, current, obsolete)
12+
f2 is (cached, current)
1113
f as int is 7
1214
f2 as int is 3
1315
f == f2 is 0
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
In file included from pure2-requires-clauses.cpp:7:
2-
../../../include/cpp2util.h:1802:33: error: expected unqualified-id before ‘static_assert’
3-
1802 | #define CPP2_REQUIRES_(...) static_assert(false, "GCC 11 or higher is required to support variables and type-scope functions that have a 'requires' clause. This includes a type-scope 'forward' parameter of non-wildcard type, such as 'func: (this, forward s: std::string)', which relies on being able to add a 'requires' clause - in that case, use 'forward s: _' instead if you need the result to compile with GCC 10.")
2+
../../../include/cpp2util.h:1804:33: error: expected unqualified-id before ‘static_assert’
3+
1804 | #define CPP2_REQUIRES_(...) static_assert(false, "GCC 11 or higher is required to support variables and type-scope functions that have a 'requires' clause. This includes a type-scope 'forward' parameter of non-wildcard type, such as 'func: (this, forward s: std::string)', which relies on being able to add a 'requires' clause - in that case, use 'forward s: _' instead if you need the result to compile with GCC 10.")
44
| ^~~~~~~~~~~~~
55
pure2-requires-clauses.cpp2:19:1: note: in expansion of macro ‘CPP2_REQUIRES_’

regression-tests/test-results/gcc-13/pure2-enum.cpp.execution

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ f2 as int is 1
88
f is (f2) is 1
99
f2 is (f ) is 1
1010

11+
f is (cached, current, obsolete)
12+
f2 is (cached, current)
1113
f as int is 7
1214
f2 as int is 3
1315
f == f2 is 0

regression-tests/test-results/mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99

1010
//=== Cpp2 type definitions and function declarations ===========================
1111

12-
#line 1 "mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp2"
1312
extern cpp2::i32 x;
1413
int main() { }
1514
// ugh
1615

1716
//=== Cpp2 function definitions =================================================
1817

19-
#line 1 "mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp2"
2018
cpp2::i32 x {0};
2119

regression-tests/test-results/msvc-2022/pure2-enum.cpp.execution

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ f2 as int is 1
88
f is (f2) is 1
99
f2 is (f ) is 1
1010

11+
f is (cached, current, obsolete)
12+
f2 is (cached, current)
1113
f as int is 7
1214
f2 as int is 3
1315
f == f2 is 0

regression-tests/test-results/pure2-bounds-safety-span.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
auto print_and_decorate(auto const& thing) -> void;
1919

2020

21-
#line 1 "pure2-bounds-safety-span.cpp2"
2221

2322
//=== Cpp2 function definitions =================================================
2423

regression-tests/test-results/pure2-bugfix-for-assign-expression-list.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010

1111
//=== Cpp2 type definitions and function declarations ===========================
1212

13-
#line 1 "pure2-bugfix-for-assign-expression-list.cpp2"
1413
auto main() -> int;
1514

1615

1716
//=== Cpp2 function definitions =================================================
1817

19-
#line 1 "pure2-bugfix-for-assign-expression-list.cpp2"
2018
auto main() -> int{
2119
using vec = std::vector<int>;
2220
vec v {0};

regression-tests/test-results/pure2-bugfix-for-discard-precedence.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66

77
#include "cpp2util.h"
88

9-
#line 1 "pure2-bugfix-for-discard-precedence.cpp2"
109
class quantity;
1110

1211

1312
//=== Cpp2 type definitions and function declarations ===========================
1413

15-
#line 1 "pure2-bugfix-for-discard-precedence.cpp2"
1614
class quantity {
1715
private: cpp2::i32 number;
1816
public: explicit quantity(cpp2::in<cpp2::i32> x);

regression-tests/test-results/pure2-bugfix-for-max-munch.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
//=== Cpp2 type definitions and function declarations ===========================
1212

13-
#line 1 "pure2-bugfix-for-max-munch.cpp2"
1413
template<typename T> auto static constexpr v = 0;
1514
auto main() -> int;
1615

regression-tests/test-results/pure2-bugfix-for-memberwise-base-assignment.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include "cpp2util.h"
88

9-
#line 1 "pure2-bugfix-for-memberwise-base-assignment.cpp2"
109
class Base;
1110

1211

@@ -16,7 +15,6 @@ class Derived;
1615

1716
//=== Cpp2 type definitions and function declarations ===========================
1817

19-
#line 1 "pure2-bugfix-for-memberwise-base-assignment.cpp2"
2018
class Base {
2119
public: explicit Base();
2220
public: Base([[maybe_unused]] Base const& that);

regression-tests/test-results/pure2-bugfix-for-name-lookup-and-value-decoration.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
struct vals__ret { int i; };
1414

15-
#line 1 "pure2-bugfix-for-name-lookup-and-value-decoration.cpp2"
1615
[[nodiscard]] auto vals() -> vals__ret;
1716

1817

@@ -22,7 +21,6 @@ struct vals__ret { int i; };
2221

2322
//=== Cpp2 function definitions =================================================
2423

25-
#line 1 "pure2-bugfix-for-name-lookup-and-value-decoration.cpp2"
2624
[[nodiscard]] auto vals() -> vals__ret{
2725
cpp2::deferred_init<int> i;
2826
#line 2 "pure2-bugfix-for-name-lookup-and-value-decoration.cpp2"

regression-tests/test-results/pure2-bugfix-for-non-local-initialization.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class t;
1313

1414
//=== Cpp2 type definitions and function declarations ===========================
1515

16-
#line 1 "pure2-bugfix-for-non-local-initialization.cpp2"
1716
using u = std::array<cpp2::i32,2>;
1817
class t: public std::integral_constant<u,u{17, 29}> {
1918

regression-tests/test-results/pure2-bugfix-for-optional-template-argument-list.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010

1111
//=== Cpp2 type definitions and function declarations ===========================
1212

13-
#line 1 "pure2-bugfix-for-optional-template-argument-list.cpp2"
1413
extern std::plus<> const plus;
1514
[[nodiscard]] auto main() -> int;
1615

1716

1817
//=== Cpp2 function definitions =================================================
1918

20-
#line 1 "pure2-bugfix-for-optional-template-argument-list.cpp2"
2119
std::plus<> const plus {};
2220
[[nodiscard]] auto main() -> int { return std::plus<>()(0, 0); }
2321

regression-tests/test-results/pure2-bugfix-for-requires-clause-in-forward-declaration.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66

77
#include "cpp2util.h"
88

9-
#line 1 "pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2"
109
class element;
1110

1211

1312
//=== Cpp2 type definitions and function declarations ===========================
1413

15-
#line 1 "pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2"
1614
class element {
1715
private: std::string name;
1816
public: explicit element(auto&& n)

regression-tests/test-results/pure2-bugfix-for-requires-clause-unbraced-function-initializer.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,14 @@
1010

1111
//=== Cpp2 type definitions and function declarations ===========================
1212

13-
#line 1 "pure2-bugfix-for-requires-clause-unbraced-function-initializer.cpp2"
1413
template<typename T> auto f() -> void
15-
CPP2_REQUIRES (std::regular<T>)
16-
#line 1 "pure2-bugfix-for-requires-clause-unbraced-function-initializer.cpp2"
17-
;
14+
CPP2_REQUIRES (std::regular<T>);
1815
auto main() -> int;
1916

2017

2118
//=== Cpp2 function definitions =================================================
2219

23-
#line 1 "pure2-bugfix-for-requires-clause-unbraced-function-initializer.cpp2"
2420
template<typename T> auto f() -> void
25-
requires (std::regular<T>)
26-
#line 1 "pure2-bugfix-for-requires-clause-unbraced-function-initializer.cpp2"
27-
{ g(T()); }
21+
requires (std::regular<T>) { g(T()); }
2822
auto main() -> int {}
2923

regression-tests/test-results/pure2-bugfix-for-template-argument.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010

1111
//=== Cpp2 type definitions and function declarations ===========================
1212

13-
#line 1 "pure2-bugfix-for-template-argument.cpp2"
1413
auto main() -> int;
1514

1615

1716
//=== Cpp2 function definitions =================================================
1817

19-
#line 1 "pure2-bugfix-for-template-argument.cpp2"
2018
auto main() -> int {
2119
std::cout
2220
<< std::boolalpha

regression-tests/test-results/pure2-bugfix-for-variable-template.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010

1111
//=== Cpp2 type definitions and function declarations ===========================
1212

13-
#line 1 "pure2-bugfix-for-variable-template.cpp2"
1413
template<auto V> extern int const v0;
1514
[[nodiscard]] auto main() -> int;
1615

1716

1817
//=== Cpp2 function definitions =================================================
1918

20-
#line 1 "pure2-bugfix-for-variable-template.cpp2"
2119
template<auto V> int const v0 {0};
2220
[[nodiscard]] auto main() -> int { return v0<0>; }
2321

regression-tests/test-results/pure2-chained-comparisons.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010

1111
//=== Cpp2 type definitions and function declarations ===========================
1212

13-
#line 1 "pure2-chained-comparisons.cpp2"
1413
[[nodiscard]] auto main() -> int;
1514

1615

1716
//=== Cpp2 function definitions =================================================
1817

19-
#line 1 "pure2-chained-comparisons.cpp2"
2018
[[nodiscard]] auto main() -> int{
2119
std::cout << std::boolalpha;
2220
auto i {0}; for( ; cpp2::cmp_less(i,3); ++i ) {

regression-tests/test-results/pure2-concept-definition.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
//=== Cpp2 type definitions and function declarations ===========================
1212

13-
#line 1 "pure2-concept-definition.cpp2"
1413
template<typename T> concept arithmetic = std::integral<T> || std::floating_point<T>;
1514
auto main() -> int;
1615

0 commit comments

Comments
 (0)