diff --git a/docs/tied_sequence.md b/docs/tied_sequence.md index 0ef59fe..ab2a6a7 100644 --- a/docs/tied_sequence.md +++ b/docs/tied_sequence.md @@ -303,25 +303,29 @@ constexpr size_t size() const noexcept; constexpr size_t max_size() const noexcept; ``` - + +Available only if every sequences provide `shrink_to_fit()`. ## Modifiers diff --git a/flat_map/tied_sequence.hpp b/flat_map/tied_sequence.hpp index 9e72d52..12f30ca 100644 --- a/flat_map/tied_sequence.hpp +++ b/flat_map/tied_sequence.hpp @@ -471,10 +471,7 @@ class tied_sequence constexpr reference back() { return *std::prev(end()); } constexpr const_reference back() const { return *std::prev(end()); } - constexpr pointer data() noexcept((static_cast(sizeof(std::declval().data())), ..., true)) - { - return detail::tuple_transform([](auto& c) { return c.data(); }, _seq); - } + constexpr pointer data() noexcept { return detail::tuple_transform([](auto& c) { return c.data(); }, _seq); } constexpr const_pointer data() const noexcept(noexcept(std::declval()->data())) { return const_cast(this)->data(); } @@ -497,13 +494,11 @@ class tied_sequence public: constexpr size_t max_size() const noexcept { return detail::tuple_reduction([](auto&&... c) { return std::min({c.max_size()...}); }, _seq); } -#if 0 // TODO constexpr void reserve(size_type new_cap) { detail::tuple_reduction([new_cap](auto&... c) { (c.reserve(new_cap), ...); }, _seq); } constexpr size_type capacity() const noexcept { return detail::tuple_reduction([](auto&... c) { return std::min({c.capacity()...}); }, _seq); } - constexpr void shrink_to_fit() noexcept { detail::tuple_reduction([](auto&... c) { (c.shrink_to_fit(), ...); }, _seq); } -#endif + constexpr void shrink_to_fit() { detail::tuple_reduction([](auto&... c) { (c.shrink_to_fit(), ...); }, _seq); } constexpr void clear() noexcept { detail::tuple_reduction([](auto&... c) { (c.clear(), ...); }, _seq); } diff --git a/test/tied_sequence.cpp b/test/tied_sequence.cpp index a148618..4d65bd8 100644 --- a/test/tied_sequence.cpp +++ b/test/tied_sequence.cpp @@ -650,14 +650,13 @@ TEST_CASE("capacity", "[capacity]") REQUIRE(ts.max_size() > 0); } -#if 0 // TODO SECTION("reserve/capacity") { flat_map::tied_sequence, std::vector> ts; REQUIRE(ts.capacity() == 0); REQUIRE(ts.size() == 0); ts.reserve(10); - REQUIRE(ts.capacity() == 10); + REQUIRE(ts.capacity() >= 10); REQUIRE(ts.size() == 0); } @@ -667,14 +666,13 @@ TEST_CASE("capacity", "[capacity]") ts.reserve(10); ts.push_back({0, 1}); - REQUIRE(ts.capacity() == 10); + REQUIRE(ts.capacity() >= 10); REQUIRE(ts.size() == 1); ts.shrink_to_fit(); REQUIRE(ts.capacity() == 1); REQUIRE(ts.size() == 1); } -#endif SECTION("clear") {