Skip to content

Commit b59f539

Browse files
committed
Change auto&& to decltype(auto) return types, closes #175
1 parent 3deb042 commit b59f539

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

include/cpp2util.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ constexpr auto contract_group::set_handler(handler h) -> handler {
308308

309309
// Null pointer deref checking
310310
//
311-
auto assert_not_null(auto&& p CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> auto&&
311+
auto assert_not_null(auto&& p CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto)
312312
{
313313
// NOTE: This "!= T{}" test may or may not work for STL iterators. The standard
314314
// doesn't guarantee that using == and != will reliably report whether an
@@ -319,15 +319,15 @@ auto assert_not_null(auto&& p CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> auto&&
319319

320320
// Subscript bounds checking
321321
//
322-
auto assert_in_bounds(auto&& x, auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> auto&&
322+
auto assert_in_bounds(auto&& x, auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto)
323323
requires (std::is_integral_v<CPP2_TYPEOF(arg)> &&
324324
requires { std::ssize(x); x[arg]; })
325325
{
326326
Bounds.expects(0 <= arg && arg < std::ssize(x), "out of bounds access attempt detected" CPP2_SOURCE_LOCATION_ARG);
327327
return std::forward<decltype(x)>(x) [ std::forward<decltype(arg)>(arg) ];
328328
}
329329

330-
auto assert_in_bounds(auto&& x, auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> auto&&
330+
auto assert_in_bounds(auto&& x, auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto)
331331
requires (!(std::is_integral_v<CPP2_TYPEOF(arg)> &&
332332
requires { std::ssize(x); x[arg]; }))
333333
{
@@ -652,7 +652,7 @@ auto as(auto const&) -> auto {
652652

653653
template< typename C, typename X >
654654
requires std::is_same_v<C, X>
655-
auto as( X const& x ) -> auto&& {
655+
auto as( X const& x ) -> decltype(auto) {
656656
return x;
657657
}
658658

@@ -769,7 +769,7 @@ constexpr auto is( std::variant<Ts...> const& x, auto const& value ) -> bool
769769
// as
770770
//
771771
template<size_t I, typename... Ts>
772-
constexpr auto operator_as( std::variant<Ts...> const& x ) -> auto&& {
772+
constexpr auto operator_as( std::variant<Ts...> const& x ) -> decltype(auto) {
773773
if constexpr (I < std::variant_size_v<std::variant<Ts...>>) {
774774
return std::get<I>( x );
775775
}
@@ -926,7 +926,7 @@ constexpr auto is( std::optional<T> const& x, auto const& value ) -> bool
926926
//
927927
template<typename T, typename X>
928928
requires std::is_same_v<X,std::optional<T>>
929-
constexpr auto as( X const& x ) -> auto&&
929+
constexpr auto as( X const& x ) -> decltype(auto)
930930
{ return x.value(); }
931931

932932

0 commit comments

Comments
 (0)