| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0b380c5 commit f2f70ed
15 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -260,6 +260,7 @@ | |||
| 260 | 260 | ||
| 261 | 261 | #define CPP2_TYPEOF(x) std::remove_cvref_t<decltype(x)> | |
| 262 | 262 | #define CPP2_FORWARD(x) std::forward<decltype(x)>(x) | |
| 263 | + #define CPP2_PACK_EMPTY(x) (sizeof...(x) == 0) | ||
| 263 | 264 | #define CPP2_CONTINUE_BREAK(NAME) goto CONTINUE_##NAME; CONTINUE_##NAME: continue; goto BREAK_##NAME; BREAK_##NAME: break; | |
| 264 | 265 | // these redundant goto's to avoid 'unused label' warnings | |
| 265 | 266 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,7 +49,7 @@ outer: @print type = { | |||
| 49 | 49 | return :() -> std::string = (s + m[0])$; (); | |
| 50 | 50 | } | |
| 51 | 51 | ||
| 52 | - values: <T> (this, t: T) throws -> (offset: int, name: std::string) = { | ||
| 52 | + values: <T> (this, _: T) throws -> (offset: int, name: std::string) = { | ||
| 53 | 53 | offset = 53; | |
| 54 | 54 | name = "plugh"; | |
| 55 | 55 | } | |
@@ -60,7 +60,7 @@ outer: @print type = { | |||
| 60 | 60 | ||
| 61 | 61 | operator=: (implicit out this, _: int) = { } | |
| 62 | 62 | ||
| 63 | - variadic: (x...: int) = { } | ||
| 63 | + variadic: (x...: int) = { (std::cout << ... << x); } | ||
| 64 | 64 | } | |
| 65 | 65 | ||
| 66 | 66 | test: () = { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ x: <Ts...: type> type = { | |||
| 4 | 4 | tup: std::tuple<Ts...> = (); | |
| 5 | 5 | } | |
| 6 | 6 | ||
| 7 | - print: <Args...: type> (inout out: std::ostream, args...: Args) = { | ||
| 7 | + left_fold_print: <Args...: type> (inout out: std::ostream, args...: Args) = { | ||
| 8 | 8 | // Binary left fold expression | |
| 9 | 9 | (out << ... << args); | |
| 10 | 10 | } | |
@@ -25,7 +25,7 @@ main: () | |||
| 25 | 25 | std::cout << make_string("plugh", :u8=3) << "\n"; | |
| 26 | 26 | std::cout << make<std::string>("abracadabra", :u8=3) << "\n"; | |
| 27 | 27 | ||
| 28 | - print( std::cout, 3.14, "word", -1500 ); | ||
| 28 | + left_fold_print( std::cout, 3.14, "word", -1500 ); | ||
| 29 | 29 | ||
| 30 | 30 | std::cout << "\nfirst all() returned (all(true, true, true, false))$"; | |
| 31 | 31 | std::cout << "\nsecond all() returned " << all(true, true, true, true) as std::string; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +0,0 @@ | |||
| 1 | - pure2-print.cpp2:52:80: warning: unused parameter 't' [-Wunused-parameter] | ||
| 2 | - template<typename T> [[nodiscard]] auto outer::mytype::values(T const& t) const& -> values_ret{ | ||
| 3 | - ^ | ||
| 4 | - pure2-print.cpp2:63:53: warning: unused parameter 'x' [-Wunused-parameter] | ||
| 5 | - auto outer::mytype::variadic(auto const& ...x) -> void{} | ||
| 6 | - ^ | ||
| 7 | - 2 warnings generated. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,17 @@ | |||
| 1 | 1 | In file included from pure2-print.cpp:7: | |
| 2 | 2 | ../../../include/cpp2util.h:10005:33: error: expected unqualified-id before ‘static_assert’ | |
| 3 | 3 | pure2-print.cpp2:7:1: note: in expansion of macro ‘CPP2_REQUIRES_’ | |
| 4 | + pure2-print.cpp2:63:59: error: expected ‘;’ at end of member declaration | ||
| 5 | + In file included from pure2-print.cpp:7: | ||
| 6 | + ../../../include/cpp2util.h:10005: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 | + pure2-print.cpp2:64:1: note: in expansion of macro ‘CPP2_REQUIRES_’ | ||
| 4 | 8 | ../../../include/cpp2util.h:10005:33: error: expected initializer before ‘static_assert’ | |
| 5 | 9 | pure2-print.cpp2:89:1: note: in expansion of macro ‘CPP2_REQUIRES_’ | |
| 6 | 10 | pure2-print.cpp2:6:29: error: ‘constexpr const T outer::object_alias’ is not a static data member of ‘class outer’ | |
| 7 | 11 | pure2-print.cpp2:6:36: error: template definition of non-template ‘constexpr const T outer::object_alias’ | |
| 12 | + pure2-print.cpp2:63:14: error: no declaration matches ‘void outer::mytype::variadic(const auto:89& ...) requires (is_convertible_v<typename std::remove_cv<typename std::remove_reference<decltype(outer::mytype::variadic::x)>::type>::type, int> && ...)’ | ||
| 13 | + pure2-print.cpp2:63:29: note: candidate is: ‘template<class ... auto:80> static void outer::mytype::variadic(const auto:80& ...)’ | ||
| 14 | + pure2-print.cpp2:8:19: note: ‘class outer::mytype’ defined here | ||
| 8 | 15 | pure2-print.cpp2:88:37: error: no declaration matches ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::cmp_greater_eq(sizeof (Args)..., 0)’ | |
| 9 | 16 | pure2-print.cpp2:88:37: note: no functions named ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::cmp_greater_eq(sizeof (Args)..., 0)’ | |
| 10 | 17 | pure2-print.cpp2:4:7: note: ‘class outer’ defined here | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,9 +24,9 @@ class file_attributes; | |||
| 24 | 24 | ||
| 25 | 25 | #line 2 "pure2-enum.cpp2" | |
| 26 | 26 | class skat_game { | |
| 27 | - private: cpp2::i8 _value; private: constexpr skat_game(cpp2::in<cpp2::i64> val); | ||
| 27 | + private: cpp2::i8 _value; private: constexpr skat_game(cpp2::in<cpp2::i64> _val); | ||
| 28 | 28 | ||
| 29 | - private: constexpr auto operator=(cpp2::in<cpp2::i64> val) -> skat_game& ; | ||
| 29 | + private: constexpr auto operator=(cpp2::in<cpp2::i64> _val) -> skat_game& ; | ||
| 30 | 30 | public: [[nodiscard]] constexpr auto get_raw_value() const& -> cpp2::i8; | |
| 31 | 31 | public: constexpr skat_game(skat_game const& that); | |
| 32 | 32 | public: constexpr auto operator=(skat_game const& that) -> skat_game& ; | |
@@ -54,9 +54,9 @@ class janus { | |||
| 54 | 54 | #line 15 "pure2-enum.cpp2" | |
| 55 | 55 | public: constexpr auto flip() & -> void; | |
| 56 | 56 | ||
| 57 | - private: cpp2::i8 _value; private: constexpr janus(cpp2::in<cpp2::i64> val); | ||
| 57 | + private: cpp2::i8 _value; private: constexpr janus(cpp2::in<cpp2::i64> _val); | ||
| 58 | 58 | ||
| 59 | - private: constexpr auto operator=(cpp2::in<cpp2::i64> val) -> janus& ; | ||
| 59 | + private: constexpr auto operator=(cpp2::in<cpp2::i64> _val) -> janus& ; | ||
| 60 | 60 | public: [[nodiscard]] constexpr auto get_raw_value() const& -> cpp2::i8; | |
| 61 | 61 | public: constexpr janus(janus const& that); | |
| 62 | 62 | public: constexpr auto operator=(janus const& that) -> janus& ; | |
@@ -71,9 +71,9 @@ public: [[nodiscard]] auto to_string() const& -> std::string; | |||
| 71 | 71 | }; | |
| 72 | 72 | ||
| 73 | 73 | class file_attributes { | |
| 74 | - private: cpp2::u8 _value; private: constexpr file_attributes(cpp2::in<cpp2::i64> val); | ||
| 74 | + private: cpp2::u8 _value; private: constexpr file_attributes(cpp2::in<cpp2::i64> _val); | ||
| 75 | 75 | ||
| 76 | - private: constexpr auto operator=(cpp2::in<cpp2::i64> val) -> file_attributes& ; | ||
| 76 | + private: constexpr auto operator=(cpp2::in<cpp2::i64> _val) -> file_attributes& ; | ||
| 77 | 77 | public: [[nodiscard]] constexpr auto get_raw_value() const& -> cpp2::u8; | |
| 78 | 78 | public: constexpr file_attributes(file_attributes const& that); | |
| 79 | 79 | public: constexpr auto operator=(file_attributes const& that) -> file_attributes& ; | |
@@ -111,11 +111,11 @@ auto main() -> int; | |||
| 111 | 111 | ||
| 112 | 112 | ||
| 113 | 113 | ||
| 114 | - constexpr skat_game::skat_game(cpp2::in<cpp2::i64> val) | ||
| 115 | - : _value{ cpp2::unsafe_narrow<cpp2::i8>(val) } { } | ||
| 116 | - constexpr auto skat_game::operator=(cpp2::in<cpp2::i64> val) -> skat_game& { | ||
| 117 | - _value = cpp2::unsafe_narrow<cpp2::i8>(val); | ||
| 118 | - return *this; } | ||
| 114 | + constexpr skat_game::skat_game(cpp2::in<cpp2::i64> _val) | ||
| 115 | + : _value{ cpp2::unsafe_narrow<cpp2::i8>(_val) } { } | ||
| 116 | + constexpr auto skat_game::operator=(cpp2::in<cpp2::i64> _val) -> skat_game& { | ||
| 117 | + _value = cpp2::unsafe_narrow<cpp2::i8>(_val); | ||
| 118 | + return *this; } | ||
| 119 | 119 | [[nodiscard]] constexpr auto skat_game::get_raw_value() const& -> cpp2::i8 { return _value; } | |
| 120 | 120 | constexpr skat_game::skat_game(skat_game const& that) | |
| 121 | 121 | : _value{ that._value }{} | |
@@ -155,12 +155,12 @@ inline CPP2_CONSTEXPR skat_game skat_game::null = 23; | |||
| 155 | 155 | } | |
| 156 | 156 | ||
| 157 | 157 | ||
| 158 | - constexpr janus::janus(cpp2::in<cpp2::i64> val) | ||
| 159 | - : _value{ cpp2::unsafe_narrow<cpp2::i8>(val) } { } | ||
| 158 | + constexpr janus::janus(cpp2::in<cpp2::i64> _val) | ||
| 159 | + : _value{ cpp2::unsafe_narrow<cpp2::i8>(_val) } { } | ||
| 160 | 160 | ||
| 161 | - constexpr auto janus::operator=(cpp2::in<cpp2::i64> val) -> janus& { | ||
| 162 | - _value = cpp2::unsafe_narrow<cpp2::i8>(val); | ||
| 163 | - return *this; } | ||
| 161 | + constexpr auto janus::operator=(cpp2::in<cpp2::i64> _val) -> janus& { | ||
| 162 | + _value = cpp2::unsafe_narrow<cpp2::i8>(_val); | ||
| 163 | + return *this; } | ||
| 164 | 164 | [[nodiscard]] constexpr auto janus::get_raw_value() const& -> cpp2::i8 { return _value; } | |
| 165 | 165 | constexpr janus::janus(janus const& that) | |
| 166 | 166 | : _value{ that._value }{} | |
@@ -182,11 +182,11 @@ inline CPP2_CONSTEXPR janus janus::future = 1; | |||
| 182 | 182 | return "invalid janus value"; | |
| 183 | 183 | } | |
| 184 | 184 | ||
| 185 | - constexpr file_attributes::file_attributes(cpp2::in<cpp2::i64> val) | ||
| 186 | - : _value{ cpp2::unsafe_narrow<cpp2::u8>(val) } { } | ||
| 187 | - constexpr auto file_attributes::operator=(cpp2::in<cpp2::i64> val) -> file_attributes& { | ||
| 188 | - _value = cpp2::unsafe_narrow<cpp2::u8>(val); | ||
| 189 | - return *this; } | ||
| 185 | + constexpr file_attributes::file_attributes(cpp2::in<cpp2::i64> _val) | ||
| 186 | + : _value{ cpp2::unsafe_narrow<cpp2::u8>(_val) } { } | ||
| 187 | + constexpr auto file_attributes::operator=(cpp2::in<cpp2::i64> _val) -> file_attributes& { | ||
| 188 | + _value = cpp2::unsafe_narrow<cpp2::u8>(_val); | ||
| 189 | + return *this; } | ||
| 190 | 190 | [[nodiscard]] constexpr auto file_attributes::get_raw_value() const& -> cpp2::u8 { return _value; } | |
| 191 | 191 | constexpr file_attributes::file_attributes(file_attributes const& that) | |
| 192 | 192 | : _value{ that._value }{} | |
@@ -219,15 +219,15 @@ inline CPP2_CONSTEXPR file_attributes file_attributes::none = 0; | |||
| 219 | 219 | ||
| 220 | 220 | [[nodiscard]] auto file_attributes::to_string() const& -> std::string{ | |
| 221 | 221 | ||
| 222 | - std::string ret {"("}; | ||
| 222 | + std::string _ret {"("}; | ||
| 223 | 223 | ||
| 224 | - std::string comma {}; | ||
| 224 | + std::string _comma {}; | ||
| 225 | 225 | if ((*this) == none) {return "(none)"; } | |
| 226 | - if (((*this) & cached) == cached) {ret += comma + "cached";comma = ", ";} | ||
| 227 | - if (((*this) & current) == current) {ret += comma + "current";comma = ", ";} | ||
| 228 | - if (((*this) & obsolete) == obsolete) {ret += comma + "obsolete";comma = ", ";} | ||
| 229 | - if (((*this) & cached_and_current) == cached_and_current) {ret += comma + "cached_and_current";comma = ", ";} | ||
| 230 | - return ret + ")"; | ||
| 226 | + if (((*this) & cached) == cached) {_ret += _comma + "cached";_comma = ", ";} | ||
| 227 | + if (((*this) & current) == current) {_ret += _comma + "current";_comma = ", ";} | ||
| 228 | + if (((*this) & obsolete) == obsolete) {_ret += _comma + "obsolete";_comma = ", ";} | ||
| 229 | + if (((*this) & cached_and_current) == cached_and_current) {_ret += _comma + "cached_and_current";_comma = ", ";} | ||
| 230 | + return _ret + ")"; | ||
| 231 | 231 | } | |
| 232 | 232 | #line 28 "pure2-enum.cpp2" | |
| 233 | 233 | auto main() -> int{ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,7 +38,7 @@ CPP2_REQUIRES_ (true) | |||
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | 40 | #line 52 "pure2-print.cpp2" | |
| 41 | - public: template<typename T> [[nodiscard]] auto values(T const& t) const& -> values_ret; | ||
| 41 | + public: template<typename T> [[nodiscard]] auto values([[maybe_unused]] T const& param2) const& -> values_ret; | ||
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | 44 | #line 57 "pure2-print.cpp2" | |
@@ -48,7 +48,10 @@ CPP2_REQUIRES_ (true) | |||
| 48 | 48 | ||
| 49 | 49 | public: mytype([[maybe_unused]] cpp2::in<int> param2); | |
| 50 | 50 | ||
| 51 | - public: static auto variadic(auto const& ...x) -> void; | ||
| 51 | + public: static auto variadic(auto const& ...x) -> void | ||
| 52 | + CPP2_REQUIRES_ ((std::is_convertible_v<CPP2_TYPEOF(x), int> && ...)) | ||
| 53 | + #line 63 "pure2-print.cpp2" | ||
| 54 | + ; | ||
| 52 | 55 | }; | |
| 53 | 56 | ||
| 54 | 57 | public: static auto test() -> void; | |
@@ -142,7 +145,7 @@ requires (true) | |||
| 142 | 145 | return [_0 = (s + cpp2::assert_in_bounds(m, 0))]() -> std::string { return _0; }(); | |
| 143 | 146 | } | |
| 144 | 147 | ||
| 145 | - template<typename T> [[nodiscard]] auto outer::mytype::values(T const& t) const& -> values_ret{ | ||
| 148 | + template<typename T> [[nodiscard]] auto outer::mytype::values([[maybe_unused]] T const& param2) const& -> values_ret{ | ||
| 146 | 149 | cpp2::deferred_init<int> offset; | |
| 147 | 150 | cpp2::deferred_init<std::string> name; | |
| 148 | 151 | #line 53 "pure2-print.cpp2" | |
@@ -156,7 +159,10 @@ requires (true) | |||
| 156 | 159 | ||
| 157 | 160 | outer::mytype::mytype([[maybe_unused]] cpp2::in<int> param2){} | |
| 158 | 161 | ||
| 159 | - auto outer::mytype::variadic(auto const& ...x) -> void{} | ||
| 162 | + auto outer::mytype::variadic(auto const& ...x) -> void | ||
| 163 | + requires ((std::is_convertible_v<CPP2_TYPEOF(x), int> && ...)) | ||
| 164 | + #line 63 "pure2-print.cpp2" | ||
| 165 | + {(std::cout << ... << x); } | ||
| 160 | 166 | ||
| 161 | 167 | #line 66 "pure2-print.cpp2" | |
| 162 | 168 | auto outer::test() -> void{ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -80,7 +80,7 @@ outer: type = | |||
| 80 | 80 | ||
| 81 | 81 | values: <T: type>( | |
| 82 | 82 | in this, | |
| 83 | - in t: T | ||
| 83 | + in _: T | ||
| 84 | 84 | ) throws -> ( | |
| 85 | 85 | out offset: int, | |
| 86 | 86 | out name: std::string | |
@@ -111,6 +111,7 @@ outer: type = | |||
| 111 | 111 | ||
| 112 | 112 | variadic:(in x...: int) = | |
| 113 | 113 | { | |
| 114 | + (std::cout << ... << x); | ||
| 114 | 115 | } | |
| 115 | 116 | } | |
| 116 | 117 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments