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

[FIX] CPP23 #3240

Merged
merged 2 commits into from
Feb 27, 2024
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
11 changes: 11 additions & 0 deletions include/seqan3/core/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ static_assert(sdsl::sdsl_version_major == 3, "Only version 3 of the SDSL is supp
# endif
#endif

/*!\brief Workaround for variable template specialisations not being emitted.
* \see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114013
*/
#ifndef SEQAN3_WORKAROUND_GCC_114013
# if SEQAN3_COMPILER_IS_GCC && (__GNUC__ == 14)
# define SEQAN3_WORKAROUND_GCC_114013 constexpr
# else
# define SEQAN3_WORKAROUND_GCC_114013 inline constexpr
# endif
#endif

/*!\brief This is needed to support CentOS 7 or RHEL 7; Newer CentOS's include a more modern default-gcc version making
* this macro obsolete.
*
Expand Down
20 changes: 15 additions & 5 deletions include/seqan3/io/record.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ struct fields
template <typename field_types, typename field_ids>
struct record : detail::transfer_template_args_onto_t<field_types, std::tuple>
{
public:
//!\brief A specialisation of std::tuple.
using base_type = detail::transfer_template_args_onto_t<field_types, std::tuple>;

private:
//!\brief Auxiliary functions for clear().
template <typename t>
Expand All @@ -210,10 +214,13 @@ struct record : detail::transfer_template_args_onto_t<field_types, std::tuple>
(clear_element(args), ...);
};

public:
//!\brief A specialisation of std::tuple.
using base_type = detail::transfer_template_args_onto_t<field_types, std::tuple>;
//!\brief Returns the tuple as the underlying std::tuple type.
base_type & as_base() noexcept
{
return *this;
}

public:
/*!\name Constructors, destructor and assignment
* \{
*/
Expand All @@ -232,9 +239,12 @@ struct record : detail::transfer_template_args_onto_t<field_types, std::tuple>
"You must give as many IDs as types to seqan3::record.");

//!\brief Clears containers that provide `.clear()` and (re-)initialises all other elements with `= {}`.
void clear() noexcept(noexcept(std::apply(expander, std::declval<record &>())))
void clear() noexcept(noexcept(std::apply(expander, std::declval<record &>().as_base())))
{
std::apply(expander, *this);
// PR2165 / __cpp_lib_tuple_like (C++23): std::apply requires tuple-like.
// In C++23, this means std::array, std::pair, std::tuple, and std::ranges::subranges. Nothing else.
// https://en.cppreference.com/w/cpp/utility/tuple/tuple-like
std::apply(expander, as_base());
Copy link
Member Author

@eseiler eseiler Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also be

std::apply(expander, static_cast<base_type &>(*this));

but I prefer the as_base()-way

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, as_base() is nicer

}

