add empty,size,max_size,capacity,clear noexcept specs

This commit is contained in:
2019-05-12 17:36:25 +07:00
parent 05934cac38
commit 4e5e7e8485
8 changed files with 88 additions and 20 deletions

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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>;

View File

@@ -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>;

View File

@@ -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>;

View File

@@ -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>;