add noexcept to iterator getters

This commit is contained in:
2019-05-12 19:10:47 +07:00
parent 4e5e7e8485
commit ea8b1efe18
8 changed files with 316 additions and 104 deletions

View File

@@ -181,43 +181,83 @@ namespace flat_hpp
return *this; return *this;
} }
iterator begin() noexcept { return data_.begin(); } iterator begin()
const_iterator begin() const noexcept { return data_.begin(); } noexcept(noexcept(std::declval<container_type&>().begin())) {
const_iterator cbegin() const noexcept { return data_.cbegin(); } return data_.begin();
}
iterator end() noexcept { return data_.end(); } const_iterator begin() const
const_iterator end() const noexcept { return data_.end(); } noexcept(noexcept(std::declval<const container_type&>().begin())) {
const_iterator cend() const noexcept { return data_.cend(); } return data_.begin();
}
reverse_iterator rbegin() noexcept { return data_.rbegin(); } const_iterator cbegin() const
const_reverse_iterator rbegin() const noexcept { return data_.rbegin(); } noexcept(noexcept(std::declval<const container_type&>().cbegin())) {
const_reverse_iterator crbegin() const noexcept { return data_.crbegin(); } return data_.cbegin();
}
reverse_iterator rend() noexcept { return data_.rend(); } iterator end()
const_reverse_iterator rend() const noexcept { return data_.rend(); } noexcept(noexcept(std::declval<container_type&>().end())) {
const_reverse_iterator crend() const noexcept { return data_.crend(); } return data_.end();
}
const_iterator end() const
noexcept(noexcept(std::declval<const container_type&>().end())) {
return data_.end();
}
const_iterator cend() const
noexcept(noexcept(std::declval<const container_type&>().cend())) {
return data_.cend();
}
reverse_iterator rbegin()
noexcept(noexcept(std::declval<container_type&>().rbegin())) {
return data_.rbegin();
}
const_reverse_iterator rbegin() const
noexcept(noexcept(std::declval<const container_type&>().rbegin())) {
return data_.rbegin();
}
const_reverse_iterator crbegin() const
noexcept(noexcept(std::declval<const container_type&>().crbegin())) {
return data_.crbegin();
}
reverse_iterator rend()
noexcept(noexcept(std::declval<container_type&>().rend())) {
return data_.rend();
}
const_reverse_iterator rend() const
noexcept(noexcept(std::declval<const container_type&>().rend())) {
return data_.rend();
}
const_reverse_iterator crend() const
noexcept(noexcept(std::declval<const container_type&>().crend())) {
return data_.crend();
}
bool empty() const bool empty() const
noexcept(noexcept(std::declval<const container_type&>().empty())) noexcept(noexcept(std::declval<const container_type&>().empty())) {
{
return data_.empty(); return data_.empty();
} }
size_type size() const size_type size() const
noexcept(noexcept(std::declval<const container_type&>().size())) noexcept(noexcept(std::declval<const container_type&>().size())) {
{
return data_.size(); return data_.size();
} }
size_type max_size() const size_type max_size() const
noexcept(noexcept(std::declval<const container_type&>().max_size())) noexcept(noexcept(std::declval<const container_type&>().max_size())) {
{
return data_.max_size(); return data_.max_size();
} }
size_type capacity() const size_type capacity() const
noexcept(noexcept(std::declval<const container_type&>().capacity())) noexcept(noexcept(std::declval<const container_type&>().capacity())) {
{
return data_.capacity(); return data_.capacity();
} }
@@ -309,8 +349,7 @@ namespace flat_hpp
} }
void clear() void clear()
noexcept(noexcept(std::declval<container_type&>().clear())) noexcept(noexcept(std::declval<container_type&>().clear())) {
{
data_.clear(); data_.clear();
} }

View File

@@ -181,43 +181,83 @@ namespace flat_hpp
return *this; return *this;
} }
iterator begin() noexcept { return data_.begin(); } iterator begin()
const_iterator begin() const noexcept { return data_.begin(); } noexcept(noexcept(std::declval<container_type&>().begin())) {
const_iterator cbegin() const noexcept { return data_.cbegin(); } return data_.begin();
}
iterator end() noexcept { return data_.end(); } const_iterator begin() const
const_iterator end() const noexcept { return data_.end(); } noexcept(noexcept(std::declval<const container_type&>().begin())) {
const_iterator cend() const noexcept { return data_.cend(); } return data_.begin();
}
reverse_iterator rbegin() noexcept { return data_.rbegin(); } const_iterator cbegin() const
const_reverse_iterator rbegin() const noexcept { return data_.rbegin(); } noexcept(noexcept(std::declval<const container_type&>().cbegin())) {
const_reverse_iterator crbegin() const noexcept { return data_.crbegin(); } return data_.cbegin();
}
reverse_iterator rend() noexcept { return data_.rend(); } iterator end()
const_reverse_iterator rend() const noexcept { return data_.rend(); } noexcept(noexcept(std::declval<container_type&>().end())) {
const_reverse_iterator crend() const noexcept { return data_.crend(); } return data_.end();
}
const_iterator end() const
noexcept(noexcept(std::declval<const container_type&>().end())) {
return data_.end();
}
const_iterator cend() const
noexcept(noexcept(std::declval<const container_type&>().cend())) {
return data_.cend();
}
reverse_iterator rbegin()
noexcept(noexcept(std::declval<container_type&>().rbegin())) {
return data_.rbegin();
}
const_reverse_iterator rbegin() const
noexcept(noexcept(std::declval<const container_type&>().rbegin())) {
return data_.rbegin();
}
const_reverse_iterator crbegin() const
noexcept(noexcept(std::declval<const container_type&>().crbegin())) {
return data_.crbegin();
}
reverse_iterator rend()
noexcept(noexcept(std::declval<container_type&>().rend())) {
return data_.rend();
}
const_reverse_iterator rend() const
noexcept(noexcept(std::declval<const container_type&>().rend())) {
return data_.rend();
}
const_reverse_iterator crend() const
noexcept(noexcept(std::declval<const container_type&>().crend())) {
return data_.crend();
}
bool empty() const bool empty() const
noexcept(noexcept(std::declval<const container_type&>().empty())) noexcept(noexcept(std::declval<const container_type&>().empty())) {
{
return data_.empty(); return data_.empty();
} }
size_type size() const size_type size() const
noexcept(noexcept(std::declval<const container_type&>().size())) noexcept(noexcept(std::declval<const container_type&>().size())) {
{
return data_.size(); return data_.size();
} }
size_type max_size() const size_type max_size() const
noexcept(noexcept(std::declval<const container_type&>().max_size())) noexcept(noexcept(std::declval<const container_type&>().max_size())) {
{
return data_.max_size(); return data_.max_size();
} }
size_type capacity() const size_type capacity() const
noexcept(noexcept(std::declval<const container_type&>().capacity())) noexcept(noexcept(std::declval<const container_type&>().capacity())) {
{
return data_.capacity(); return data_.capacity();
} }
@@ -305,8 +345,7 @@ namespace flat_hpp
} }
void clear() void clear()
noexcept(noexcept(std::declval<container_type&>().clear())) noexcept(noexcept(std::declval<container_type&>().clear())) {
{
data_.clear(); data_.clear();
} }

View File

