Skip to content

Commit

Permalink
Merge pull request #3328 from eseiler/infra/update_stl
Browse files Browse the repository at this point in the history
[INFRA] Update stl
  • Loading branch information
eseiler authored Jan 23, 2025
2 parents d50f050 + bb76dfc commit 31a4a3e
Show file tree
Hide file tree
Showing 4 changed files with 380 additions and 5 deletions.
4 changes: 2 additions & 2 deletions include/seqan3/contrib/std/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright (c) 2006-2024, Knut Reinert & Freie Universität Berlin
Copyright (c) 2016-2024, Knut Reinert & MPI für molekulare Genetik
Copyright (c) 2006-2025, Knut Reinert & Freie Universität Berlin
Copyright (c) 2016-2025, Knut Reinert & MPI für molekulare Genetik
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
5 changes: 5 additions & 0 deletions include/seqan3/contrib/std/detail/exposition_only.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ concept simple_view = std::ranges::view<range_t> && std::ranges::range<range_t c
template <bool is_const, typename t>
using maybe_const = std::conditional_t<is_const, t const, t>;

template <class R>
concept range_with_movable_references =
std::ranges::input_range<R> && std::move_constructible<std::ranges::range_reference_t<R>>
&& std::move_constructible<std::ranges::range_rvalue_reference_t<R>>;

} // namespace seqan::stl::detail

#endif // SEQAN_STD_DETAIL_EXPOSITION_ONLY
35 changes: 32 additions & 3 deletions include/seqan3/contrib/std/detail/movable_box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ class movable_box : public std::optional<t>
};

template <boxable t>
requires std::copyable<t> || (std::is_nothrow_move_constructible_v<t> && std::is_nothrow_copy_constructible_v<t>)
requires std::copyable<t>
|| (std::is_copy_constructible_v<t> && std::is_nothrow_move_constructible_v<t>
&& std::is_nothrow_copy_constructible_v<t>)
|| (!std::is_copy_constructible_v<t> && (std::movable<t> || std::is_nothrow_move_constructible_v<t>))
class movable_box<t>
{
private:
Expand All @@ -92,13 +95,39 @@ class movable_box<t>
constexpr movable_box(movable_box &&) = default;
constexpr ~movable_box() = default;

constexpr movable_box & operator=(movable_box const &) = default;
constexpr movable_box & operator=(movable_box const &)
requires std::copyable<t>
= default;

constexpr movable_box & operator=(movable_box &&) = default;
constexpr movable_box & operator=(movable_box &&)
requires std::movable<t>
= default;

constexpr explicit movable_box(t const & other) noexcept(std::is_nothrow_copy_constructible_v<t>) : value{other}
{}

constexpr movable_box & operator=(movable_box const & other) noexcept(std::is_nothrow_copy_constructible_v<t>)
requires (!std::copyable<t> && std::copy_constructible<t>)
{
if (this != std::addressof(other))
{
value.~t();
std::construct_at(std::addressof(value), other.value);
}
return *this;
}

constexpr movable_box & operator=(movable_box && other) noexcept(std::is_nothrow_move_constructible_v<t>)
requires (!std::movable<t>)
{
if (this != std::addressof(other))
{
value.~t();
std::construct_at(std::addressof(value), std::move(other.value));
}
return *this;
}

constexpr explicit movable_box(t && other) noexcept(std::is_nothrow_move_constructible_v<t>) :
value{std::move(other)}
{}
Expand Down
Loading

0 comments on commit 31a4a3e

Please sign in to comment.