diff --git a/stl/inc/xutility b/stl/inc/xutility index 235fd627b3..9e613dc1b7 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -360,7 +360,6 @@ _EXPORT_STD struct identity { }; #endif // _HAS_CXX20 -// TRANSITION, VSO-386225 template struct _Ref_fn { // pass function object by value as a reference template @@ -376,17 +375,14 @@ struct _Ref_fn { // pass function object by value as a reference }; template -_INLINE_VAR constexpr bool _Pass_functor_by_value_v = conjunction_v, - is_trivially_copy_constructible<_Fn>, is_trivially_destructible<_Fn>>; - -template , int> = 0> // TRANSITION, if constexpr -constexpr _Fn _Pass_fn(_Fn _Val) { // pass functor by value - return _Val; -} - -template , int> = 0> -constexpr _Ref_fn<_Fn> _Pass_fn(_Fn& _Val) { // pass functor by "reference" - return {_Val}; +constexpr auto _Pass_fn(_Fn& _Func) noexcept { + constexpr bool _Pass_by_value = conjunction_v, + is_trivially_copy_constructible<_Fn>, is_trivially_destructible<_Fn>>; + if constexpr (_Pass_by_value) { + return _Func; + } else { + return _Ref_fn<_Fn>{_Func}; // pass functor by "reference" + } } #if _HAS_CXX23