@@ -126,43 +126,83 @@ namespace flat_hpp
return *this; return *this;
} }
iterator begin() noexcept { return data_.begin(); } iterator begin()
const_iterator begin() const noexcept { return data_.begin(); } noexcept(noexcept(std::declval<container_type&>().begin())) {
const_iterator cbegin() const noexcept { return data_.cbegin(); } return data_.begin();
}
iterator end() noexcept { return data_.end(); } const_iterator begin() const
const_iterator end() const noexcept { return data_.end(); } noexcept(noexcept(std::declval<const container_type&>().begin())) {
const_iterator cend() const noexcept { return data_.cend(); } return data_.begin();
}
reverse_iterator rbegin() noexcept { return data_.rbegin(); } const_iterator cbegin() const
const_reverse_iterator rbegin() const noexcept { return data_.rbegin(); } noexcept(noexcept(std::declval<const container_type&>().cbegin())) {
const_reverse_iterator crbegin() const noexcept { return data_.crbegin(); } return data_.cbegin();
}
reverse_iterator rend() noexcept { return data_.rend(); } iterator end()
const_reverse_iterator rend() const noexcept { return data_.rend(); } noexcept(noexcept(std::declval<container_type&>().end())) {
const_reverse_iterator crend() const noexcept { return data_.crend(); } return data_.end();
}
const_iterator end() const
noexcept(noexcept(std::declval<const container_type&>().end())) {
return data_.end();
}
const_iterator cend() const
noexcept(noexcept(std::declval<const container_type&>().cend())) {
return data_.cend();
}
reverse_iterator rbegin()
noexcept(noexcept(std::declval<container_type&>().rbegin())) {
return data_.rbegin();
}
const_reverse_iterator rbegin() const
noexcept(noexcept(std::declval<const container_type&>().rbegin())) {
return data_.rbegin();
}
const_reverse_iterator crbegin() const
noexcept(noexcept(std::declval<const container_type&>().crbegin())) {
return data_.crbegin();
}
reverse_iterator rend()
noexcept(noexcept(std::declval<container_type&>().rend())) {
return data_.rend();
}
const_reverse_iterator rend() const
noexcept(noexcept(std::declval<const container_type&>().rend())) {
return data_.rend();
}
const_reverse_iterator crend() const
noexcept(noexcept(std::declval<const container_type&>().crend())) {
return data_.crend();
}
bool empty() const bool empty() const
noexcept(noexcept(std::declval<const container_type&>().empty())) noexcept(noexcept(std::declval<const container_type&>().empty())) {
{
return data_.empty(); return data_.empty();
} }
size_type size() const size_type size() const
noexcept(noexcept(std::declval<const container_type&>().size())) noexcept(noexcept(std::declval<const container_type&>().size())) {
{
return data_.size(); return data_.size();
} }
size_type max_size() const size_type max_size() const
noexcept(noexcept(std::declval<const container_type&>().max_size())) noexcept(noexcept(std::declval<const container_type&>().max_size())) {
{
return data_.max_size(); return data_.max_size();
} }
size_type capacity() const size_type capacity() const
noexcept(noexcept(std::declval<const container_type&>().capacity())) noexcept(noexcept(std::declval<const container_type&>().capacity())) {
{
return data_.capacity(); return data_.capacity();
} }
@@ -220,8 +260,7 @@ namespace flat_hpp
} }
void clear() void clear()
noexcept(noexcept(std::declval<container_type&>().clear())) noexcept(noexcept(std::declval<container_type&>().clear())) {
{
data_.clear(); data_.clear();
} }

View File

