libstdc++: Fix constraints on std::expected<void, E> constructor [PR105153]
libstdc++-v3/ChangeLog: PR libstdc++/105153 * include/std/expected (expected<void,E>::expected(expected<U,G>&&)): Fix constraints. * testsuite/20_util/expected/cons.cc: Check constructor.
This commit is contained in:
parent
0dfaf56252
commit
7b4495d3c4
2 changed files with 20 additions and 2 deletions
|
@ -966,8 +966,8 @@ namespace __expected
|
|||
}
|
||||
|
||||
template<typename _Up, typename _Gr>
|
||||
requires is_void_v<_Tp>
|
||||
&& is_constructible_v<_Er, const _Gr&>
|
||||
requires is_void_v<_Up>
|
||||
&& is_constructible_v<_Er, _Gr>
|
||||
&& (!__cons_from_expected<_Up, _Gr>)
|
||||
constexpr explicit(!is_convertible_v<_Gr, _Er>)
|
||||
expected(expected<_Up, _Gr>&& __x)
|
||||
|
|
|
@ -162,6 +162,22 @@ test_copy()
|
|||
return true;
|
||||
}
|
||||
|
||||
constexpr bool
|
||||
test_pr105153()
|
||||
{
|
||||
struct E {
|
||||
E(int&&) = delete;
|
||||
E(const int&);
|
||||
};
|
||||
|
||||
std::expected<void, E> e(std::expected<void, int>{});
|
||||
|
||||
static_assert( ! std::is_constructible_v<std::expected<void, int>,
|
||||
std::expected<int, int>> );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_default();
|
||||
|
@ -172,4 +188,6 @@ int main()
|
|||
static_assert( test_err() );
|
||||
test_copy();
|
||||
static_assert( test_copy() );
|
||||
test_pr105153();
|
||||
static_assert( test_pr105153() );
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue