Skip to content

Commit

Permalink
[MISC] Replace copyable_wrapper with movable_box
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Jan 23, 2025
1 parent 3e4c200 commit 6ade43d
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 301 deletions.
1 change: 0 additions & 1 deletion doc/cookbook/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ Search for keywords with `Strg + F`.
\include test/snippet/core/debug_stream_set_underlying_stream.cpp
\include test/snippet/core/debug_stream_set_underlying_stream2.cpp
\include test/snippet/core/debug_stream_usage.cpp
\include test/snippet/core/detail/copyable_wrapper.cpp
\include test/snippet/core/detail/customisation_point.cpp
\include test/snippet/core/detail/deferred_crtp_base.cpp
\include test/snippet/core/detail/is_class_template_declarable_with.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include <type_traits>

#include <seqan3/alignment/configuration/detail.hpp>
#include <seqan3/contrib/std/detail/movable_box.hpp>
#include <seqan3/core/configuration/pipeable_config_element.hpp>
#include <seqan3/core/detail/copyable_wrapper.hpp>

namespace seqan3::align_cfg
{
Expand All @@ -22,7 +22,7 @@ namespace seqan3::align_cfg
* \ingroup alignment_configuration
*
* \tparam callback_t The type of the callback; must model std::invocable with the generated seqan3::alignment_result
* and std::copy_constructible.
* and std::move_constructible.
*
* \details
*
Expand All @@ -35,7 +35,7 @@ namespace seqan3::align_cfg
* function, you need to make sure that the referenced function object outlives the call to the alignment algorithm.
*
* \if DEV
* The given callback is wrapped inside a seqan3::detail::copyable_wrapper wrapper type. This allows to also
* The given callback is wrapped inside a seqan::stl::detail::movable_box wrapper type. This allows to also
* use lambdas with a capture block, which otherwise are not std::copy_assignable and therefore invalidate the
* requirements for the configuration element (must model std::semiregular).
* \endif
Expand All @@ -46,12 +46,12 @@ namespace seqan3::align_cfg
*
* \include test/snippet/alignment/configuration/align_cfg_on_result.cpp
*/
template <std::copy_constructible callback_t>
template <std::move_constructible callback_t>
class on_result : private seqan3::pipeable_config_element
{
public:
//!\brief The stored callable which will be invoked with the alignment result.
seqan3::detail::copyable_wrapper_t<callback_t> callback; // Allows lambdas with capture blocks.
seqan::stl::detail::movable_box_t<callback_t> callback; // Allows lambdas with capture blocks.

/*!\name Constructors, destructor and assignment
* \{
Expand Down Expand Up @@ -79,7 +79,7 @@ class on_result : private seqan3::pipeable_config_element
* \{
*/
//!\brief Deduces the callback type from a forwarding constructor argument.
template <std::copy_constructible callback_t>
template <std::move_constructible callback_t>
on_result(callback_t &&) -> on_result<std::decay_t<callback_t>>;
//!\}
} // namespace seqan3::align_cfg
4 changes: 2 additions & 2 deletions include/seqan3/core/configuration/detail/concept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ inline constexpr std::array<std::array<void *, 0>, 0> compatibility_table{};
* \brief Concept for an algorithm configuration element.
* \ingroup core_configuration
*
* \extends std::copyable
* \extends std::movable
* \implements seqan3::pipeable_config_element
*/

Expand All @@ -64,7 +64,7 @@ inline constexpr std::array<std::array<void *, 0>, 0> compatibility_table{};
template <typename config_t>
concept config_element = requires {
requires std::is_base_of_v<seqan3::pipeable_config_element, config_t>;
requires std::copyable<config_t>;
requires std::movable<config_t>;
{ config_t::id };
};
//!\endcond
Expand Down
254 changes: 0 additions & 254 deletions include/seqan3/core/detail/copyable_wrapper.hpp

This file was deleted.

16 changes: 9 additions & 7 deletions include/seqan3/io/views/detail/take_until_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <ranges>
#include <type_traits>

#include <seqan3/core/detail/copyable_wrapper.hpp>
#include <seqan3/contrib/std/detail/movable_box.hpp>
#include <seqan3/core/detail/iterator_traits.hpp>
#include <seqan3/core/range/detail/adaptor_from_functor.hpp>
#include <seqan3/core/range/detail/inherited_iterator_base.hpp>
Expand Down Expand Up @@ -58,7 +58,7 @@ class view_take_until : public std::ranges::view_interface<view_take_until<urng_
urng_t urange;

//!\brief The functor.
copyable_wrapper_t<fun_t> fun;
seqan::stl::detail::movable_box_t<fun_t> fun;

//!\brief Whether this view is const_iterable or not.
static constexpr bool const_iterable =
Expand Down Expand Up @@ -201,7 +201,7 @@ class view_take_until<urng_t, fun_t, or_throw, and_consume>::basic_consume_itera
using base_t = inherited_iterator_base<basic_consume_iterator, underlying_iterator_t>;

//!\brief Pointer to the functor stored in the view.
copyable_wrapper_t<fun_t> const * fun{nullptr};
seqan::stl::detail::movable_box_t<fun_t> const * fun{nullptr};

//!\brief The sentinel type is identical to that of the underlying range.
using underlying_sentinel_t = seqan3::detail::maybe_const_sentinel_t<const_range, urng_t>;
Expand All @@ -225,8 +225,9 @@ class view_take_until<urng_t, fun_t, or_throw, and_consume>::basic_consume_itera
~basic_consume_iterator() = default; //!< Defaulted.

//!\brief Constructor that delegates to the CRTP layer and initialises the callable.
basic_consume_iterator(underlying_iterator_t it, copyable_wrapper_t<fun_t> const & _fun, underlying_sentinel_t sen)
noexcept(noexcept(base_t{it})) :
basic_consume_iterator(underlying_iterator_t it,
seqan::stl::detail::movable_box_t<fun_t> const & _fun,
underlying_sentinel_t sen) noexcept(noexcept(base_t{it})) :
base_t{std::move(it)},
fun{std::addressof(_fun)},
underlying_sentinel{std::move(sen)}
Expand Down Expand Up @@ -348,7 +349,7 @@ class view_take_until<urng_t, fun_t, or_throw, and_consume>::basic_sentinel
underlying_sentinel_t underlying_sentinel{};

//!\brief Pointer to the functor stored in the view.
copyable_wrapper_t<fun_t> const * fun{nullptr};
seqan::stl::detail::movable_box_t<fun_t> const * fun{nullptr};

public:
/*!\name Constructors, destructor and assignment
Expand All @@ -365,7 +366,8 @@ class view_take_until<urng_t, fun_t, or_throw, and_consume>::basic_sentinel
* \param[in] underlying_sentinel The actual end of the underlying range.
* \param[in] _fun Reference to the functor stored in the view.
*/
explicit basic_sentinel(underlying_sentinel_t underlying_sentinel, copyable_wrapper_t<fun_t> const & _fun) :
explicit basic_sentinel(underlying_sentinel_t underlying_sentinel,
seqan::stl::detail::movable_box_t<fun_t> const & _fun) :
underlying_sentinel{std::move(underlying_sentinel)},
fun{std::addressof(_fun)}
{}
Expand Down
Loading

0 comments on commit 6ade43d

Please sign in to comment.