From e0406f37c04875c4c6e9629896b877180a157f81 Mon Sep 17 00:00:00 2001 From: "seqan-actions[bot]" Date: Thu, 25 Jan 2024 17:45:15 +0100 Subject: [PATCH] [MISC] automatic linting --- .../debug_stream_alignment.hpp | 11 +- .../advanceable_alignment_coordinate.hpp | 4 +- .../alignment/matrix/detail/debug_matrix.hpp | 10 +- .../matrix/detail/trace_directions.hpp | 21 +-- .../alignment/pairwise/alignment_result.hpp | 83 +++++----- .../alphabet/detail/debug_stream_alphabet.hpp | 4 +- .../core/debug_stream/debug_stream_type.hpp | 19 ++- .../core/debug_stream/default_printer.hpp | 149 +++++++++++------- include/seqan3/core/debug_stream/optional.hpp | 7 +- include/seqan3/core/debug_stream/range.hpp | 68 ++++---- include/seqan3/core/debug_stream/tuple.hpp | 10 +- 11 files changed, 219 insertions(+), 167 deletions(-) diff --git a/include/seqan3/alignment/aligned_sequence/debug_stream_alignment.hpp b/include/seqan3/alignment/aligned_sequence/debug_stream_alignment.hpp index 2308758240..3a94c2c8ab 100644 --- a/include/seqan3/alignment/aligned_sequence/debug_stream_alignment.hpp +++ b/include/seqan3/alignment/aligned_sequence/debug_stream_alignment.hpp @@ -112,16 +112,17 @@ inline debug_stream_type & operator<<(debug_stream_type & stream { #else template - requires (tuple_like> && detail::all_model_aligned_seq>>) + requires (tuple_like> + && detail::all_model_aligned_seq>>) struct alignment_printer { - constexpr static auto print = [](auto & stream, auto && alignment) + static constexpr auto print = [](auto & stream, auto && alignment) { - constexpr size_t sequence_count = std::tuple_size_v>; + constexpr size_t sequence_count = std::tuple_size_v>; - static_assert(sequence_count >= 2, "An alignment requires at least two sequences."); + static_assert(sequence_count >= 2, "An alignment requires at least two sequences."); - detail::stream_alignment(stream, alignment, std::make_index_sequence{}); + detail::stream_alignment(stream, alignment, std::make_index_sequence{}); }; }; #endif diff --git a/include/seqan3/alignment/matrix/detail/advanceable_alignment_coordinate.hpp b/include/seqan3/alignment/matrix/detail/advanceable_alignment_coordinate.hpp index 143eb7a3af..014dc6c731 100644 --- a/include/seqan3/alignment/matrix/detail/advanceable_alignment_coordinate.hpp +++ b/include/seqan3/alignment/matrix/detail/advanceable_alignment_coordinate.hpp @@ -319,9 +319,9 @@ template detail::advanceable_alignment_coordinate> struct advanceable_alignment_coordinate_printer { - constexpr static auto print = [](auto & s, coordinate_type const & c) + static constexpr auto print = [](auto & s, coordinate_type const & c) { - s << std::tie(c.first, c.second); + s << std::tie(c.first, c.second); }; }; #endif diff --git a/include/seqan3/alignment/matrix/detail/debug_matrix.hpp b/include/seqan3/alignment/matrix/detail/debug_matrix.hpp index 90a03ab411..4eb7864e93 100644 --- a/include/seqan3/alignment/matrix/detail/debug_matrix.hpp +++ b/include/seqan3/alignment/matrix/detail/debug_matrix.hpp @@ -488,13 +488,13 @@ template requires detail::matrix> struct alignment_matrix_printer { - constexpr static auto print = [](auto & s, auto && matrix) + static constexpr auto print = [](auto & s, auto && matrix) { - detail::debug_matrix debug{std::forward(matrix)}; + detail::debug_matrix debug{std::forward(matrix)}; - std::stringstream sstream{}; - debug.stream_matrix(sstream, s.flags2()); - s << sstream.str(); + std::stringstream sstream{}; + debug.stream_matrix(sstream, s.flags2()); + s << sstream.str(); }; }; #endif diff --git a/include/seqan3/alignment/matrix/detail/trace_directions.hpp b/include/seqan3/alignment/matrix/detail/trace_directions.hpp index 241b83fc86..436bb6cd11 100644 --- a/include/seqan3/alignment/matrix/detail/trace_directions.hpp +++ b/include/seqan3/alignment/matrix/detail/trace_directions.hpp @@ -84,20 +84,21 @@ template requires std::is_same_v, detail::trace_directions> struct trace_directions_printer { - constexpr static auto print = [](auto & s, detail::trace_directions const trace) + static constexpr auto print = [](auto & s, detail::trace_directions const trace) { - static char const * unicode[32]{"↺", "↖", "↑", "↖↑", "⇡", "↖⇡", "↑⇡", "↖↑⇡", "←", "↖←", "↑←", - "↖↑←", "⇡←", "↖⇡←", "↑⇡←", "↖↑⇡←", "⇠", "↖⇠", "↑⇠", "↖↑⇠", "⇡⇠", "↖⇡⇠", - "↑⇡⇠", "↖↑⇡⇠", "←⇠", "↖←⇠", "↑←⇠", "↖↑←⇠", "⇡←⇠", "↖⇡←⇠", "↑⇡←⇠", "↖↑⇡←⇠"}; + static char const * unicode[32]{"↺", "↖", "↑", "↖↑", "⇡", "↖⇡", "↑⇡", "↖↑⇡", + "←", "↖←", "↑←", "↖↑←", "⇡←", "↖⇡←", "↑⇡←", "↖↑⇡←", + "⇠", "↖⇠", "↑⇠", "↖↑⇠", "⇡⇠", "↖⇡⇠", "↑⇡⇠", "↖↑⇡⇠", + "←⇠", "↖←⇠", "↑←⇠", "↖↑←⇠", "⇡←⇠", "↖⇡←⇠", "↑⇡←⇠", "↖↑⇡←⇠"}; - static char const * csv[32]{"N", "D", "U", "DU", "u", "Du", "Uu", "DUu", "L", "DL", "UL", - "DUL", "uL", "DuL", "UuL", "DUuL", "l", "Dl", "Ul", "DUl", "ul", "Dul", - "Uul", "DUul", "Ll", "DLl", "ULl", "DULl", "uLl", "DuLl", "UuLl", "DUuLl"}; + static char const * csv[32]{"N", "D", "U", "DU", "u", "Du", "Uu", "DUu", "L", "DL", "UL", + "DUL", "uL", "DuL", "UuL", "DUuL", "l", "Dl", "Ul", "DUl", "ul", "Dul", + "Uul", "DUul", "Ll", "DLl", "ULl", "DULl", "uLl", "DuLl", "UuLl", "DUuLl"}; - bool is_unicode = (s.flags2() & fmtflags2::utf8) == fmtflags2::utf8; - auto const & trace_dir = is_unicode ? unicode : csv; + bool is_unicode = (s.flags2() & fmtflags2::utf8) == fmtflags2::utf8; + auto const & trace_dir = is_unicode ? unicode : csv; - s << trace_dir[static_cast(trace)]; + s << trace_dir[static_cast(trace)]; }; }; #endif diff --git a/include/seqan3/alignment/pairwise/alignment_result.hpp b/include/seqan3/alignment/pairwise/alignment_result.hpp index 61d8e8ff6e..a9ba9c84b3 100644 --- a/include/seqan3/alignment/pairwise/alignment_result.hpp +++ b/include/seqan3/alignment/pairwise/alignment_result.hpp @@ -421,50 +421,55 @@ inline debug_stream_type & operator<<(debug_stream_type & stream template requires (!std::is_same_v>) struct alignment_result_printer : public alignment_result_printer> -{ -}; +{}; template struct alignment_result_printer> { - constexpr static auto print = [](auto & stream, alignment_result const & result) - { - using alignment_result_t = alignment_result; - using disabled_t = std::nullopt_t *; - using result_data_t = - typename detail::alignment_result_value_type_accessor>::type; - - constexpr bool has_sequence1_id = !std::is_same_v().sequence1_id), disabled_t>; - constexpr bool has_sequence2_id = !std::is_same_v().sequence2_id), disabled_t>; - constexpr bool has_score = !std::is_same_v().score), disabled_t>; - constexpr bool has_end_positions = - !std::is_same_v().end_positions), disabled_t>; - constexpr bool has_begin_positions = - !std::is_same_v().begin_positions), disabled_t>; - constexpr bool has_alignment = !std::is_same_v().alignment), disabled_t>; - - bool prepend_comma = false; - auto append_to_stream = [&](auto &&... args) + static constexpr auto print = [](auto & stream, alignment_result const & result) { - ((stream << (prepend_comma ? std::string{", "} : std::string{})) << ... << std::forward(args)); - prepend_comma = true; - }; - - stream << '{'; - if constexpr (has_sequence1_id) - append_to_stream("sequence1 id: ", result.sequence1_id()); - if constexpr (has_sequence2_id) - append_to_stream("sequence2 id: ", result.sequence2_id()); - if constexpr (has_score) - append_to_stream("score: ", result.score()); - if constexpr (has_begin_positions) - append_to_stream("begin: (", result.sequence1_begin_position(), ",", result.sequence2_begin_position(), ")"); - if constexpr (has_end_positions) - append_to_stream("end: (", result.sequence1_end_position(), ",", result.sequence2_end_position(), ")"); - if constexpr (has_alignment) - append_to_stream("\nalignment:\n", result.alignment()); - stream << '}'; - + using alignment_result_t = alignment_result; + using disabled_t = std::nullopt_t *; + using result_data_t = + typename detail::alignment_result_value_type_accessor>::type; + + constexpr bool has_sequence1_id = + !std::is_same_v().sequence1_id), disabled_t>; + constexpr bool has_sequence2_id = + !std::is_same_v().sequence2_id), disabled_t>; + constexpr bool has_score = !std::is_same_v().score), disabled_t>; + constexpr bool has_end_positions = + !std::is_same_v().end_positions), disabled_t>; + constexpr bool has_begin_positions = + !std::is_same_v().begin_positions), disabled_t>; + constexpr bool has_alignment = !std::is_same_v().alignment), disabled_t>; + + bool prepend_comma = false; + auto append_to_stream = [&](auto &&... args) + { + ((stream << (prepend_comma ? std::string{", "} : std::string{})) + << ... << std::forward(args)); + prepend_comma = true; + }; + + stream << '{'; + if constexpr (has_sequence1_id) + append_to_stream("sequence1 id: ", result.sequence1_id()); + if constexpr (has_sequence2_id) + append_to_stream("sequence2 id: ", result.sequence2_id()); + if constexpr (has_score) + append_to_stream("score: ", result.score()); + if constexpr (has_begin_positions) + append_to_stream("begin: (", + result.sequence1_begin_position(), + ",", + result.sequence2_begin_position(), + ")"); + if constexpr (has_end_positions) + append_to_stream("end: (", result.sequence1_end_position(), ",", result.sequence2_end_position(), ")"); + if constexpr (has_alignment) + append_to_stream("\nalignment:\n", result.alignment()); + stream << '}'; }; }; #endif diff --git a/include/seqan3/alphabet/detail/debug_stream_alphabet.hpp b/include/seqan3/alphabet/detail/debug_stream_alphabet.hpp index 32a6268fdf..98198506e3 100644 --- a/include/seqan3/alphabet/detail/debug_stream_alphabet.hpp +++ b/include/seqan3/alphabet/detail/debug_stream_alphabet.hpp @@ -39,7 +39,7 @@ template requires alphabet struct alphabet_printer { - constexpr static auto print = [](auto & s, alphabet_t l) + static constexpr auto print = [](auto & s, alphabet_t l) { s << to_char(l); }; @@ -69,7 +69,7 @@ template requires std::same_as, mask> struct mask_printer { - constexpr static auto print = [](auto & s, alphabet_t const l) + static constexpr auto print = [](auto & s, alphabet_t const l) { s << (l == std::remove_cvref_t{} ? "UNMASKED" : "MASKED"); }; diff --git a/include/seqan3/core/debug_stream/debug_stream_type.hpp b/include/seqan3/core/debug_stream/debug_stream_type.hpp index 740fb7ff53..892ebfec6d 100644 --- a/include/seqan3/core/debug_stream/debug_stream_type.hpp +++ b/include/seqan3/core/debug_stream/debug_stream_type.hpp @@ -133,9 +133,12 @@ class debug_stream_type { using t_ = std::remove_cvref_t; - if constexpr(default_printer::is_printable) { + if constexpr (default_printer::is_printable) + { default_printer::print(s, v); - } else { + } + else + { std::string const msg = std::string{"debug_stream has no print overload for type: "} + typeid(v).name(); throw std::runtime_error{msg}; } @@ -171,10 +174,10 @@ class debug_stream_type } #else - template + template friend struct debug_stream_printer; - template + template friend struct std_printer; #endif @@ -216,14 +219,14 @@ class debug_stream_type #ifdef _LIBCPP_VERSION static_assert(std::same_as); #else -#if 0 +# if 0 //!\copybrief setf() debug_stream_type & operator<<(fmtflags const flag) { setf(flag); return *this; } -#endif +# endif //!\} #endif @@ -275,7 +278,9 @@ class debug_stream_type }; template - requires (std::is_same_v, int8_t> || std::is_same_v, uint8_t> || std::is_same_v, fmtflags2>) + requires (std::is_same_v, int8_t> + || std::is_same_v, uint8_t> + || std::is_same_v, fmtflags2>) struct debug_stream_printer { struct print_fn diff --git a/include/seqan3/core/debug_stream/default_printer.hpp b/include/seqan3/core/debug_stream/default_printer.hpp index 7c682e04e0..ba40a562e8 100644 --- a/include/seqan3/core/debug_stream/default_printer.hpp +++ b/include/seqan3/core/debug_stream/default_printer.hpp @@ -1,40 +1,78 @@ #pragma once #include -#include #include +#include #include namespace seqan3 { -struct no_printer_found{}; -template struct advanceable_alignment_coordinate_printer {}; -template struct alignment_matrix_printer {}; -template struct alignment_printer {}; -template struct alignment_result_printer {}; -template struct alphabet_printer {}; -template struct debug_stream_printer {}; -template struct input_range_printer {}; -template struct integer_sequence_printer {}; -template struct integral_printer {}; -template struct mask_printer {}; -template struct optional_printer {}; -template struct sequence_printer {}; -template struct std_printer {}; -template struct char_sequence_printer {}; -template struct trace_directions_printer {}; -template struct tuple_printer {}; +struct no_printer_found +{}; +template +struct advanceable_alignment_coordinate_printer +{}; +template +struct alignment_matrix_printer +{}; +template +struct alignment_printer +{}; +template +struct alignment_result_printer +{}; +template +struct alphabet_printer +{}; +template +struct debug_stream_printer +{}; +template +struct input_range_printer +{}; +template +struct integer_sequence_printer +{}; +template +struct integral_printer +{}; +template +struct mask_printer +{}; +template +struct optional_printer +{}; +template +struct sequence_printer +{}; +template +struct std_printer +{}; +template +struct char_sequence_printer +{}; +template +struct trace_directions_printer +{}; +template +struct tuple_printer +{}; template -concept printable = requires() { { printer_t::print }; }; +concept printable = requires () { + { + printer_t::print + }; + }; template - requires requires(std::ostream & cout, type_t value) - { - {cout << value}; - } + requires requires (std::ostream & cout, type_t value) { + { + cout << value + }; + } struct std_printer { static constexpr auto print = [](auto & s, auto && value) @@ -52,32 +90,32 @@ struct integral_printer // note that we assume here that we always can print all std::integral's, // but this is not correct since std::cout << char32_t{5}; is not possible. // since char32_t is also an alphabet, we avoid infinite recursion here. - if constexpr(printable>) + if constexpr (printable>) std_printer::print(s, value); else static_assert(std::same_as, "This type is not printable."); }; }; -template typename ...printers_t> +template