@@ -974,7 +974,7 @@ private:
974974};
975975
976976#if _HAS_CXX23
977- template <class _Rx, bool _Noexcept, class... _Types>
977+ template <class _Rx, class... _Types>
978978class _Function_base;
979979#endif // _HAS_CXX23
980980
@@ -1105,7 +1105,7 @@ protected:
11051105
11061106private:
11071107#if _HAS_CXX23
1108- friend _Function_base<_Ret, false, _Types...>;
1108+ friend _Function_base<_Ret, _Types...>;
11091109#endif // _HAS_CXX23
11101110
11111111 bool _Local() const noexcept { // test for locally stored copy of object
@@ -1574,7 +1574,7 @@ _NODISCARD void* _Function_new_large(_CTypes&&... _Args) {
15741574 return _Ptr;
15751575}
15761576
1577- template <class _Rx, bool _Noexcept, class... _Types>
1577+ template <class _Rx, class... _Types>
15781578class _Function_base {
15791579public:
15801580 using result_type = _Rx;
@@ -1626,12 +1626,12 @@ public:
16261626 void _Construct_with_old_fn(_Fn&& _Func) {
16271627 const auto _Old_fn_impl = _Func._Getimpl();
16281628 if (_Old_fn_impl == nullptr) {
1629- _Data._Impl = _Create_impl_ptr<_Impl_kind::_Old_fn_null, _Vt, void>();
1629+ _Data._Impl = _Create_impl_ptr<_Impl_kind::_Old_fn_null, _Vt, void, false >();
16301630 } else if (_Func._Local()) {
16311631#ifdef _WIN64
16321632 _STL_INTERNAL_STATIC_ASSERT(alignof(max_align_t) == alignof(void*));
16331633 // 64-bit target, can put small function into small move_only_function directly
1634- _Data._Impl = _Create_impl_ptr<_Impl_kind::_Old_fn_small, _Vt, void>();
1634+ _Data._Impl = _Create_impl_ptr<_Impl_kind::_Old_fn_small, _Vt, void, false >();
16351635 if constexpr (is_lvalue_reference_v<_Fn>) {
16361636 _Old_fn_impl->_Copy(_Data._Buf_ptr<void*>());
16371637 } else {
@@ -1664,12 +1664,12 @@ public:
16641664 _Func._Tidy();
16651665 }
16661666
1667- _Data._Impl = _Create_impl_ptr<_Impl_kind::_Old_fn_small_as_large, _Vt, void>();
1667+ _Data._Impl = _Create_impl_ptr<_Impl_kind::_Old_fn_small_as_large, _Vt, void, false >();
16681668 _Data._Set_large_fn_ptr(_Where);
16691669#endif // ^^^ 32-bit ^^^
16701670 } else {
16711671 // Just take ownership of the inner impl pointer
1672- _Data._Impl = _Create_impl_ptr<_Impl_kind::_Old_fn_large, _Vt, void>();
1672+ _Data._Impl = _Create_impl_ptr<_Impl_kind::_Old_fn_large, _Vt, void, false >();
16731673 if constexpr (is_lvalue_reference_v<_Fn>) {
16741674 _Data._Set_large_fn_ptr(_Old_fn_impl->_Copy(nullptr));
16751675 } else {
@@ -1679,9 +1679,9 @@ public:
16791679 }
16801680 }
16811681
1682- template <class _Vt, class _VtInvQuals, class... _CTypes>
1682+ template <class _Vt, class _VtInvQuals, bool _Noexcept, class... _CTypes>
16831683 void _Construct_with_fn(_CTypes&&... _Args) {
1684- _Data._Impl = _Create_impl_ptr<_Impl_kind::_Usual, _Vt, _VtInvQuals>();
1684+ _Data._Impl = _Create_impl_ptr<_Impl_kind::_Usual, _Vt, _VtInvQuals, _Noexcept >();
16851685 if constexpr (_Large_function_engaged<_Vt>) {
16861686 _Data._Set_large_fn_ptr(_STD _Function_new_large<_Vt>(_STD forward<_CTypes>(_Args)...));
16871687 } else {
@@ -1757,6 +1757,7 @@ public:
17571757 || sizeof(_Vt) > _Function_data::_Buf_size<_Vt>
17581758 || !is_nothrow_move_constructible_v<_Vt>;
17591759
1760+ template <bool _Noexcept>
17601761 _NODISCARD auto _Get_invoke() const noexcept {
17611762 if constexpr (_Noexcept) {
17621763 return reinterpret_cast<_Rx(__stdcall*)(void*, _Types&&...) noexcept>(_Get_impl(_Data)->_Invoke);
@@ -1776,7 +1777,7 @@ public:
17761777 return _Ret ? _Ret : &_Null_move_only_function;
17771778 }
17781779
1779- template <_Impl_kind _Kind, class _Vt, class _VtInvQuals>
1780+ template <_Impl_kind _Kind, class _Vt, class _VtInvQuals, bool _Noexcept >
17801781 _NODISCARD static constexpr _Impl_t _Create_impl() noexcept {
17811782 _Impl_t _Impl{};
17821783 if constexpr (_Kind != _Impl_kind::_Usual) {
@@ -1839,9 +1840,9 @@ public:
18391840 return _Impl;
18401841 }
18411842
1842- template <_Impl_kind _Kind, class _Vt, class _VtInvQuals>
1843+ template <_Impl_kind _Kind, class _Vt, class _VtInvQuals, bool _Noexcept >
18431844 _NODISCARD static const _Impl_t* _Create_impl_ptr() noexcept {
1844- static constexpr _Impl_t _Impl = _Create_impl<_Kind, _Vt, _VtInvQuals>();
1845+ static constexpr _Impl_t _Impl = _Create_impl<_Kind, _Vt, _VtInvQuals, _Noexcept >();
18451846 return &_Impl;
18461847 }
18471848};
@@ -1861,8 +1862,10 @@ class _Function_call {
18611862// Beginning of generated code - DO NOT EDIT manually!
18621863template <class _Rx, class... _Types>
18631864class _Function_call<_Rx(_Types...)> // Generated code - DO NOT EDIT manually!
1864- : public _Function_base<_Rx, false, _Types...> {
1865+ : public _Function_base<_Rx, _Types...> {
18651866public:
1867+ static constexpr bool _Noex = false;
1868+
18661869 template <class _Vt>
18671870 using _VtInvQuals = _Vt&;
18681871
@@ -1871,44 +1874,50 @@ public:
18711874 is_invocable_r_v<_Rx, _Vt, _Types...> && is_invocable_r_v<_Rx, _Vt&, _Types...>;
18721875
18731876 _Rx operator()(_Types... _Args) {
1874- return this->_Get_invoke()(&this->_Data, _STD forward<_Types>(_Args)...);
1877+ return this->template _Get_invoke<false> ()(&this->_Data, _STD forward<_Types>(_Args)...);
18751878 }
18761879};
18771880
18781881template <class _Rx, class... _Types>
18791882class _Function_call<_Rx(_Types...) &> // Generated code - DO NOT EDIT manually!
1880- : public _Function_base<_Rx, false, _Types...> {
1883+ : public _Function_base<_Rx, _Types...> {
18811884public:
1885+ static constexpr bool _Noex = false;
1886+
18821887 template <class _Vt>
18831888 using _VtInvQuals = _Vt&;
18841889
18851890 template <class _Vt>
18861891 static constexpr bool _Is_callable_from = is_invocable_r_v<_Rx, _Vt&, _Types...>;
18871892
18881893 _Rx operator()(_Types... _Args) & {
1889- return this->_Get_invoke()(&this->_Data, _STD forward<_Types>(_Args)...);
1894+ return this->template _Get_invoke<false> ()(&this->_Data, _STD forward<_Types>(_Args)...);
18901895 }
18911896};
18921897
18931898template <class _Rx, class... _Types>
18941899class _Function_call<_Rx(_Types...) &&> // Generated code - DO NOT EDIT manually!
1895- : public _Function_base<_Rx, false, _Types...> {
1900+ : public _Function_base<_Rx, _Types...> {
18961901public:
1902+ static constexpr bool _Noex = false;
1903+
18971904 template <class _Vt>
18981905 using _VtInvQuals = _Vt&&;
18991906
19001907 template <class _Vt>
19011908 static constexpr bool _Is_callable_from = is_invocable_r_v<_Rx, _Vt, _Types...>;
19021909
19031910 _Rx operator()(_Types... _Args) && {
1904- return this->_Get_invoke()(&this->_Data, _STD forward<_Types>(_Args)...);
1911+ return this->template _Get_invoke<false> ()(&this->_Data, _STD forward<_Types>(_Args)...);
19051912 }
19061913};
19071914
19081915template <class _Rx, class... _Types>
19091916class _Function_call<_Rx(_Types...) const> // Generated code - DO NOT EDIT manually!
1910- : public _Function_base<_Rx, false, _Types...> {
1917+ : public _Function_base<_Rx, _Types...> {
19111918public:
1919+ static constexpr bool _Noex = false;
1920+
19121921 template <class _Vt>
19131922 using _VtInvQuals = const _Vt&;
19141923
@@ -1917,45 +1926,54 @@ public:
19171926 is_invocable_r_v<_Rx, const _Vt, _Types...> && is_invocable_r_v<_Rx, const _Vt&, _Types...>;
19181927
19191928 _Rx operator()(_Types... _Args) const {
1920- return this->_Get_invoke()(const_cast<_Function_data*>(&this->_Data), _STD forward<_Types>(_Args)...);
1929+ return this->template _Get_invoke<false>()(
1930+ const_cast<_Function_data*>(&this->_Data), _STD forward<_Types>(_Args)...);
19211931 }
19221932};
19231933
19241934template <class _Rx, class... _Types>
19251935class _Function_call<_Rx(_Types...) const&> // Generated code - DO NOT EDIT manually!
1926- : public _Function_base<_Rx, false, _Types...> {
1936+ : public _Function_base<_Rx, _Types...> {
19271937public:
1938+ static constexpr bool _Noex = false;
1939+
19281940 template <class _Vt>
19291941 using _VtInvQuals = const _Vt&;
19301942
19311943 template <class _Vt>
19321944 static constexpr bool _Is_callable_from = is_invocable_r_v<_Rx, const _Vt&, _Types...>;
19331945
19341946 _Rx operator()(_Types... _Args) const& {
1935- return this->_Get_invoke()(const_cast<_Function_data*>(&this->_Data), _STD forward<_Types>(_Args)...);
1947+ return this->template _Get_invoke<false>()(
1948+ const_cast<_Function_data*>(&this->_Data), _STD forward<_Types>(_Args)...);
19361949 }
19371950};
19381951
19391952template <class _Rx, class... _Types>
19401953class _Function_call<_Rx(_Types...) const&&> // Generated code - DO NOT EDIT manually!
1941- : public _Function_base<_Rx, false, _Types...> {
1954+ : public _Function_base<_Rx, _Types...> {
19421955public:
1956+ static constexpr bool _Noex = false;
1957+
19431958 template <class _Vt>
19441959 using _VtInvQuals = const _Vt&&;
19451960
19461961 template <class _Vt>
19471962 static constexpr bool _Is_callable_from = is_invocable_r_v<_Rx, const _Vt, _Types...>;
19481963
19491964 _Rx operator()(_Types... _Args) const&& {
1950- return this->_Get_invoke()(const_cast<_Function_data*>(&this->_Data), _STD forward<_Types>(_Args)...);
1965+ return this->template _Get_invoke<false>()(
1966+ const_cast<_Function_data*>(&this->_Data), _STD forward<_Types>(_Args)...);
19511967 }
19521968};
19531969
19541970#ifdef __cpp_noexcept_function_type
19551971template <class _Rx, class... _Types>
19561972class _Function_call<_Rx(_Types...) noexcept> // Generated code - DO NOT EDIT manually!
1957- : public _Function_base<_Rx, true, _Types...> {
1973+ : public _Function_base<_Rx, _Types...> {
19581974public:
1975+ static constexpr bool _Noex = true;
1976+
19591977 template <class _Vt>
19601978 using _VtInvQuals = _Vt&;
19611979
@@ -1964,44 +1982,50 @@ public:
19641982 is_nothrow_invocable_r_v<_Rx, _Vt, _Types...> && is_nothrow_invocable_r_v<_Rx, _Vt&, _Types...>;
19651983
19661984 _Rx operator()(_Types... _Args) noexcept {
1967- return this->_Get_invoke()(&this->_Data, _STD forward<_Types>(_Args)...);
1985+ return this->template _Get_invoke<true> ()(&this->_Data, _STD forward<_Types>(_Args)...);
19681986 }
19691987};
19701988
19711989template <class _Rx, class... _Types>
19721990class _Function_call<_Rx(_Types...) & noexcept> // Generated code - DO NOT EDIT manually!
1973- : public _Function_base<_Rx, true, _Types...> {
1991+ : public _Function_base<_Rx, _Types...> {
19741992public:
1993+ static constexpr bool _Noex = true;
1994+
19751995 template <class _Vt>
19761996 using _VtInvQuals = _Vt&;
19771997
19781998 template <class _Vt>
19791999 static constexpr bool _Is_callable_from = is_nothrow_invocable_r_v<_Rx, _Vt&, _Types...>;
19802000
19812001 _Rx operator()(_Types... _Args) & noexcept {
1982- return this->_Get_invoke()(&this->_Data, _STD forward<_Types>(_Args)...);
2002+ return this->template _Get_invoke<true> ()(&this->_Data, _STD forward<_Types>(_Args)...);
19832003 }
19842004};
19852005
19862006template <class _Rx, class... _Types>
19872007class _Function_call<_Rx(_Types...) && noexcept> // Generated code - DO NOT EDIT manually!
1988- : public _Function_base<_Rx, true, _Types...> {
2008+ : public _Function_base<_Rx, _Types...> {
19892009public:
2010+ static constexpr bool _Noex = true;
2011+
19902012 template <class _Vt>
19912013 using _VtInvQuals = _Vt&&;
19922014
19932015 template <class _Vt>
19942016 static constexpr bool _Is_callable_from = is_nothrow_invocable_r_v<_Rx, _Vt, _Types...>;
19952017
19962018 _Rx operator()(_Types... _Args) && noexcept {
1997- return this->_Get_invoke()(&this->_Data, _STD forward<_Types>(_Args)...);
2019+ return this->template _Get_invoke<true> ()(&this->_Data, _STD forward<_Types>(_Args)...);
19982020 }
19992021};
20002022
20012023template <class _Rx, class... _Types>
20022024class _Function_call<_Rx(_Types...) const noexcept> // Generated code - DO NOT EDIT manually!
2003- : public _Function_base<_Rx, true, _Types...> {
2025+ : public _Function_base<_Rx, _Types...> {
20042026public:
2027+ static constexpr bool _Noex = true;
2028+
20052029 template <class _Vt>
20062030 using _VtInvQuals = const _Vt&;
20072031
@@ -2010,37 +2034,44 @@ public:
20102034 is_nothrow_invocable_r_v<_Rx, const _Vt, _Types...> && is_nothrow_invocable_r_v<_Rx, const _Vt&, _Types...>;
20112035
20122036 _Rx operator()(_Types... _Args) const noexcept {
2013- return this->_Get_invoke()(const_cast<_Function_data*>(&this->_Data), _STD forward<_Types>(_Args)...);
2037+ return this->template _Get_invoke<true>()(
2038+ const_cast<_Function_data*>(&this->_Data), _STD forward<_Types>(_Args)...);
20142039 }
20152040};
20162041
20172042template <class _Rx, class... _Types>
20182043class _Function_call<_Rx(_Types...) const & noexcept> // Generated code - DO NOT EDIT manually!
2019- : public _Function_base<_Rx, true, _Types...> {
2044+ : public _Function_base<_Rx, _Types...> {
20202045public:
2046+ static constexpr bool _Noex = true;
2047+
20212048 template <class _Vt>
20222049 using _VtInvQuals = const _Vt&;
20232050
20242051 template <class _Vt>
20252052 static constexpr bool _Is_callable_from = is_nothrow_invocable_r_v<_Rx, const _Vt&, _Types...>;
20262053
20272054 _Rx operator()(_Types... _Args) const& noexcept {
2028- return this->_Get_invoke()(const_cast<_Function_data*>(&this->_Data), _STD forward<_Types>(_Args)...);
2055+ return this->template _Get_invoke<true>()(
2056+ const_cast<_Function_data*>(&this->_Data), _STD forward<_Types>(_Args)...);
20292057 }
20302058};
20312059
20322060template <class _Rx, class... _Types>
20332061class _Function_call<_Rx(_Types...) const && noexcept> // Generated code - DO NOT EDIT manually!
2034- : public _Function_base<_Rx, true, _Types...> {
2062+ : public _Function_base<_Rx, _Types...> {
20352063public:
2064+ static constexpr bool _Noex = true;
2065+
20362066 template <class _Vt>
20372067 using _VtInvQuals = const _Vt&&;
20382068
20392069 template <class _Vt>
20402070 static constexpr bool _Is_callable_from = is_nothrow_invocable_r_v<_Rx, const _Vt, _Types...>;
20412071
20422072 _Rx operator()(_Types... _Args) const&& noexcept {
2043- return this->_Get_invoke()(const_cast<_Function_data*>(&this->_Data), _STD forward<_Types>(_Args)...);
2073+ return this->template _Get_invoke<true>()(
2074+ const_cast<_Function_data*>(&this->_Data), _STD forward<_Types>(_Args)...);
20442075 }
20452076};
20462077#endif // defined(__cpp_noexcept_function_type)
@@ -2113,7 +2144,7 @@ public:
21132144 _Callable._Reset_to_null();
21142145 } else {
21152146 using _VtInvQuals = _Call::template _VtInvQuals<_Vt>;
2116- this->template _Construct_with_fn<_Vt, _VtInvQuals>(_STD forward<_Fn>(_Callable));
2147+ this->template _Construct_with_fn<_Vt, _VtInvQuals, _Call::_Noex >(_STD forward<_Fn>(_Callable));
21172148 }
21182149 }
21192150 }
@@ -2125,7 +2156,7 @@ public:
21252156 static_assert(is_same_v<_Vt, _Fn>, "_Vt should be the same type as _Fn. (N4950 [func.wrap.move.ctor]/12)");
21262157
21272158 using _VtInvQuals = _Call::template _VtInvQuals<_Vt>;
2128- this->template _Construct_with_fn<_Vt, _VtInvQuals>(_STD forward<_CTypes>(_Args)...);
2159+ this->template _Construct_with_fn<_Vt, _VtInvQuals, _Call::_Noex >(_STD forward<_CTypes>(_Args)...);
21292160 }
21302161
21312162 template <class _Fn, class _Ux, class... _CTypes>
@@ -2135,7 +2166,7 @@ public:
21352166 static_assert(is_same_v<_Vt, _Fn>, "_Vt should be the same type as _Fn. (N4950 [func.wrap.move.ctor]/18)");
21362167
21372168 using _VtInvQuals = _Call::template _VtInvQuals<_Vt>;
2138- this->template _Construct_with_fn<_Vt, _VtInvQuals>(_Li, _STD forward<_CTypes>(_Args)...);
2169+ this->template _Construct_with_fn<_Vt, _VtInvQuals, _Call::_Noex >(_Li, _STD forward<_CTypes>(_Args)...);
21392170 }
21402171
21412172 ~move_only_function() {
0 commit comments