mirror of
https://github.com/ETLCPP/etl.git
synced 2026-07-30 16:26:17 +08:00
Clean up the use of type traits by using C++11 forms wherever possible.
This commit is contained in:
parent
7f290365a9
commit
b323c049c9
@ -315,13 +315,13 @@ namespace etl
|
||||
//*******************************************
|
||||
/// Copy construct from unexpected type.
|
||||
//*******************************************
|
||||
template <typename G, typename etl::enable_if< !etl::is_convertible<const G&, TError>::value, bool>::type = false>
|
||||
template <typename G, etl::enable_if_t<!etl::is_convertible<const G&, TError>::value, bool> = false>
|
||||
ETL_CONSTEXPR14 explicit expected(const etl::unexpected<G>& ue)
|
||||
: storage(etl::in_place_index_t<Error_Type>(), ue.error())
|
||||
{
|
||||
}
|
||||
|
||||
template <typename G, typename etl::enable_if< etl::is_convertible<const G&, TError>::value, bool>::type = false>
|
||||
template <typename G, etl::enable_if_t<etl::is_convertible<const G&, TError>::value, bool> = false>
|
||||
ETL_CONSTEXPR14 expected(const etl::unexpected<G>& ue)
|
||||
: storage(etl::in_place_index_t<Error_Type>(), ue.error())
|
||||
{
|
||||
@ -338,13 +338,13 @@ namespace etl
|
||||
//*******************************************
|
||||
/// Move construct from unexpected type.
|
||||
//*******************************************
|
||||
template <typename G, typename etl::enable_if< !etl::is_convertible<const G&, TError>::value, bool>::type = false>
|
||||
template <typename G, etl::enable_if_t< !etl::is_convertible<const G&, TError>::value, bool> = false>
|
||||
ETL_CONSTEXPR14 explicit expected(etl::unexpected<G>&& ue)
|
||||
: storage(etl::in_place_index_t<Error_Type>(), etl::move(ue.error()))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename G, typename etl::enable_if< etl::is_convertible<const G&, TError>::value, bool>::type = false>
|
||||
template <typename G, etl::enable_if_t<etl::is_convertible<const G&, TError>::value, bool> = false>
|
||||
ETL_CONSTEXPR14 expected(etl::unexpected<G>&& ue)
|
||||
: storage(etl::in_place_index_t<Error_Type>(), etl::move(ue.error()))
|
||||
{
|
||||
@ -807,97 +807,97 @@ namespace etl
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, TValue&>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F, TValue&>>>
|
||||
auto transform(F&& f) & -> expected<U, TError>
|
||||
{
|
||||
return transform_impl<F, this_type&, U, TValue&>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template < typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, const TValue&>::type>::type>
|
||||
template < typename F, typename U = etl::remove_cvref_t< etl::invoke_result_t<F, const TValue&>>>
|
||||
auto transform(F&& f) const& -> expected<U, TError>
|
||||
{
|
||||
return transform_impl<F, const this_type&, U, const TValue&>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, TValue&&>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t< etl::invoke_result_t<F, TValue&&>>>
|
||||
auto transform(F&& f) && -> expected<U, TError>
|
||||
{
|
||||
return transform_impl<F, this_type&&, U, TValue&&>(etl::forward<F>(f), etl::move(*this));
|
||||
}
|
||||
|
||||
template < typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, const TValue&&>::type>::type>
|
||||
template < typename F, typename U = etl::remove_cvref_t< etl::invoke_result_t<F, const TValue&&>>>
|
||||
auto transform(F&& f) const&& -> expected<U, TError>
|
||||
{
|
||||
return transform_impl<F, const this_type&&, U, const TValue&&>(etl::forward<F>(f), etl::move(*this));
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, TValue&>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t< etl::invoke_result_t<F, TValue&>>>
|
||||
auto and_then(F&& f) & -> U
|
||||
{
|
||||
return and_then_impl<F, this_type&, U, TValue&>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template < typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, const TValue&>::type>::type>
|
||||
template < typename F, typename U = etl::remove_cvref_t< etl::invoke_result_t<F, const TValue&>>>
|
||||
auto and_then(F&& f) const& -> U
|
||||
{
|
||||
return and_then_impl<F, const this_type&, U, const TValue&>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, TValue&&>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t< etl::invoke_result_t<F, TValue&&>>>
|
||||
auto and_then(F&& f) && -> U
|
||||
{
|
||||
return and_then_impl<F, this_type&&, U, TValue&&>(etl::forward<F>(f), etl::move(*this));
|
||||
}
|
||||
|
||||
template < typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, const TValue&&>::type>::type>
|
||||
template < typename F, typename U = etl::remove_cvref_t< etl::invoke_result_t<F, const TValue&&>>>
|
||||
auto and_then(F&& f) const&& -> U
|
||||
{
|
||||
return and_then_impl<F, const this_type&&, U, const TValue&&>(etl::forward<F>(f), etl::move(*this));
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, TError&>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t< etl::invoke_result_t<F, TError&>>>
|
||||
auto or_else(F&& f) & -> U
|
||||
{
|
||||
return or_else_impl<F, this_type&, U, TError&>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template < typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, const TError&>::type>::type>
|
||||
template < typename F, typename U = etl::remove_cvref_t< etl::invoke_result_t<F, const TError&>>>
|
||||
auto or_else(F&& f) const& -> U
|
||||
{
|
||||
return or_else_impl<F, const this_type&, U, const TError&>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, TError&&>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t< etl::invoke_result_t<F, TError&&>>>
|
||||
auto or_else(F&& f) && -> U
|
||||
{
|
||||
return or_else_impl<F, this_type&&, U, TError&&>(etl::forward<F>(f), etl::move(*this));
|
||||
}
|
||||
|
||||
template < typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, const TError&&>::type>::type>
|
||||
template < typename F, typename U = etl::remove_cvref_t< etl::invoke_result_t<F, const TError&&>>>
|
||||
auto or_else(F&& f) const&& -> U
|
||||
{
|
||||
return or_else_impl<F, const this_type&&, U, const TError&&>(etl::forward<F>(f), etl::move(*this));
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, TError&>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t< etl::invoke_result_t<F, TError&>>>
|
||||
auto transform_error(F&& f) & -> expected<TValue, U>
|
||||
{
|
||||
return transform_error_impl<F, this_type&, U, TError&>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template < typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, const TError&>::type>::type>
|
||||
template < typename F, typename U = etl::remove_cvref_t< etl::invoke_result_t<F, const TError&>>>
|
||||
auto transform_error(F&& f) const& -> expected<TValue, U>
|
||||
{
|
||||
return transform_error_impl<F, const this_type&, U, const TError&>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, TError&&>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t< etl::invoke_result_t<F, TError&&>>>
|
||||
auto transform_error(F&& f) && -> expected<TValue, U>
|
||||
{
|
||||
return transform_error_impl<F, this_type&&, U, TError&&>(etl::forward<F>(f), etl::move(*this));
|
||||
}
|
||||
|
||||
template < typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, const TError&&>::type>::type>
|
||||
template < typename F, typename U = etl::remove_cvref_t< etl::invoke_result_t<F, const TError&&>>>
|
||||
auto transform_error(F&& f) const&& -> expected<TValue, U>
|
||||
{
|
||||
return transform_error_impl<F, const this_type&&, U, const TError&&>(etl::forward<F>(f), etl::move(*this));
|
||||
@ -916,7 +916,7 @@ namespace etl
|
||||
storage_type storage;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
template < typename F, typename TExp, typename TRet, typename TValueRef, typename = typename etl::enable_if<!etl::is_void<TRet>::value>::type>
|
||||
template < typename F, typename TExp, typename TRet, typename TValueRef, typename = etl::enable_if_t<!etl::is_void<TRet>::value>>
|
||||
auto transform_impl(F&& f, TExp&& exp) const -> expected<TRet, TError>
|
||||
{
|
||||
if (exp.has_value())
|
||||
@ -929,7 +929,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
template < typename F, typename TExp, typename TRet, typename TValueRef, typename = typename etl::enable_if<etl::is_void<TRet>::value>::type>
|
||||
template < typename F, typename TExp, typename TRet, typename TValueRef, typename = etl::enable_if_t<etl::is_void<TRet>::value>>
|
||||
auto transform_impl(F&& f, TExp&& exp) const -> expected<void, TError>
|
||||
{
|
||||
if (exp.has_value())
|
||||
@ -944,8 +944,8 @@ namespace etl
|
||||
}
|
||||
|
||||
template < typename F, typename TExp, typename TRet, typename TValueRef,
|
||||
typename = typename etl::enable_if< !etl::is_void<TRet>::value && etl::is_expected<TRet>::value
|
||||
&& etl::is_same<typename TRet::error_type, TError>::value>::type>
|
||||
typename = etl::enable_if_t<!etl::is_void<TRet>::value && etl::is_expected<TRet>::value
|
||||
&& etl::is_same<typename TRet::error_type, TError>::value>>
|
||||
auto and_then_impl(F&& f, TExp&& exp) const -> TRet
|
||||
{
|
||||
if (exp.has_value())
|
||||
@ -959,8 +959,8 @@ namespace etl
|
||||
}
|
||||
|
||||
template < typename F, typename TExp, typename TRet, typename TErrorRef,
|
||||
typename = typename etl::enable_if< !etl::is_void<TRet>::value && etl::is_expected<TRet>::value
|
||||
&& etl::is_same<typename TRet::value_type, TValue>::value>::type>
|
||||
typename = etl::enable_if_t<!etl::is_void<TRet>::value && etl::is_expected<TRet>::value
|
||||
&& etl::is_same<typename TRet::value_type, TValue>::value>>
|
||||
auto or_else_impl(F&& f, TExp&& exp) const -> TRet
|
||||
{
|
||||
if (exp.has_value())
|
||||
@ -973,7 +973,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
template < typename F, typename TExp, typename TRet, typename TErrorRef, typename = typename etl::enable_if<!etl::is_void<TRet>::value>::type>
|
||||
template < typename F, typename TExp, typename TRet, typename TErrorRef, typename = etl::enable_if_t<!etl::is_void<TRet>::value>>
|
||||
auto transform_error_impl(F&& f, TExp&& exp) const -> expected<TValue, TRet>
|
||||
{
|
||||
if (exp.has_value())
|
||||
@ -1216,97 +1216,97 @@ namespace etl
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F>>>
|
||||
auto transform(F&& f) & -> expected<U, TError>
|
||||
{
|
||||
return transform_impl<F, this_type&, U>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F>>>
|
||||
auto transform(F&& f) const& -> expected<U, TError>
|
||||
{
|
||||
return transform_impl<F, const this_type&, U>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F>>>
|
||||
auto transform(F&& f) && -> expected<U, TError>
|
||||
{
|
||||
return transform_impl<F, this_type&&, U>(etl::forward<F>(f), etl::move(*this));
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F>>>
|
||||
auto transform(F&& f) const&& -> expected<U, TError>
|
||||
{
|
||||
return transform_impl<F, const this_type&&, U>(etl::forward<F>(f), etl::move(*this));
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F>>>
|
||||
auto and_then(F&& f) & -> U
|
||||
{
|
||||
return and_then_impl<F, this_type&, U>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F>>>
|
||||
auto and_then(F&& f) const& -> U
|
||||
{
|
||||
return and_then_impl<F, const this_type&, U>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F>>>
|
||||
auto and_then(F&& f) && -> U
|
||||
{
|
||||
return and_then_impl<F, this_type&&, U>(etl::forward<F>(f), etl::move(*this));
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F>>>
|
||||
auto and_then(F&& f) const&& -> U
|
||||
{
|
||||
return and_then_impl<F, const this_type&&, U>(etl::forward<F>(f), etl::move(*this));
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, TError&>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F, TError&>>>
|
||||
auto or_else(F&& f) & -> U
|
||||
{
|
||||
return or_else_impl<F, this_type&, U, TError&>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template < typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, const TError&>::type>::type>
|
||||
template < typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F, const TError&>>>
|
||||
auto or_else(F&& f) const& -> U
|
||||
{
|
||||
return or_else_impl<F, const this_type&, U, const TError&>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, TError&&>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F, TError&&>>>
|
||||
auto or_else(F&& f) && -> U
|
||||
{
|
||||
return or_else_impl<F, this_type&&, U, TError&&>(etl::forward<F>(f), etl::move(*this));
|
||||
}
|
||||
|
||||
template < typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, const TError&&>::type>::type>
|
||||
template < typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F, const TError&&>>>
|
||||
auto or_else(F&& f) const&& -> U
|
||||
{
|
||||
return or_else_impl<F, const this_type&&, U, const TError&&>(etl::forward<F>(f), etl::move(*this));
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, TError&>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F, TError&>>>
|
||||
auto transform_error(F&& f) & -> expected<void, U>
|
||||
{
|
||||
return transform_error_impl<F, this_type&, U, TError&>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template < typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, const TError&>::type>::type>
|
||||
template < typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F, const TError&>>>
|
||||
auto transform_error(F&& f) const& -> expected<void, U>
|
||||
{
|
||||
return transform_error_impl<F, const this_type&, U, const TError&>(etl::forward<F>(f), *this);
|
||||
}
|
||||
|
||||
template <typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, TError&&>::type>::type>
|
||||
template <typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F, TError&&>>>
|
||||
auto transform_error(F&& f) && -> expected<void, U>
|
||||
{
|
||||
return transform_error_impl<F, this_type&&, U, TError&&>(etl::forward<F>(f), etl::move(*this));
|
||||
}
|
||||
|
||||
template < typename F, typename U = typename etl::remove_cvref< typename etl::invoke_result<F, void, const TError&&>::type>::type>
|
||||
template < typename F, typename U = etl::remove_cvref_t<etl::invoke_result_t<F, const TError&&>>>
|
||||
auto transform_error(F&& f) const&& -> expected<void, U>
|
||||
{
|
||||
return transform_error_impl<F, const this_type&&, U, const TError&&>(etl::forward<F>(f), etl::move(*this));
|
||||
@ -1324,7 +1324,7 @@ namespace etl
|
||||
etl::variant<etl::monostate, error_type> storage;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
template < typename F, typename TExp, typename TRet, typename = typename etl::enable_if<!etl::is_void<TRet>::value>::type>
|
||||
template < typename F, typename TExp, typename TRet, typename = etl::enable_if_t<!etl::is_void<TRet>::value>>
|
||||
auto transform_impl(F&& f, TExp&& exp) const -> expected<TRet, TError>
|
||||
{
|
||||
if (exp.has_value())
|
||||
@ -1337,7 +1337,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
template < typename F, typename TExp, typename TRet, typename = typename etl::enable_if<etl::is_void<TRet>::value>::type>
|
||||
template < typename F, typename TExp, typename TRet, typename = etl::enable_if_t<etl::is_void<TRet>::value>>
|
||||
auto transform_impl(F&& f, TExp&& exp) const -> expected<void, TError>
|
||||
{
|
||||
if (exp.has_value())
|
||||
@ -1352,8 +1352,8 @@ namespace etl
|
||||
}
|
||||
|
||||
template < typename F, typename TExp, typename TRet,
|
||||
typename = typename etl::enable_if< !etl::is_void<TRet>::value && etl::is_expected<TRet>::value
|
||||
&& etl::is_same<typename TRet::error_type, TError>::value>::type>
|
||||
typename = etl::enable_if_t< !etl::is_void<TRet>::value && etl::is_expected<TRet>::value
|
||||
&& etl::is_same<typename TRet::error_type, TError>::value>>
|
||||
auto and_then_impl(F&& f, TExp&& exp) const -> TRet
|
||||
{
|
||||
if (exp.has_value())
|
||||
@ -1367,8 +1367,8 @@ namespace etl
|
||||
}
|
||||
|
||||
template <typename F, typename TExp, typename TRet, typename TErrorRef,
|
||||
typename = typename etl::enable_if< !etl::is_void<TRet>::value && etl::is_expected<TRet>::value
|
||||
&& etl::is_same<typename TRet::value_type, void>::value>::type>
|
||||
typename = etl::enable_if_t< !etl::is_void<TRet>::value && etl::is_expected<TRet>::value
|
||||
&& etl::is_same<typename TRet::value_type, void>::value>>
|
||||
auto or_else_impl(F&& f, TExp&& exp) const -> TRet
|
||||
{
|
||||
if (exp.has_value())
|
||||
@ -1381,7 +1381,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
template < typename F, typename TExp, typename TRet, typename TErrorRef, typename = typename etl::enable_if<!etl::is_void<TRet>::value>::type>
|
||||
template < typename F, typename TExp, typename TRet, typename TErrorRef, typename = etl::enable_if_t<!etl::is_void<TRet>::value>>
|
||||
auto transform_error_impl(F&& f, TExp&& exp) const -> expected<void, TRet>
|
||||
{
|
||||
if (exp.has_value())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user