@@ -126,43 +126,83 @@ namespace flat_hpp
return *this; return *this;
} }
iterator begin() noexcept { return data_.begin(); } iterator begin()
const_iterator begin() const noexcept { return data_.begin(); } noexcept(noexcept(std::declval<container_type&>().begin())) {
const_iterator cbegin() const noexcept { return data_.cbegin(); } return data_.begin();
}
iterator end() noexcept { return data_.end(); } const_iterator begin() const
const_iterator end() const noexcept { return data_.end(); } noexcept(noexcept(std::declval<const container_type&>().begin())) {
const_iterator cend() const noexcept { return data_.cend(); } return data_.begin();
}
reverse_iterator rbegin() noexcept { return data_.rbegin(); } const_iterator cbegin() const
const_reverse_iterator rbegin() const noexcept { return data_.rbegin(); } noexcept(noexcept(std::declval<const container_type&>().cbegin())) {
const_reverse_iterator crbegin() const noexcept { return data_.crbegin(); } return data_.cbegin();
}
reverse_iterator rend() noexcept { return data_.rend(); } iterator end()
const_reverse_iterator rend() const noexcept { return data_.rend(); } noexcept(noexcept(std::declval<container_type&>().end())) {
const_reverse_iterator crend() const noexcept { return data_.crend(); } return data_.end();
}
const_iterator end() const
noexcept(noexcept(std::declval<const container_type&>().end())) {
return data_.end();
}
const_iterator cend() const
noexcept(noexcept(std::declval<const container_type&>().cend())) {
return data_.cend();
}
reverse_iterator rbegin()
noexcept(noexcept(std::declval<container_type&>().rbegin())) {
return data_.rbegin();
}
const_reverse_iterator rbegin() const
noexcept(noexcept(std::declval<const container_type&>().rbegin())) {
return data_.rbegin();
}
const_reverse_iterator crbegin() const
noexcept(noexcept(std::declval<const container_type&>().crbegin())) {
return data_.crbegin();
}
reverse_iterator rend()
noexcept(noexcept(std::declval<container_type&>().rend())) {
return data_.rend();
}
const_reverse_iterator rend() const
noexcept(noexcept(std::declval<const container_type&>().rend())) {
return data_.rend();
}
const_reverse_iterator crend() const
noexcept(noexcept(std::declval<const container_type&>().crend())) {
return data_.crend();
}
bool empty() const bool empty() const
noexcept(noexcept(std::declval<const container_type&>().empty())) noexcept(noexcept(std::declval<const container_type&>().empty())) {
{
return data_.empty(); return data_.empty();
} }
size_type size() const size_type size() const
noexcept(noexcept(std::declval<const container_type&>().size())) noexcept(noexcept(std::declval<const container_type&>().size())) {
{
return data_.size(); return data_.size();
} }
size_type max_size() const size_type max_size() const
noexcept(noexcept(std::declval<const container_type&>().max_size())) noexcept(noexcept(std::declval<const container_type&>().max_size())) {
{
return data_.max_size(); return data_.max_size();
} }
size_type capacity() const size_type capacity() const
noexcept(noexcept(std::declval<const container_type&>().capacity())) noexcept(noexcept(std::declval<const container_type&>().capacity())) {
{
return data_.capacity(); return data_.capacity();
} }
@@ -224,8 +264,7 @@ namespace flat_hpp
} }
void clear() void clear()
noexcept(noexcept(std::declval<container_type&>().clear())) noexcept(noexcept(std::declval<container_type&>().clear())) {
{
data_.clear(); data_.clear();
} }

View File

@@ -75,10 +75,24 @@ TEST_CASE("flat_map") {
STATIC_REQUIRE(std::is_nothrow_swappable_v<map2_t>); STATIC_REQUIRE(std::is_nothrow_swappable_v<map2_t>);
STATIC_REQUIRE(!std::is_nothrow_swappable_v<map3_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&>().begin()));
STATIC_REQUIRE(noexcept(std::declval<map_t&>().size())); STATIC_REQUIRE(noexcept(std::declval<const map_t&>().begin()));
STATIC_REQUIRE(noexcept(std::declval<map_t&>().max_size())); STATIC_REQUIRE(noexcept(std::declval<const map_t&>().cbegin()));
STATIC_REQUIRE(noexcept(std::declval<map_t&>().capacity())); STATIC_REQUIRE(noexcept(std::declval<map_t&>().end()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().end()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().cend()));
STATIC_REQUIRE(noexcept(std::declval<map_t&>().rbegin()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().rbegin()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().crbegin()));
STATIC_REQUIRE(noexcept(std::declval<map_t&>().rend()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().rend()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().crend()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().empty()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().size()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().max_size()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().capacity()));
STATIC_REQUIRE(noexcept(std::declval<map_t&>().clear())); STATIC_REQUIRE(noexcept(std::declval<map_t&>().clear()));
} }

View File

