mirror of
https://github.com/BlackMATov/flat.hpp.git
synced 2025-12-13 01:36:27 +07:00
add empty,size,max_size,capacity,clear noexcept specs
This commit is contained in:
@@ -197,19 +197,27 @@ namespace flat_hpp
|
||||
const_reverse_iterator rend() const noexcept { return data_.rend(); }
|
||||
const_reverse_iterator crend() const noexcept { return data_.crend(); }
|
||||
|
||||
bool empty() const noexcept {
|
||||
bool empty() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().empty()))
|
||||
{
|
||||
return data_.empty();
|
||||
}
|
||||
|
||||
size_type size() const noexcept {
|
||||
size_type size() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().size()))
|
||||
{
|
||||
return data_.size();
|
||||
}
|
||||
|
||||
size_type max_size() const noexcept {
|
||||
size_type max_size() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().max_size()))
|
||||
{
|
||||
return data_.max_size();
|
||||
}
|
||||
|
||||
size_type capacity() const noexcept {
|
||||
size_type capacity() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().capacity()))
|
||||
{
|
||||
return data_.capacity();
|
||||
}
|
||||
|
||||
@@ -300,7 +308,9 @@ namespace flat_hpp
|
||||
return insert(hint, value_type(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
void clear() noexcept {
|
||||
void clear()
|
||||
noexcept(noexcept(std::declval<container_type&>().clear()))
|
||||
{
|
||||
data_.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -197,19 +197,27 @@ namespace flat_hpp
|
||||
const_reverse_iterator rend() const noexcept { return data_.rend(); }
|
||||
const_reverse_iterator crend() const noexcept { return data_.crend(); }
|
||||
|
||||
bool empty() const noexcept {
|
||||
bool empty() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().empty()))
|
||||
{
|
||||
return data_.empty();
|
||||
}
|
||||
|
||||
size_type size() const noexcept {
|
||||
size_type size() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().size()))
|
||||
{
|
||||
return data_.size();
|
||||
}
|
||||
|
||||
size_type max_size() const noexcept {
|
||||
size_type max_size() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().max_size()))
|
||||
{
|
||||
return data_.max_size();
|
||||
}
|
||||
|
||||
size_type capacity() const noexcept {
|
||||
size_type capacity() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().capacity()))
|
||||
{
|
||||
return data_.capacity();
|
||||
}
|
||||
|
||||
@@ -296,7 +304,9 @@ namespace flat_hpp
|
||||
return insert(hint, value_type(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
void clear() noexcept {
|
||||
void clear()
|
||||
noexcept(noexcept(std::declval<container_type&>().clear()))
|
||||
{
|
||||
data_.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -142,19 +142,27 @@ namespace flat_hpp
|
||||
const_reverse_iterator rend() const noexcept { return data_.rend(); }
|
||||
const_reverse_iterator crend() const noexcept { return data_.crend(); }
|
||||
|
||||
bool empty() const noexcept {
|
||||
bool empty() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().empty()))
|
||||
{
|
||||
return data_.empty();
|
||||
}
|
||||
|
||||
size_type size() const noexcept {
|
||||
size_type size() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().size()))
|
||||
{
|
||||
return data_.size();
|
||||
}
|
||||
|
||||
size_type max_size() const noexcept {
|
||||
size_type max_size() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().max_size()))
|
||||
{
|
||||
return data_.max_size();
|
||||
}
|
||||
|
||||
size_type capacity() const noexcept {
|
||||
size_type capacity() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().capacity()))
|
||||
{
|
||||
return data_.capacity();
|
||||
}
|
||||
|
||||
@@ -211,7 +219,9 @@ namespace flat_hpp
|
||||
return insert(hint, value_type(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
void clear() noexcept {
|
||||
void clear()
|
||||
noexcept(noexcept(std::declval<container_type&>().clear()))
|
||||
{
|
||||
data_.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -142,19 +142,27 @@ namespace flat_hpp
|
||||
const_reverse_iterator rend() const noexcept { return data_.rend(); }
|
||||
const_reverse_iterator crend() const noexcept { return data_.crend(); }
|
||||
|
||||
bool empty() const noexcept {
|
||||
bool empty() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().empty()))
|
||||
{
|
||||
return data_.empty();
|
||||
}
|
||||
|
||||
size_type size() const noexcept {
|
||||
size_type size() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().size()))
|
||||
{
|
||||
return data_.size();
|
||||
}
|
||||
|
||||
size_type max_size() const noexcept {
|
||||
size_type max_size() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().max_size()))
|
||||
{
|
||||
return data_.max_size();
|
||||
}
|
||||
|
||||
size_type capacity() const noexcept {
|
||||
size_type capacity() const
|
||||
noexcept(noexcept(std::declval<const container_type&>().capacity()))
|
||||
{
|
||||
return data_.capacity();
|
||||
}
|
||||
|
||||
@@ -215,7 +223,9 @@ namespace flat_hpp
|
||||
return insert(hint, value_type(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
void clear() noexcept {
|
||||
void clear()
|
||||
noexcept(noexcept(std::declval<container_type&>().clear()))
|
||||
{
|
||||
data_.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,13 @@ TEST_CASE("flat_map") {
|
||||
STATIC_REQUIRE(std::is_nothrow_swappable_v<map_t>);
|
||||
STATIC_REQUIRE(std::is_nothrow_swappable_v<map2_t>);
|
||||
STATIC_REQUIRE(!std::is_nothrow_swappable_v<map3_t>);
|
||||
|
||||
STATIC_REQUIRE(noexcept(std::declval<map_t&>().empty()));
|
||||
STATIC_REQUIRE(noexcept(std::declval<map_t&>().size()));
|
||||
STATIC_REQUIRE(noexcept(std::declval<map_t&>().max_size()));
|
||||
STATIC_REQUIRE(noexcept(std::declval<map_t&>().capacity()));
|
||||
|
||||
STATIC_REQUIRE(noexcept(std::declval<map_t&>().clear()));
|
||||
}
|
||||
SECTION("types") {
|
||||
using map_t = flat_map<int, unsigned>;
|
||||
|
||||
@@ -74,6 +74,13 @@ TEST_CASE("flat_multimap") {
|
||||
STATIC_REQUIRE(std::is_nothrow_swappable_v<map_t>);
|
||||
STATIC_REQUIRE(std::is_nothrow_swappable_v<map2_t>);
|
||||
STATIC_REQUIRE(!std::is_nothrow_swappable_v<map3_t>);
|
||||
|
||||
STATIC_REQUIRE(noexcept(std::declval<map_t&>().empty()));
|
||||
STATIC_REQUIRE(noexcept(std::declval<map_t&>().size()));
|
||||
STATIC_REQUIRE(noexcept(std::declval<map_t&>().max_size()));
|
||||
STATIC_REQUIRE(noexcept(std::declval<map_t&>().capacity()));
|
||||
|
||||
STATIC_REQUIRE(noexcept(std::declval<map_t&>().clear()));
|
||||
}
|
||||
SECTION("types") {
|
||||
using map_t = flat_multimap<int, unsigned>;
|
||||
|
||||
@@ -74,6 +74,13 @@ TEST_CASE("flat_multiset") {
|
||||
STATIC_REQUIRE(std::is_nothrow_swappable_v<set_t>);
|
||||
STATIC_REQUIRE(std::is_nothrow_swappable_v<set2_t>);
|
||||
STATIC_REQUIRE(!std::is_nothrow_swappable_v<set3_t>);
|
||||
|
||||
STATIC_REQUIRE(noexcept(std::declval<set_t&>().empty()));
|
||||
STATIC_REQUIRE(noexcept(std::declval<set_t&>().size()));
|
||||
STATIC_REQUIRE(noexcept(std::declval<set_t&>().max_size()));
|
||||
STATIC_REQUIRE(noexcept(std::declval<set_t&>().capacity()));
|
||||
|
||||
STATIC_REQUIRE(noexcept(std::declval<set_t&>().clear()));
|
||||
}
|
||||
SECTION("types") {
|
||||
using set_t = flat_multiset<int>;
|
||||
|
||||
@@ -74,6 +74,13 @@ TEST_CASE("flat_set") {
|
||||
STATIC_REQUIRE(std::is_nothrow_swappable_v<set_t>);
|
||||
STATIC_REQUIRE(std::is_nothrow_swappable_v<set2_t>);
|
||||
STATIC_REQUIRE(!std::is_nothrow_swappable_v<set3_t>);
|
||||
|
||||
STATIC_REQUIRE(noexcept(std::declval<set_t&>().empty()));
|
||||
STATIC_REQUIRE(noexcept(std::declval<set_t&>().size()));
|
||||
STATIC_REQUIRE(noexcept(std::declval<set_t&>().max_size()));
|
||||
STATIC_REQUIRE(noexcept(std::declval<set_t&>().capacity()));
|
||||
|
||||
STATIC_REQUIRE(noexcept(std::declval<set_t&>().clear()));
|
||||
}
|
||||
SECTION("types") {
|
||||
using set_t = flat_set<int>;
|
||||
|
||||
Reference in New Issue
Block a user