|
| 1 | + |
| 2 | +#define CPP2_IMPORT_STD Yes |
| 3 | + |
| 4 | +//=== Cpp2 type declarations ==================================================== |
| 5 | + |
| 6 | + |
| 7 | +#include "cpp2util.h" |
| 8 | + |
| 9 | +#line 1 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 10 | + |
| 11 | +#line 30 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 12 | +template<typename T> class v; |
| 13 | + |
| 14 | + |
| 15 | +//=== Cpp2 type definitions and function declarations =========================== |
| 16 | + |
| 17 | +#line 1 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 18 | +// Dependent, non-deducible parameters are wrapped like non-dependent parameters. |
| 19 | +#line 2 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 20 | +template<typename T> auto init(cpp2::impl::out<std::integral_constant<cpp2::i32,T::value>> x) -> void; |
| 21 | +template<typename T> auto init(cpp2::impl::out<std::integral_constant<cpp2::i32,T::value>> x, [[maybe_unused]] T const& unnamed_param_2) -> void; |
| 22 | +template<typename T> [[nodiscard]] auto id(cpp2::impl::in<std::integral_constant<cpp2::i32,T::value>> x) -> auto; |
| 23 | +template<typename T> auto id(cpp2::impl::in<std::integral_constant<cpp2::i32,T::value>> x, T const& y) -> void; |
| 24 | + |
| 25 | +auto main() -> int; |
| 26 | + |
| 27 | +#line 30 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 28 | +template<typename T> class v { |
| 29 | + public: explicit v([[maybe_unused]] T const& unnamed_param_2); |
| 30 | +#line 31 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 31 | + public: auto operator=([[maybe_unused]] T const& unnamed_param_2) -> v& ; |
| 32 | + public: v(v const&) = delete; /* No 'that' constructor, suppress copy */ |
| 33 | + public: auto operator=(v const&) -> void = delete; |
| 34 | + |
| 35 | +#line 32 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 36 | +}; |
| 37 | + |
| 38 | + |
| 39 | +//=== Cpp2 function definitions ================================================= |
| 40 | + |
| 41 | +#line 1 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 42 | + |
| 43 | +#line 2 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 44 | +template<typename T> auto init(cpp2::impl::out<std::integral_constant<cpp2::i32,T::value>> x) -> void{x.construct(); } |
| 45 | +#line 3 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 46 | +template<typename T> auto init(cpp2::impl::out<std::integral_constant<cpp2::i32,T::value>> x, [[maybe_unused]] T const& unnamed_param_2) -> void{x.construct(); } |
| 47 | +#line 4 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 48 | +template<typename T> [[nodiscard]] auto id(cpp2::impl::in<std::integral_constant<cpp2::i32,T::value>> x) -> auto { return &x; } |
| 49 | +#line 5 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 50 | +template<typename T> auto id(cpp2::impl::in<std::integral_constant<cpp2::i32,T::value>> x, T const& y) -> void{if (cpp2::cpp2_default.is_active() && !(&x == &y) ) { cpp2::cpp2_default.report_violation(""); }} |
| 51 | + |
| 52 | +#line 7 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 53 | +auto main() -> int{ |
| 54 | + using zero = std::integral_constant<cpp2::i32,0>; |
| 55 | + |
| 56 | + cpp2::impl::deferred_init<zero> z; |
| 57 | + init<zero>(cpp2::impl::out(&z)); |
| 58 | + if (cpp2::cpp2_default.is_active() && !(id<zero>(z.value()) == &z.value()) ) { cpp2::cpp2_default.report_violation(""); } |
| 59 | + |
| 60 | + // Deducible parameters. |
| 61 | + static_cast<void>(v{ 0}); |
| 62 | + []<typename T>([[maybe_unused]] std::vector<T> const& unnamed_param_1) -> void{}(std::vector<cpp2::i32>{}); |
| 63 | + []<typename T>([[maybe_unused]] std::vector<std::vector<T>> const& unnamed_param_1) -> void{}(std::vector<std::vector<cpp2::i32>>{}); |
| 64 | + // _ = :<T, U> (x: std::pair<T, typename U::value_type>, y: U) = {}(:std::pair = (0, 0), z); // Blocked on #727. |
| 65 | + []<typename T, typename U>([[maybe_unused]] std::array<T,U::value> const& unnamed_param_1, [[maybe_unused]] U const& unnamed_param_2) -> void{}(std::array<cpp2::i32,0>{}, z.value()); |
| 66 | + init(cpp2::impl::out(&z.value()), z.value()); |
| 67 | + id(z.value(), cpp2::move(z.value())); |
| 68 | +{ |
| 69 | +auto f{[]<typename T>([[maybe_unused]] std::vector<std::type_identity_t<T>> const& unnamed_param_1) -> void{}}; |
| 70 | + |
| 71 | + // Test that these are emitted unwrapped in case they are deducible. |
| 72 | + |
| 73 | +#line 25 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 74 | + static_assert(!(std::is_invocable_v<decltype(cpp2::move(f)),std::vector<cpp2::i32>>), "`T` is non-deducible."); |
| 75 | +} |
| 76 | +{ |
| 77 | +auto f{[]<typename T>([[maybe_unused]] std::vector<std::vector<T>> const& unnamed_param_1) -> void{}}; |
| 78 | + |
| 79 | +#line 27 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 80 | + static_assert(std::is_invocable_v<decltype(cpp2::move(f)),std::vector<std::vector<cpp2::i32>>>, "`T` is deducible."); |
| 81 | +} |
| 82 | +#line 28 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 83 | +} |
| 84 | + |
| 85 | +#line 31 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 86 | + template <typename T> v<T>::v([[maybe_unused]] T const& unnamed_param_2){} |
| 87 | +#line 31 "pure2-bugfix-for-deducible-parameters.cpp2" |
| 88 | + template <typename T> auto v<T>::operator=([[maybe_unused]] T const& unnamed_param_2) -> v& { |
| 89 | + return *this; } |
| 90 | + |
0 commit comments