diff --git a/include/seqan3/io/sam_file/header.hpp b/include/seqan3/io/sam_file/header.hpp index f52f7aa0cf..367f7d9ad3 100644 --- a/include/seqan3/io/sam_file/header.hpp +++ b/include/seqan3/io/sam_file/header.hpp @@ -56,17 +56,10 @@ class sam_file_header sam_file_header & operator=(sam_file_header &&) = default; //!< Defaulted. ~sam_file_header() = default; //!< Defaulted. - /*!\brief Construct from a range of reference ids which redirects the `ref_ids_ptr` member (non-owning). - * \param[in] ref_ids The range over reference ids to redirect the pointer at. + /*!\brief Construct from a range of reference ids which is moved into the `ref_ids_ptr` (owning). + * \param[in] ref_ids The range over reference ids. */ - sam_file_header(ref_ids_type & ref_ids) : ref_ids_ptr{&ref_ids, ref_ids_deleter_noop} - {} - - /*!\brief Construct from a rvalue range of reference ids which is moved into the `ref_ids_ptr` (owning). - * \param[in] ref_ids The range over reference ids to own. - */ - sam_file_header(ref_ids_type && ref_ids) : - ref_ids_ptr{new ref_ids_type{std::move(ref_ids)}, ref_ids_deleter_default} + sam_file_header(ref_ids_type ref_ids) : ref_ids_ptr{std::make_unique(std::move(ref_ids))} {} //!\} @@ -84,21 +77,14 @@ class sam_file_header private: //!\brief The type of the internal ref_ids pointer. Allows dynamically setting ownership management. - using ref_ids_ptr_t = std::unique_ptr>; - //!\brief Stream deleter that does nothing (no ownership assumed). - static void ref_ids_deleter_noop(ref_ids_type *) - {} - //!\brief Stream deleter with default behaviour (ownership assumed). - static void ref_ids_deleter_default(ref_ids_type * ptr) - { - delete ptr; - } + using ref_ids_ptr_t = std::unique_ptr; + //!\brief The key's type of ref_dict. using key_type = std::conditional_t>, std::span const>, type_reduce_t>>; - //!\brief The pointer to reference ids information (non-owning if reference information is given). - ref_ids_ptr_t ref_ids_ptr{new ref_ids_type{}, ref_ids_deleter_default}; + //!\brief The pointer to reference ids information (owning). + ref_ids_ptr_t ref_ids_ptr{std::make_unique(ref_ids_type{})}; //!\brief Custom hash function since std::hash is not defined for all range types (e.g. std::span). struct key_hasher