@@ -75,10 +75,24 @@ TEST_CASE("flat_multimap") {
STATIC_REQUIRE(std::is_nothrow_swappable_v<map2_t>); STATIC_REQUIRE(std::is_nothrow_swappable_v<map2_t>);
STATIC_REQUIRE(!std::is_nothrow_swappable_v<map3_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&>().begin()));
STATIC_REQUIRE(noexcept(std::declval<map_t&>().size())); STATIC_REQUIRE(noexcept(std::declval<const map_t&>().begin()));
STATIC_REQUIRE(noexcept(std::declval<map_t&>().max_size())); STATIC_REQUIRE(noexcept(std::declval<const map_t&>().cbegin()));
STATIC_REQUIRE(noexcept(std::declval<map_t&>().capacity())); STATIC_REQUIRE(noexcept(std::declval<map_t&>().end()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().end()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().cend()));
STATIC_REQUIRE(noexcept(std::declval<map_t&>().rbegin()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().rbegin()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().crbegin()));
STATIC_REQUIRE(noexcept(std::declval<map_t&>().rend()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().rend()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().crend()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().empty()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().size()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().max_size()));
STATIC_REQUIRE(noexcept(std::declval<const map_t&>().capacity()));
STATIC_REQUIRE(noexcept(std::declval<map_t&>().clear())); STATIC_REQUIRE(noexcept(std::declval<map_t&>().clear()));
} }

View File

@@ -75,10 +75,24 @@ TEST_CASE("flat_multiset") {
STATIC_REQUIRE(std::is_nothrow_swappable_v<set2_t>); STATIC_REQUIRE(std::is_nothrow_swappable_v<set2_t>);
STATIC_REQUIRE(!std::is_nothrow_swappable_v<set3_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&>().begin()));
STATIC_REQUIRE(noexcept(std::declval<set_t&>().size())); STATIC_REQUIRE(noexcept(std::declval<const set_t&>().begin()));
STATIC_REQUIRE(noexcept(std::declval<set_t&>().max_size())); STATIC_REQUIRE(noexcept(std::declval<const set_t&>().cbegin()));
STATIC_REQUIRE(noexcept(std::declval<set_t&>().capacity())); STATIC_REQUIRE(noexcept(std::declval<set_t&>().end()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().end()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().cend()));
STATIC_REQUIRE(noexcept(std::declval<set_t&>().rbegin()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().rbegin()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().crbegin()));
STATIC_REQUIRE(noexcept(std::declval<set_t&>().rend()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().rend()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().crend()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().empty()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().size()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().max_size()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().capacity()));
STATIC_REQUIRE(noexcept(std::declval<set_t&>().clear())); STATIC_REQUIRE(noexcept(std::declval<set_t&>().clear()));
} }

View File

@@ -75,10 +75,24 @@ TEST_CASE("flat_set") {
STATIC_REQUIRE(std::is_nothrow_swappable_v<set2_t>); STATIC_REQUIRE(std::is_nothrow_swappable_v<set2_t>);
STATIC_REQUIRE(!std::is_nothrow_swappable_v<set3_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&>().begin()));
STATIC_REQUIRE(noexcept(std::declval<set_t&>().size())); STATIC_REQUIRE(noexcept(std::declval<const set_t&>().begin()));
STATIC_REQUIRE(noexcept(std::declval<set_t&>().max_size())); STATIC_REQUIRE(noexcept(std::declval<const set_t&>().cbegin()));
STATIC_REQUIRE(noexcept(std::declval<set_t&>().capacity())); STATIC_REQUIRE(noexcept(std::declval<set_t&>().end()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().end()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().cend()));
STATIC_REQUIRE(noexcept(std::declval<set_t&>().rbegin()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().rbegin()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().crbegin()));
STATIC_REQUIRE(noexcept(std::declval<set_t&>().rend()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().rend()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().crend()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().empty()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().size()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().max_size()));
STATIC_REQUIRE(noexcept(std::declval<const set_t&>().capacity()));
STATIC_REQUIRE(noexcept(std::declval<set_t&>().clear())); STATIC_REQUIRE(noexcept(std::declval<set_t&>().clear()));
} }