Skip to content

Commit

Permalink
Merge pull request #26 from Flast/unnnecessary-sfinae
Browse files Browse the repository at this point in the history
Removed unnecessary SFINAE
  • Loading branch information
Flast authored Sep 14, 2024
2 parents ef17523 + e0c05aa commit e0acc2c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 37 deletions.
6 changes: 3 additions & 3 deletions docs/flat_map.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand All @@ -310,15 +310,15 @@ 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

```cpp
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**

Expand Down
6 changes: 3 additions & 3 deletions docs/flat_multimap.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand All @@ -275,15 +275,15 @@ 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

```cpp
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**

Expand Down
6 changes: 3 additions & 3 deletions docs/flat_multiset.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand All @@ -257,15 +257,15 @@ 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

```cpp
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**

Expand Down
6 changes: 3 additions & 3 deletions docs/flat_set.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand All @@ -257,15 +257,15 @@ 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

```cpp
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**

Expand Down
4 changes: 1 addition & 3 deletions flat_map/__concepts.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -26,7 +26,5 @@ template <typename T> inline constexpr bool Name = Name ## _body<T Params>::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
26 changes: 4 additions & 22 deletions flat_map/__flat_tree.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -173,29 +173,11 @@ class _flat_tree_base : private detail::comparator_store<Compare>
size_type size() const noexcept { return _container.size(); }
size_type max_size() const noexcept { return _container.max_size(); }
// extension
template <typename... ShouldBeEmpty, typename Dummy = Container>
std::enable_if_t<concepts::Reservable<Dummy>>
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 <typename... ShouldBeEmpty, typename Dummy = Container>
std::enable_if_t<concepts::HasCapacity<Dummy>, size_type>
capacity() const noexcept
{
static_assert(sizeof...(ShouldBeEmpty) == 0);
return _container.capacity();
}
size_type capacity() const noexcept { return _container.capacity(); }
// extension
template <typename... ShouldBeEmpty, typename Dummy = Container>
std::enable_if_t<concepts::Shrinkable<Dummy>>
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 <typename K>
Expand Down

0 comments on commit e0acc2c

Please sign in to comment.