diff --git a/stl/inc/functional b/stl/inc/functional index a0c97586e40..8c0ce8f7944 100644 --- a/stl/inc/functional +++ b/stl/inc/functional @@ -1139,12 +1139,37 @@ public: _NON_MEMBER_CALL(_FUNCTION_POINTER_DEDUCTION_GUIDE, X1, X2, X3) #undef _FUNCTION_POINTER_DEDUCTION_GUIDE +template +struct _Deduce_from_call_operator : _Is_memfunptr<_Call_op>::_Guide_type {}; // N4958 [func.wrap.func.con]/16.1 + +#ifdef __cpp_static_call_operator +template +struct _Inspect_static_call_operator {}; + +#define _STATIC_CALL_OPERATOR_GUIDES(CALL_OPT, CV_OPT, REF_OPT, NOEXCEPT_OPT) \ + template \ + struct _Inspect_static_call_operator<_Ret(CALL_OPT*)(_Args...) NOEXCEPT_OPT> { \ + using type = _Ret(_Args...); \ + }; + +_NON_MEMBER_CALL(_STATIC_CALL_OPERATOR_GUIDES, , , ) +#ifdef __cpp_noexcept_function_type +_NON_MEMBER_CALL(_STATIC_CALL_OPERATOR_GUIDES, , , noexcept) +#endif // ^^^ defined(__cpp_noexcept_function_type) ^^^ + +#undef _STATIC_CALL_OPERATOR_GUIDES + +template +struct _Deduce_from_call_operator<_Fx, _Call_op, void_t().operator())>> + : _Inspect_static_call_operator<_Call_op> {}; // N4958 [func.wrap.func.con]/16.2 +#endif // ^^^ defined(__cpp_static_call_operator) ^^^ + template struct _Deduce_signature {}; // can't deduce signature when &_Fx::operator() is missing, inaccessible, or ambiguous template struct _Deduce_signature<_Fx, void_t> - : _Is_memfunptr::_Guide_type {}; // N4950 [func.wrap.func.con]/16.1 + : _Deduce_from_call_operator<_Fx, decltype(&_Fx::operator())> {}; template function(_Fx) -> function::type>; diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index e1df05934dd..d3a4feed390 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -128,6 +128,7 @@ // P0858R0 Constexpr Iterator Requirements // P1065R2 constexpr INVOKE // (the std::invoke function only; other components like bind and reference_wrapper are C++20 only) +// P1169R4 static operator() // P1518R2 Stop Overconstraining Allocators In Container Deduction Guides // P2162R2 Inheriting From variant // P2251R1 Require span And basic_string_view To Be Trivially Copyable diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index 5efce3bf46a..07200dcb4a6 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -327,9 +327,6 @@ std/utilities/tuple/tuple.tuple/tuple.cnstr/recursion_depth.pass.cpp SKIPPED std/depr/depr.c.headers/uchar_h.compile.pass.cpp FAIL std/strings/c.strings/cuchar.compile.pass.cpp FAIL -# P1169R4 static operator() -std/thread/futures/futures.task/futures.task.members/ctad.static.compile.pass.cpp FAIL - # P2255R2 "Type Traits To Detect References Binding To Temporaries" std/language.support/support.limits/support.limits.general/type_traits.version.compile.pass.cpp FAIL @@ -349,6 +346,10 @@ std/utilities/format/format.tuple/set_separator.pass.cpp FAIL # MSVC doesn't properly support [[no_unique_address]] std/algorithms/algorithms.results/no_unique_address.compile.pass.cpp SKIPPED +# P1169R4 static operator() +std/thread/futures/futures.task/futures.task.members/ctad.static.compile.pass.cpp:0 FAIL +std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/ctad.static.compile.pass.cpp:0 FAIL + # *** MISSING LWG ISSUE RESOLUTIONS *** # LWG-2192 "Validity and return type of std::abs(0u) is unclear" (resolution is missing in UCRT, DevCom-10331466) @@ -1065,7 +1066,6 @@ std/ranges/range.factories/range.single.view/cpo.pass.cpp FAIL std/thread/futures/futures.task/futures.task.members/ctor2.compile.pass.cpp FAIL std/utilities/format/format.functions/escaped_output.ascii.pass.cpp FAIL std/utilities/format/format.functions/locale-specific_form.pass.cpp FAIL -std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/ctad.static.compile.pass.cpp FAIL std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp:0 FAIL std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp:0 FAIL std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.array.unbounded.pass.cpp FAIL diff --git a/tests/std/test.lst b/tests/std/test.lst index 8c1a3602607..7b1396a5932 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -509,6 +509,7 @@ tests\P1135R6_latch tests\P1135R6_semaphore tests\P1147R1_printing_volatile_pointers tests\P1165R1_consistently_propagating_stateful_allocators +tests\P1169R4_static_call_operator tests\P1206R7_deque_append_range tests\P1206R7_deque_assign_range tests\P1206R7_deque_from_range diff --git a/tests/std/tests/P1169R4_static_call_operator/env.lst b/tests/std/tests/P1169R4_static_call_operator/env.lst new file mode 100644 index 00000000000..642f530ffad --- /dev/null +++ b/tests/std/tests/P1169R4_static_call_operator/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_latest_matrix.lst diff --git a/tests/std/tests/P1169R4_static_call_operator/test.compile.pass.cpp b/tests/std/tests/P1169R4_static_call_operator/test.compile.pass.cpp new file mode 100644 index 00000000000..47b6bcd6374 --- /dev/null +++ b/tests/std/tests/P1169R4_static_call_operator/test.compile.pass.cpp @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifdef __cpp_static_call_operator + +#include +#include +#include +using namespace std; + +struct F0 { + static char operator()(); +}; + +struct F1 { + static short operator()(float); +}; + +struct F2 { + static int operator()(double*, double&); +}; + +struct F3 { + static void operator()(const long&, long&&, const long&&); +}; + +struct Base { + static bool operator()(unsigned int); +}; + +struct Derived : Base {}; + +struct Nothrow { + static char16_t operator()(char32_t) noexcept; +}; + +template