protected:
Expand Down
45 changes: 24 additions & 21 deletions include/seqan3/search/detail/search_scheme_precomputed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ template <uint8_t nbr_blocks>
struct search
{
//!\brief Type for storing the length of blocks
typedef std::array<size_t, nbr_blocks> blocks_length_type;
using blocks_length_type = std::array<size_t, nbr_blocks>;

//!\brief Order of blocks
std::array<uint8_t, nbr_blocks> pi;
Expand All @@ -46,7 +46,7 @@ struct search
struct search_dyn
{
//!\brief Type for storing the length of blocks
typedef std::vector<size_t> blocks_length_type;
using blocks_length_type = std::vector<size_t>;

//!\brief Order of blocks
std::vector<uint8_t> pi;
Expand Down Expand Up @@ -81,60 +81,63 @@ using search_scheme_dyn_type = std::vector<search_dyn>;
* seems to be a good greedy approach.
*/
template <uint8_t min_error, uint8_t max_error>
inline constexpr int optimum_search_scheme{0};
SEQAN3_WORKAROUND_GCC_114013 int optimum_search_scheme{0};

//!\cond

template <>
inline constexpr search_scheme_type<1, 1> optimum_search_scheme<0, 0>{{{{1}, {0}, {0}}}};
SEQAN3_WORKAROUND_GCC_114013 search_scheme_type<1, 1> optimum_search_scheme<0, 0>{{{{1}, {0}, {0}}}};

template <>
inline constexpr search_scheme_type<2, 2> optimum_search_scheme<0, 1>{
SEQAN3_WORKAROUND_GCC_114013 search_scheme_type<2, 2> optimum_search_scheme<0, 1>{
{{{1, 2}, {0, 0}, {0, 1}}, {{2, 1}, {0, 1}, {0, 1}}}};

template <>
inline constexpr search_scheme_type<2, 2> optimum_search_scheme<1, 1>{
SEQAN3_WORKAROUND_GCC_114013 search_scheme_type<2, 2> optimum_search_scheme<1, 1>{
{{{1, 2}, {0, 1}, {0, 1}}, {{2, 1}, {0, 1}, {0, 1}}}};

template <>
inline constexpr search_scheme_type<3, 4> optimum_search_scheme<0, 2>{{{{1, 2, 3, 4}, {0, 0, 1, 1}, {0, 0, 2, 2}},
{{3, 2, 1, 4}, {0, 0, 0, 0}, {0, 1, 1, 2}},
{{4, 3, 2, 1}, {0, 0, 0, 2}, {0, 1, 2, 2}}}};
SEQAN3_WORKAROUND_GCC_114013 search_scheme_type<3, 4> optimum_search_scheme<0, 2>{
{{{1, 2, 3, 4}, {0, 0, 1, 1}, {0, 0, 2, 2}},
{{3, 2, 1, 4}, {0, 0, 0, 0}, {0, 1, 1, 2}},
{{4, 3, 2, 1}, {0, 0, 0, 2}, {0, 1, 2, 2}}}};

template <>
inline constexpr search_scheme_type<3, 4> optimum_search_scheme<1, 2>{{{{1, 2, 3, 4}, {0, 0, 0, 1}, {0, 0, 2, 2}},
{{3, 2, 1, 4}, {0, 0, 1, 1}, {0, 1, 1, 2}},
{{4, 3, 2, 1}, {0, 0, 0, 2}, {0, 1, 2, 2}}}};
SEQAN3_WORKAROUND_GCC_114013 search_scheme_type<3, 4> optimum_search_scheme<1, 2>{
{{{1, 2, 3, 4}, {0, 0, 0, 1}, {0, 0, 2, 2}},
{{3, 2, 1, 4}, {0, 0, 1, 1}, {0, 1, 1, 2}},
{{4, 3, 2, 1}, {0, 0, 0, 2}, {0, 1, 2, 2}}}};

template <>
inline constexpr search_scheme_type<3, 4> optimum_search_scheme<2, 2>{{{{4, 3, 2, 1}, {0, 0, 1, 2}, {0, 0, 2, 2}},
{{2, 3, 4, 1}, {0, 0, 0, 2}, {0, 1, 1, 2}},
{{1, 2, 3, 4}, {0, 0, 0, 2}, {0, 1, 2, 2}}}};
SEQAN3_WORKAROUND_GCC_114013 search_scheme_type<3, 4> optimum_search_scheme<2, 2>{
{{{4, 3, 2, 1}, {0, 0, 1, 2}, {0, 0, 2, 2}},
{{2, 3, 4, 1}, {0, 0, 0, 2}, {0, 1, 1, 2}},
{{1, 2, 3, 4}, {0, 0, 0, 2}, {0, 1, 2, 2}}}};

// TODO: benchmark whether the first search is really the fastest one (see \details of optimum_search_scheme)
template <>
inline constexpr search_scheme_type<4, 5> optimum_search_scheme<0, 3>{
{// TODO: benchmark whether the first search is really the fastest one (see \details of optimum_search_scheme)
{{5, 4, 3, 2, 1}, {0, 0, 0, 0, 0}, {0, 0, 3, 3, 3}},
SEQAN3_WORKAROUND_GCC_114013 search_scheme_type<4, 5> optimum_search_scheme<0, 3>{
{{{5, 4, 3, 2, 1}, {0, 0, 0, 0, 0}, {0, 0, 3, 3, 3}},
{{3, 4, 5, 2, 1}, {0, 0, 1, 1, 1}, {0, 1, 1, 2, 3}},
{{2, 3, 4, 5, 1}, {0, 0, 0, 2, 2}, {0, 1, 2, 2, 3}},
{{1, 2, 3, 4, 5}, {0, 0, 0, 0, 3}, {0, 2, 2, 3, 3}}}};

template <>
inline constexpr search_scheme_type<4, 5> optimum_search_scheme<1, 3>{
SEQAN3_WORKAROUND_GCC_114013 search_scheme_type<4, 5> optimum_search_scheme<1, 3>{
{{{5, 4, 3, 2, 1}, {0, 0, 0, 0, 1}, {0, 0, 3, 3, 3}},
{{3, 4, 5, 2, 1}, {0, 0, 1, 1, 1}, {0, 1, 1, 2, 3}},
{{2, 3, 4, 5, 1}, {0, 0, 0, 2, 2}, {0, 1, 2, 2, 3}},
{{1, 2, 3, 4, 5}, {0, 0, 0, 0, 3}, {0, 2, 2, 3, 3}}}};

template <>
inline constexpr search_scheme_type<4, 5> optimum_search_scheme<2, 3>{
SEQAN3_WORKAROUND_GCC_114013 search_scheme_type<4, 5> optimum_search_scheme<2, 3>{
{{{5, 4, 3, 2, 1}, {0, 0, 0, 0, 2}, {0, 0, 3, 3, 3}},
{{3, 4, 5, 2, 1}, {0, 0, 1, 1, 2}, {0, 1, 1, 2, 3}},
{{2, 3, 4, 5, 1}, {0, 0, 0, 2, 2}, {0, 1, 2, 2, 3}},
{{1, 2, 3, 4, 5}, {0, 0, 0, 0, 3}, {0, 2, 2, 3, 3}}}};

template <>
inline constexpr search_scheme_type<4, 5> optimum_search_scheme<3, 3>{
SEQAN3_WORKAROUND_GCC_114013 search_scheme_type<4, 5> optimum_search_scheme<3, 3>{
{{{5, 4, 3, 2, 1}, {0, 0, 0, 0, 3}, {0, 0, 3, 3, 3}},
{{3, 4, 5, 2, 1}, {0, 0, 1, 1, 3}, {0, 1, 1, 2, 3}},
{{2, 3, 4, 5, 1}, {0, 0, 0, 2, 3}, {0, 1, 2, 2, 3}},
Expand Down
3 changes: 2 additions & 1 deletion test/documentation/seqan3_doxygen_cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ PREDEFINED = CEREAL_SERIALIZE_FUNCTION_NAME=serialize \
__cpp_lib_three_way_comparison=1 \
SEQAN3_WORKAROUND_LITERAL=constexpr
EXPAND_AS_DEFINED = SEQAN3_CPO_OVERLOAD_BODY \
SEQAN3_CPO_OVERLOAD
SEQAN3_CPO_OVERLOAD \
SEQAN3_WORKAROUND_GCC_114013
SKIP_FUNCTION_MACROS = NO
#---------------------------------------------------------------------------
# Configuration options related to external references
Expand Down
Loading