diff --git a/include/seqan3/utility/tuple/pod_tuple.hpp b/include/seqan3/utility/tuple/pod_tuple.hpp index 77ba0fe60a..ad9704a6d0 100644 --- a/include/seqan3/utility/tuple/pod_tuple.hpp +++ b/include/seqan3/utility/tuple/pod_tuple.hpp @@ -39,9 +39,7 @@ struct pod_tuple * actually enforces this on all types in the tuple (if you want to add non POD types, just use * std::tuple instead). * - * It (only) supports [aggregate initialization](https://en.cppreference.com/w/cpp/language/aggregate_initialization), - * i.e. you must use brace-initializiers and cannot - * use paranthesis. You can use seqan3::get or std::get and also + * You can use seqan3::get or std::get and also * [structured bindings](https://en.cppreference.com/w/cpp/language/declarations#Structured_binding_declaration) * to access the elements in the tuple. * @@ -57,6 +55,17 @@ struct pod_tuple type0 _head; //!\brief The rest of the elements defined as a "recursive member". pod_tuple _tail; + + constexpr pod_tuple() noexcept = default; //!< Defaulted. + constexpr pod_tuple(pod_tuple const &) noexcept = default; //!< Defaulted. + constexpr pod_tuple & operator=(pod_tuple const &) noexcept = default; //!< Defaulted. + constexpr pod_tuple(pod_tuple &&) noexcept = default; //!< Defaulted. + constexpr pod_tuple & operator=(pod_tuple &&) noexcept = default; //!< Defaulted. + constexpr ~pod_tuple() noexcept = default; //!< Defaulted. + + //!\brief Construct from arguments. + constexpr pod_tuple(type0 v0, types... args) noexcept : _head{v0}, _tail{args...} + {} //!\endcond /*!\name Comparison operators diff --git a/test/unit/utility/tuple/pod_tuple_test.cpp b/test/unit/utility/tuple/pod_tuple_test.cpp index 13d0dc7574..fff2f88ed2 100644 --- a/test/unit/utility/tuple/pod_tuple_test.cpp +++ b/test/unit/utility/tuple/pod_tuple_test.cpp @@ -9,59 +9,66 @@ #include +#include #include -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wmissing-braces" +using tuple_t = seqan3::pod_tuple; + +TEST(pod_tuple, concepts) +{ + EXPECT_TRUE(seqan3::trivial); + EXPECT_TRUE(seqan3::standard_layout); +} // default/zero construction -TEST(pod_tuple_ctr, ctr) +TEST(pod_tuple, ctr) { - [[maybe_unused]] seqan3::pod_tuple t1; + [[maybe_unused]] tuple_t t1; } // aggregate initialization -TEST(pod_tuple_aggr, aggr) +TEST(pod_tuple, aggr) { - [[maybe_unused]] seqan3::pod_tuple t1{4, 7l, 3.0f}; + [[maybe_unused]] tuple_t t1{4, 7l, 3.0f}; + [[maybe_unused]] tuple_t t2(4, 7l, 3.0f); } // zero initialization -TEST(pod_tuple_zro, zro) +TEST(pod_tuple, zro) { - seqan3::pod_tuple t1{0, 0, 0}; - seqan3::pod_tuple t2{}; + tuple_t t1{0, 0, 0}; + tuple_t t2{}; EXPECT_EQ(t1, t2); } // copy construction -TEST(pod_tuple_cp_ctr, cp_ctr) +TEST(pod_tuple, cp_ctr) { - seqan3::pod_tuple t1{4, 7l, 3.0f}; - seqan3::pod_tuple t2{t1}; - seqan3::pod_tuple t3(t1); + tuple_t t1{4, 7l, 3.0f}; + tuple_t t2{t1}; + tuple_t t3(t1); EXPECT_EQ(t1, t2); EXPECT_EQ(t2, t3); } // move construction -TEST(pod_tuple_mv_ctr, mv_ctr) +TEST(pod_tuple, mv_ctr) { - seqan3::pod_tuple t0{4, 7l, 3.0f}; - seqan3::pod_tuple t1{4, 7l, 3.0f}; - seqan3::pod_tuple t2{std::move(t1)}; + tuple_t t0{4, 7l, 3.0f}; + tuple_t t1{4, 7l, 3.0f}; + tuple_t t2{std::move(t1)}; EXPECT_EQ(t2, t0); - seqan3::pod_tuple t3(std::move(t2)); + tuple_t t3(std::move(t2)); EXPECT_EQ(t3, t0); } // copy assignment -TEST(pod_tuple_cp_assgn, cp_assgn) +TEST(pod_tuple, cp_assgn) { - seqan3::pod_tuple t1{4, 7l, 3.0f}; - seqan3::pod_tuple t2; - seqan3::pod_tuple t3; + tuple_t t1{4, 7l, 3.0f}; + tuple_t t2; + tuple_t t3; t2 = t1; t3 = t1; @@ -70,12 +77,12 @@ TEST(pod_tuple_cp_assgn, cp_assgn) } // move assignment -TEST(pod_tuple_mv_assgn, mv_assgn) +TEST(pod_tuple, mv_assgn) { - seqan3::pod_tuple t0{4, 7l, 3.0f}; - seqan3::pod_tuple t1{4, 7l, 3.0f}; - seqan3::pod_tuple t2; - seqan3::pod_tuple t3; + tuple_t t0{4, 7l, 3.0f}; + tuple_t t1{4, 7l, 3.0f}; + tuple_t t2; + tuple_t t3; t2 = std::move(t1); EXPECT_EQ(t2, t0); t3 = std::move(t2); @@ -83,12 +90,12 @@ TEST(pod_tuple_mv_assgn, mv_assgn) } // swap -TEST(pod_tuple_swap, swap) +TEST(pod_tuple, swap) { - seqan3::pod_tuple t0{4, 7l, 3.0f}; - seqan3::pod_tuple t1{4, 7l, 3.0f}; - seqan3::pod_tuple t2{}; - seqan3::pod_tuple t3{}; + tuple_t t0{4, 7l, 3.0f}; + tuple_t t1{4, 7l, 3.0f}; + tuple_t t2{}; + tuple_t t3{}; std::swap(t1, t2); EXPECT_EQ(t2, t0); @@ -96,9 +103,9 @@ TEST(pod_tuple_swap, swap) } // get<1> -TEST(pod_tuple_get_i, get_i) +TEST(pod_tuple, get_i) { - seqan3::pod_tuple t0{4, 7l, 3.0f}; + tuple_t t0{4, 7l, 3.0f}; static_assert(std::is_same_v(t0)), int &>); static_assert(std::is_same_v(t0)), long &>); @@ -111,7 +118,7 @@ TEST(pod_tuple_get_i, get_i) // std::get<1> TEST(pod_tuple, stdget_i) { - seqan3::pod_tuple t0{4, 7l, 3.0f}; + tuple_t t0{4, 7l, 3.0f}; static_assert(std::is_same_v(t0)), int &>); static_assert(std::is_same_v(t0)), long &>); @@ -122,9 +129,9 @@ TEST(pod_tuple, stdget_i) } // structured bindings -TEST(pod_tuple_struct_binding, struct_binding) +TEST(pod_tuple, struct_binding) { - seqan3::pod_tuple t0{4, 7l, 3.0f}; + tuple_t t0{4, 7l, 3.0f}; auto [i, l, f] = t0; EXPECT_EQ(i, 4); @@ -133,9 +140,9 @@ TEST(pod_tuple_struct_binding, struct_binding) } // get -TEST(pod_tuple_get_type, get_type) +TEST(pod_tuple, get_type) { - using pt = seqan3::pod_tuple; + using pt = tuple_t; using ptc = pt const; pt t0{4, 7l, 3.0f}; ptc t1{4, 7l, 3.0f}; @@ -174,9 +181,9 @@ TEST(pod_tuple_get_type, get_type) } // std::get -TEST(pod_tuple_get_type, stdget_type) +TEST(pod_tuple, stdget_type) { - using pt = seqan3::pod_tuple; + using pt = tuple_t; using ptc = pt const; pt t0{4, 7l, 3.0f}; ptc t1{4, 7l, 3.0f}; @@ -215,9 +222,9 @@ TEST(pod_tuple_get_type, stdget_type) } // std::tuple_element -TEST(pod_tuple_tuple_element, tuple_element) +TEST(pod_tuple, tuple_element) { - using pt = seqan3::pod_tuple; + using pt = tuple_t; static_assert(std::is_same_v, int>); static_assert(std::is_same_v, long>); @@ -226,7 +233,7 @@ TEST(pod_tuple_tuple_element, tuple_element) } // type deduction -TEST(pod_tuple_type_deduce, type_deduce) +TEST(pod_tuple, type_deduce) { seqan3::pod_tuple t0{4, 7l, 3.0f}; using pt = decltype(t0); @@ -237,11 +244,11 @@ TEST(pod_tuple_type_deduce, type_deduce) } // comparison operators -TEST(pod_tuple_cmp, cmp) +TEST(pod_tuple, cmp) { - seqan3::pod_tuple t0{4, 6l, 4.0f}; - seqan3::pod_tuple t1{4, 7l, 3.0f}; - seqan3::pod_tuple t2{4, 7l, 4.0f}; + tuple_t t0{4, 6l, 4.0f}; + tuple_t t1{4, 7l, 3.0f}; + tuple_t t2{4, 7l, 4.0f}; EXPECT_LT(t0, t1); EXPECT_LE(t0, t1); @@ -251,5 +258,3 @@ TEST(pod_tuple_cmp, cmp) EXPECT_GE(t2, t1); EXPECT_GT(t2, t1); } - -#pragma GCC diagnostic pop