File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed
test/std/utilities/variant/variant.variant/variant.ctor Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -67,20 +67,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD
6767
6868#if __has_builtin(__builtin_invoke)
6969
70- template <class ... _Args>
71- using __invoke_result_t _LIBCPP_NODEBUG = decltype (__builtin_invoke(std::declval<_Args>()...));
72-
7370template <class , class ... _Args>
7471struct __invoke_result_impl {};
7572
7673template <class ... _Args>
77- struct __invoke_result_impl <__void_t <__invoke_result_t <_Args...> >, _Args...> {
78- using type _LIBCPP_NODEBUG = __invoke_result_t <_Args...> ;
74+ struct __invoke_result_impl <__void_t <decltype (__builtin_invoke(std::declval <_Args>() ...)) >, _Args...> {
75+ using type _LIBCPP_NODEBUG = decltype (__builtin_invoke(std::declval <_Args>() ...)) ;
7976};
8077
8178template <class ... _Args>
8279using __invoke_result _LIBCPP_NODEBUG = __invoke_result_impl<void , _Args...>;
8380
81+ template <class ... _Args>
82+ using __invoke_result_t _LIBCPP_NODEBUG = typename __invoke_result<_Args...>::type;
83+
8484template <class ... _Args>
8585_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __invoke_result_t <_Args...> __invoke (_Args&&... __args)
8686 _NOEXCEPT_(noexcept (__builtin_invoke(std::forward<_Args>(__args)...))) {
Original file line number Diff line number Diff line change @@ -173,12 +173,28 @@ void test_vector_bool() {
173173 assert (std::get<0 >(v) == true );
174174}
175175
176+ struct ConvertibleFromAny {
177+ template <class V >
178+ ConvertibleFromAny (V) {}
179+ };
180+
176181int main (int , char **) {
177182 test_T_ctor_basic ();
178183 test_T_ctor_noexcept ();
179184 test_T_ctor_sfinae ();
180185 test_no_narrowing_check_for_class_types ();
181186 test_construction_with_repeated_types ();
182187 test_vector_bool ();
188+
189+ { // Check that the constraints are evaluated lazily (see https://github.com/llvm/llvm-project/issues/151328)
190+ struct Matcher {
191+ Matcher () {}
192+ Matcher (std::variant<ConvertibleFromAny>) {}
193+ };
194+
195+ Matcher vec;
196+ [[maybe_unused]] Matcher m = std::move (vec);
197+ }
198+
183199 return 0 ;
184200}
You can’t perform that action at this time.
0 commit comments