mirror of
https://github.com/BlackMATov/flat.hpp.git
synced 2025-12-13 01:36:27 +07:00
add default ctor noexcept
This commit is contained in:
@@ -98,7 +98,9 @@ namespace flat_hpp
|
||||
: key_compare(std::move(compare)) {}
|
||||
};
|
||||
public:
|
||||
flat_map() {}
|
||||
flat_map()
|
||||
noexcept(std::is_nothrow_default_constructible<base_type>::value
|
||||
&& std::is_nothrow_default_constructible<container_type>::value) {}
|
||||
|
||||
explicit flat_map(const Compare& c)
|
||||
: base_type(c) {}
|
||||
|
||||
@@ -98,7 +98,9 @@ namespace flat_hpp
|
||||
: key_compare(std::move(compare)) {}
|
||||
};
|
||||
public:
|
||||
flat_multimap() {}
|
||||
flat_multimap()
|
||||
noexcept(std::is_nothrow_default_constructible<base_type>::value
|
||||
&& std::is_nothrow_default_constructible<container_type>::value) {}
|
||||
|
||||
explicit flat_multimap(const Compare& c)
|
||||
: base_type(c) {}
|
||||
|
||||
@@ -43,7 +43,9 @@ namespace flat_hpp
|
||||
using reverse_iterator = typename Container::const_reverse_iterator;
|
||||
using const_reverse_iterator = typename Container::const_reverse_iterator;
|
||||
public:
|
||||
flat_multiset() {}
|
||||
flat_multiset()
|
||||
noexcept(std::is_nothrow_default_constructible<base_type>::value
|
||||
&& std::is_nothrow_default_constructible<container_type>::value) {}
|
||||
|
||||
explicit flat_multiset(const Compare& c)
|
||||
: base_type(c) {}
|
||||
|
||||
@@ -43,7 +43,9 @@ namespace flat_hpp
|
||||
using reverse_iterator = typename Container::const_reverse_iterator;
|
||||
using const_reverse_iterator = typename Container::const_reverse_iterator;
|
||||
public:
|
||||
flat_set() {}
|
||||
flat_set()
|
||||
noexcept(std::is_nothrow_default_constructible<base_type>::value
|
||||
&& std::is_nothrow_default_constructible<container_type>::value) {}
|
||||
|
||||
explicit flat_set(const Compare& c)
|
||||
: base_type(c) {}
|
||||
|
||||
@@ -73,7 +73,8 @@ namespace
|
||||
template < typename T >
|
||||
class dummy_less {
|
||||
public:
|
||||
dummy_less(int i) : i(i) {}
|
||||
dummy_less() = default;
|
||||
dummy_less(int i) noexcept : i(i) {}
|
||||
bool operator()(const T& l, const T& r) const {
|
||||
return l < r;
|
||||
}
|
||||
@@ -95,6 +96,20 @@ TEST_CASE("flat_map") {
|
||||
};
|
||||
REQUIRE(sizeof(vc) == sizeof(int));
|
||||
}
|
||||
SECTION("noexcept") {
|
||||
using alloc_t = dummy_allocator<std::pair<int,unsigned>>;
|
||||
using map_t = flat_map<int, unsigned, dummy_less<int>, std::vector<std::pair<int,unsigned>, alloc_t>>;
|
||||
|
||||
static_assert(
|
||||
std::is_nothrow_default_constructible<map_t>::value,
|
||||
"unit test static error");
|
||||
static_assert(
|
||||
std::is_nothrow_move_constructible<map_t>::value,
|
||||
"unit test static error");
|
||||
static_assert(
|
||||
std::is_nothrow_move_assignable<map_t>::value,
|
||||
"unit test static error");
|
||||
}
|
||||
SECTION("types") {
|
||||
using map_t = flat_map<int, unsigned>;
|
||||
|
||||
|
||||
@@ -73,7 +73,8 @@ namespace
|
||||
template < typename T >
|
||||
class dummy_less {
|
||||
public:
|
||||
dummy_less(int i) : i(i) {}
|
||||
dummy_less() = default;
|
||||
dummy_less(int i) noexcept : i(i) {}
|
||||
bool operator()(const T& l, const T& r) const {
|
||||
return l < r;
|
||||
}
|
||||
@@ -95,6 +96,20 @@ TEST_CASE("flat_multimap") {
|
||||
};
|
||||
REQUIRE(sizeof(vc) == sizeof(int));
|
||||
}
|
||||
SECTION("noexcept") {
|
||||
using alloc_t = dummy_allocator<std::pair<int,unsigned>>;
|
||||
using map_t = flat_multimap<int, unsigned, dummy_less<int>, std::vector<std::pair<int,unsigned>, alloc_t>>;
|
||||
|
||||
static_assert(
|
||||
std::is_nothrow_default_constructible<map_t>::value,
|
||||
"unit test static error");
|
||||
static_assert(
|
||||
std::is_nothrow_move_constructible<map_t>::value,
|
||||
"unit test static error");
|
||||
static_assert(
|
||||
std::is_nothrow_move_assignable<map_t>::value,
|
||||
"unit test static error");
|
||||
}
|
||||
SECTION("types") {
|
||||
using map_t = flat_multimap<int, unsigned>;
|
||||
|
||||
|
||||
@@ -73,7 +73,8 @@ namespace
|
||||
template < typename T >
|
||||
class dummy_less {
|
||||
public:
|
||||
dummy_less(int i) : i(i) {}
|
||||
dummy_less() = default;
|
||||
dummy_less(int i) noexcept : i(i) {}
|
||||
bool operator()(const T& l, const T& r) const {
|
||||
return l < r;
|
||||
}
|
||||
@@ -95,6 +96,20 @@ TEST_CASE("flat_multiset") {
|
||||
};
|
||||
REQUIRE(sizeof(vc) == sizeof(int));
|
||||
}
|
||||
SECTION("noexcept") {
|
||||
using alloc_t = dummy_allocator<int>;
|
||||
using set_t = flat_multiset<int, dummy_less<int>, std::vector<int, alloc_t>>;
|
||||
|
||||
static_assert(
|
||||
std::is_nothrow_default_constructible<set_t>::value,
|
||||
"unit test static error");
|
||||
static_assert(
|
||||
std::is_nothrow_move_constructible<set_t>::value,
|
||||
"unit test static error");
|
||||
static_assert(
|
||||
std::is_nothrow_move_assignable<set_t>::value,
|
||||
"unit test static error");
|
||||
}
|
||||
SECTION("types") {
|
||||
using set_t = flat_multiset<int>;
|
||||
|
||||
|
||||
@@ -73,7 +73,8 @@ namespace
|
||||
template < typename T >
|
||||
class dummy_less {
|
||||
public:
|
||||
dummy_less(int i) : i(i) {}
|
||||
dummy_less() = default;
|
||||
dummy_less(int i) noexcept : i(i) {}
|
||||
bool operator()(const T& l, const T& r) const {
|
||||
return l < r;
|
||||
}
|
||||
@@ -95,6 +96,20 @@ TEST_CASE("flat_set") {
|
||||
};
|
||||
REQUIRE(sizeof(vc) == sizeof(int));
|
||||
}
|
||||
SECTION("noexcept") {
|
||||
using alloc_t = dummy_allocator<int>;
|
||||
using set_t = flat_set<int, dummy_less<int>, std::vector<int, alloc_t>>;
|
||||
|
||||
static_assert(
|
||||
std::is_nothrow_default_constructible<set_t>::value,
|
||||
"unit test static error");
|
||||
static_assert(
|
||||
std::is_nothrow_move_constructible<set_t>::value,
|
||||
"unit test static error");
|
||||
static_assert(
|
||||
std::is_nothrow_move_assignable<set_t>::value,
|
||||
"unit test static error");
|
||||
}
|
||||
SECTION("types") {
|
||||
using set_t = flat_set<int>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user