Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LWG-3772 repeat_view's piecewise constructor is missing Postconditions #3462

Merged
merged 1 commit into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -1561,12 +1561,16 @@ namespace ranges {
}
template <class... _TArgs, class... _BArgs>
requires constructible_from<_Ty, _TArgs...> && constructible_from<_Bo, _BArgs...>
// clang-format off
_NODISCARD_CTOR constexpr explicit repeat_view(piecewise_construct_t,
tuple<_TArgs...> _Val_args, tuple<_BArgs...> _Bound_args = tuple<>{})
noexcept(is_nothrow_constructible_v<_Ty, _TArgs...>) // strengthened
// clang-format on
: repeat_view(_Val_args, index_sequence_for<_TArgs...>{}, _STD make_from_tuple<_Bo>(_Bound_args)) {}
_NODISCARD_CTOR constexpr explicit repeat_view(piecewise_construct_t, tuple<_TArgs...> _Val_args,
tuple<_BArgs...> _Bound_args = tuple<>{}) noexcept(is_nothrow_constructible_v<_Ty,
_TArgs...>&& noexcept(_STD make_from_tuple<_Bo>(_Bound_args))) // strengthened
: repeat_view(_Val_args, index_sequence_for<_TArgs...>{}, _STD make_from_tuple<_Bo>(_Bound_args)) {
#if _CONTAINER_DEBUG_LEVEL > 0
if constexpr (_Signed_integer_like<_Bo>) {
_STL_VERIFY(_Bound >= 0, "Bound must be >= 0");
}
#endif
}

_NODISCARD constexpr _Iterator begin() const noexcept /* strengthened */ {
return _Iterator{_STD addressof(*_Value)};
Expand Down
7 changes: 5 additions & 2 deletions stl/inc/tuple
Original file line number Diff line number Diff line change
Expand Up @@ -871,15 +871,18 @@ constexpr decltype(auto) apply(_Callable&& _Obj, _Tuple&& _Tpl) noexcept(
}

template <class _Ty, class _Tuple, size_t... _Indices>
constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) {
constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) noexcept(
is_nothrow_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl)))...>) {
// construct _Ty from the elements of _Tpl
static_assert(is_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl)))...>,
"the target type must be constructible from the fields of the argument tuple (N4892 [tuple.apply]/2).");
return _Ty(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...);
}

_EXPORT_STD template <class _Ty, class _Tuple>
_NODISCARD constexpr _Ty make_from_tuple(_Tuple&& _Tpl) { // construct _Ty from the elements of _Tpl
_NODISCARD constexpr _Ty make_from_tuple(_Tuple&& _Tpl) noexcept(noexcept(_Make_from_tuple_impl<_Ty>(
_STD forward<_Tuple>(_Tpl), make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>{}))) /* strengthened */ {
// construct _Ty from the elements of _Tpl
return _Make_from_tuple_impl<_Ty>(
_STD forward<_Tuple>(_Tpl), make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>{});
}
Expand Down