Skip to content

Commit

Permalink
add make_expected() for use with std::expected() if -Dnsel_P0323R=3 (#66
Browse files Browse the repository at this point in the history
, thanks @psyinf)
  • Loading branch information
martinmoene committed Jun 3, 2024
1 parent 006a729 commit 8203019
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion include/nonstd/expected.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,22 @@ inline in_place_t in_place_index( detail::in_place_index_tag<K> = detail::in_pla
namespace nonstd {

using std::expected;
// ...

#if nsel_P0323R <= 3

template< typename T >
constexpr auto make_expected( T && v ) -> expected< typename std::decay<T>::type >
{
return expected< typename std::decay<T>::type >( std::forward<T>( v ) );
}

// expected<void> specialization:

auto inline make_expected() -> expected<void>
{
return expected<void>( in_place );
}
#endif // nsel_P0323R <= 3
}

#else // nsel_USES_STD_EXPECTED
Expand Down

0 comments on commit 8203019

Please sign in to comment.