From 4053bdd9ce78c357ddd333104fe8cc802d681313 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 11 Sep 2024 18:03:03 +0900 Subject: [PATCH 1/2] Removed unnecessary SFINAE --- flat_map/__concepts.hpp | 4 +--- flat_map/__flat_tree.hpp | 26 ++++---------------------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/flat_map/__concepts.hpp b/flat_map/__concepts.hpp index 86a715b..c0d01f2 100644 --- a/flat_map/__concepts.hpp +++ b/flat_map/__concepts.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Kohei Takahashi +// Copyright (c) 2021,2024 Kohei Takahashi // This software is released under the MIT License, see LICENSE. #pragma once @@ -26,7 +26,5 @@ template inline constexpr bool Name = Name ## _body::chec } // namespace flat_map::detail FLAT_MAP_DEFINE_CONCEPT(Reservable, T, (T c, size_t n), c.reserve(n)); -FLAT_MAP_DEFINE_CONCEPT(HasCapacity, T, (T c), c.capacity()); -FLAT_MAP_DEFINE_CONCEPT(Shrinkable, T, (T c), c.shrink_to_fit()); } // namespace flat_map::concepts diff --git a/flat_map/__flat_tree.hpp b/flat_map/__flat_tree.hpp index 9a68b27..553e840 100644 --- a/flat_map/__flat_tree.hpp +++ b/flat_map/__flat_tree.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Kohei Takahashi +// Copyright (c) 2021,2024 Kohei Takahashi // This software is released under the MIT License, see LICENSE. #pragma once @@ -173,29 +173,11 @@ class _flat_tree_base : private detail::comparator_store size_type size() const noexcept { return _container.size(); } size_type max_size() const noexcept { return _container.max_size(); } // extension - template - std::enable_if_t> - reserve(size_type new_cap) - { - static_assert(sizeof...(ShouldBeEmpty) == 0); - _container.reserve(new_cap); - } + void reserve(size_type new_cap) { _container.reserve(new_cap); } // extension - template - std::enable_if_t, size_type> - capacity() const noexcept - { - static_assert(sizeof...(ShouldBeEmpty) == 0); - return _container.capacity(); - } + size_type capacity() const noexcept { return _container.capacity(); } // extension - template - std::enable_if_t> - shrink_to_fit() - { - static_assert(sizeof...(ShouldBeEmpty) == 0); - _container.shrink_to_fit(); - } + void shrink_to_fit() { _container.shrink_to_fit(); } void clear() noexcept { return _container.clear(); } template From e0c05aa0dd6eb2ce9ddf3971add6ab67a6100ffc Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 11 Sep 2024 18:06:05 +0900 Subject: [PATCH 2/2] doc: Doc update --- docs/flat_map.md | 6 +++--- docs/flat_multimap.md | 6 +++--- docs/flat_multiset.md | 6 +++--- docs/flat_set.md | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/flat_map.md b/docs/flat_map.md index 57d1915..b87a2a6 100644 --- a/docs/flat_map.md +++ b/docs/flat_map.md @@ -298,7 +298,7 @@ size_type max_size() const noexcept; void reserve(size_type new_cap); ``` -This function is provided only if `Container::reserve()` is provided. +Available only if `Container::reserve()` is provided. **Postcondition** @@ -310,7 +310,7 @@ This function is provided only if `Container::reserve()` is provided. size_type capacity() const noexcept; ``` -This function is provided only if `Container::capacity()` is provided. +Available only if `Container::capacity()` is provided. ### shrink_to_fit @@ -318,7 +318,7 @@ This function is provided only if `Container::capacity()` is provided. void shrink_to_fit(); ``` -This function is provided only if `Container::shrink_to_fit()` is provided. +This Available if `Container::shrink_to_fit()` is provided. **Postcondition** diff --git a/docs/flat_multimap.md b/docs/flat_multimap.md index 171062f..96e483e 100644 --- a/docs/flat_multimap.md +++ b/docs/flat_multimap.md @@ -263,7 +263,7 @@ size_type max_size() const noexcept; void reserve(size_type new_cap); ``` -This function is provided only if `Container::reserve()` is provided. +Available only if `Container::reserve()` is provided. **Postcondition** @@ -275,7 +275,7 @@ This function is provided only if `Container::reserve()` is provided. size_type capacity() const noexcept; ``` -This function is provided only if `Container::capacity()` is provided. +Available only if `Container::capacity()` is provided. ### shrink_to_fit @@ -283,7 +283,7 @@ This function is provided only if `Container::capacity()` is provided. void shrink_to_fit(); ``` -This function is provided only if `Container::shrink_to_fit()` is provided. +Available only if `Container::shrink_to_fit()` is provided. **Postcondition** diff --git a/docs/flat_multiset.md b/docs/flat_multiset.md index 50c0619..b3e8feb 100644 --- a/docs/flat_multiset.md +++ b/docs/flat_multiset.md @@ -245,7 +245,7 @@ size_type max_size() const noexcept; void reserve(size_type new_cap); ``` -This function is provided only if `Container::reserve()` is provided. +Available only if `Container::reserve()` is provided. **Postcondition** @@ -257,7 +257,7 @@ This function is provided only if `Container::reserve()` is provided. size_type capacity() const noexcept; ``` -This function is provided only if `Container::capacity()` is provided. +Available only if `Container::capacity()` is provided. ### shrink_to_fit @@ -265,7 +265,7 @@ This function is provided only if `Container::capacity()` is provided. void shrink_to_fit(); ``` -This function is provided only if `Container::shrink_to_fit()` is provided. +Available only if `Container::shrink_to_fit()` is provided. **Postcondition** diff --git a/docs/flat_set.md b/docs/flat_set.md index 04deee7..994f504 100644 --- a/docs/flat_set.md +++ b/docs/flat_set.md @@ -245,7 +245,7 @@ size_type max_size() const noexcept; void reserve(size_type new_cap); ``` -This function is provided only if `Container::reserve()` is provided. +Available only if `Container::reserve()` is provided. **Postcondition** @@ -257,7 +257,7 @@ This function is provided only if `Container::reserve()` is provided. size_type capacity() const noexcept; ``` -This function is provided only if `Container::capacity()` is provided. +Available only if `Container::capacity()` is provided. ### shrink_to_fit @@ -265,7 +265,7 @@ This function is provided only if `Container::capacity()` is provided. void shrink_to_fit(); ``` -This function is provided only if `Container::shrink_to_fit()` is provided. +Available only if `Container::shrink_to_fit()` is provided. **Postcondition**