Skip to content

Commit a98226c

Browse files
move_only_function: eliminate the repeated part in call specializations (#5810)
Co-authored-by: Stephan T. Lavavej <[email protected]>
1 parent 8196ecf commit a98226c

File tree

2 files changed

+3
-27
lines changed

2 files changed

+3
-27
lines changed

stl/inc/functional

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,8 @@ _NODISCARD void* _Function_new_large(_CTypes&&... _Args) {
15351535
template <class _Rx, bool _Noexcept, class... _Types>
15361536
class _Move_only_function_base {
15371537
public:
1538+
using result_type = _Rx;
1539+
15381540
struct _Impl_t { // A per-callable-type structure acting as a virtual function table.
15391541
// Using vtable emulations gives more flexibility for optimizations and reduces the amount of RTTI data.
15401542
// (The RTTI savings may be significant as with lambdas and binds there may be many distinct callable types.
@@ -1719,8 +1721,6 @@ class _Move_only_function_call {
17191721
template <class _Rx, class... _Types>
17201722
class _Move_only_function_call<_Rx(_Types...)> : public _Move_only_function_base<_Rx, false, _Types...> {
17211723
public:
1722-
using result_type = _Rx;
1723-
17241724
template <class _Vt>
17251725
using _VtInvQuals = _Vt&;
17261726

@@ -1736,8 +1736,6 @@ public:
17361736
template <class _Rx, class... _Types>
17371737
class _Move_only_function_call<_Rx(_Types...) &> : public _Move_only_function_base<_Rx, false, _Types...> {
17381738
public:
1739-
using result_type = _Rx;
1740-
17411739
template <class _Vt>
17421740
using _VtInvQuals = _Vt&;
17431741

@@ -1752,8 +1750,6 @@ public:
17521750
template <class _Rx, class... _Types>
17531751
class _Move_only_function_call<_Rx(_Types...) &&> : public _Move_only_function_base<_Rx, false, _Types...> {
17541752
public:
1755-
using result_type = _Rx;
1756-
17571753
template <class _Vt>
17581754
using _VtInvQuals = _Vt&&;
17591755

@@ -1768,8 +1764,6 @@ public:
17681764
template <class _Rx, class... _Types>
17691765
class _Move_only_function_call<_Rx(_Types...) const> : public _Move_only_function_base<_Rx, false, _Types...> {
17701766
public:
1771-
using result_type = _Rx;
1772-
17731767
template <class _Vt>
17741768
using _VtInvQuals = const _Vt&;
17751769

@@ -1785,8 +1779,6 @@ public:
17851779
template <class _Rx, class... _Types>
17861780
class _Move_only_function_call<_Rx(_Types...) const&> : public _Move_only_function_base<_Rx, false, _Types...> {
17871781
public:
1788-
using result_type = _Rx;
1789-
17901782
template <class _Vt>
17911783
using _VtInvQuals = const _Vt&;
17921784

@@ -1801,8 +1793,6 @@ public:
18011793
template <class _Rx, class... _Types>
18021794
class _Move_only_function_call<_Rx(_Types...) const&&> : public _Move_only_function_base<_Rx, false, _Types...> {
18031795
public:
1804-
using result_type = _Rx;
1805-
18061796
template <class _Vt>
18071797
using _VtInvQuals = const _Vt&&;
18081798

@@ -1818,8 +1808,6 @@ public:
18181808
template <class _Rx, class... _Types>
18191809
class _Move_only_function_call<_Rx(_Types...) noexcept> : public _Move_only_function_base<_Rx, true, _Types...> {
18201810
public:
1821-
using result_type = _Rx;
1822-
18231811
template <class _Vt>
18241812
using _VtInvQuals = _Vt&;
18251813

@@ -1835,8 +1823,6 @@ public:
18351823
template <class _Rx, class... _Types>
18361824
class _Move_only_function_call<_Rx(_Types...) & noexcept> : public _Move_only_function_base<_Rx, true, _Types...> {
18371825
public:
1838-
using result_type = _Rx;
1839-
18401826
template <class _Vt>
18411827
using _VtInvQuals = _Vt&;
18421828

@@ -1851,8 +1837,6 @@ public:
18511837
template <class _Rx, class... _Types>
18521838
class _Move_only_function_call<_Rx(_Types...) && noexcept> : public _Move_only_function_base<_Rx, true, _Types...> {
18531839
public:
1854-
using result_type = _Rx;
1855-
18561840
template <class _Vt>
18571841
using _VtInvQuals = _Vt&&;
18581842

@@ -1867,8 +1851,6 @@ public:
18671851
template <class _Rx, class... _Types>
18681852
class _Move_only_function_call<_Rx(_Types...) const noexcept> : public _Move_only_function_base<_Rx, true, _Types...> {
18691853
public:
1870-
using result_type = _Rx;
1871-
18721854
template <class _Vt>
18731855
using _VtInvQuals = const _Vt&;
18741856

@@ -1885,8 +1867,6 @@ template <class _Rx, class... _Types>
18851867
class _Move_only_function_call<_Rx(_Types...) const & noexcept>
18861868
: public _Move_only_function_base<_Rx, true, _Types...> {
18871869
public:
1888-
using result_type = _Rx;
1889-
18901870
template <class _Vt>
18911871
using _VtInvQuals = const _Vt&;
18921872

@@ -1902,8 +1882,6 @@ template <class _Rx, class... _Types>
19021882
class _Move_only_function_call<_Rx(_Types...) const && noexcept>
19031883
: public _Move_only_function_base<_Rx, true, _Types...> {
19041884
public:
1905-
using result_type = _Rx;
1906-
19071885
template <class _Vt>
19081886
using _VtInvQuals = const _Vt&&;
19091887

tools/scripts/move_only_function_specializations.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ def specialization(cv: str, ref: str, ref_inv: str, noex: str, noex_val: str, ca
88
class _Move_only_function_call<_Rx(_Types...) {cv} {ref} {noex}>
99
: public _Move_only_function_base<_Rx, {noex_val}, _Types...> {{
1010
public:
11-
using result_type = _Rx;
12-
1311
template <class _Vt>
1412
using _VtInvQuals = {cv} _Vt {ref_inv};
1513
@@ -39,4 +37,4 @@ def cvref_permutations(noex: str, noex_val: str, trait: str) -> str:
3937
print(cvref_permutations("", "false", "is_invocable_r_v") + "\n" \
4038
+ "#ifdef __cpp_noexcept_function_type" + "\n" \
4139
+ cvref_permutations("noexcept", "true", "is_nothrow_invocable_r_v") \
42-
+ "#endif // __cpp_noexcept_function_type")
40+
+ "#endif // defined(__cpp_noexcept_function_type)")

0 commit comments

Comments
 (0)