From 47b24bb0adde70db5d205697211a354eb73ee1ae Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Fri, 10 May 2019 10:06:14 +0700 Subject: [PATCH] add default ctor noexcept --- headers/flat_hpp/flat_map.hpp | 4 +++- headers/flat_hpp/flat_multimap.hpp | 4 +++- headers/flat_hpp/flat_multiset.hpp | 4 +++- headers/flat_hpp/flat_set.hpp | 4 +++- untests/flat_map_tests.cpp | 17 ++++++++++++++++- untests/flat_multimap_tests.cpp | 17 ++++++++++++++++- untests/flat_multiset_tests.cpp | 17 ++++++++++++++++- untests/flat_set_tests.cpp | 17 ++++++++++++++++- 8 files changed, 76 insertions(+), 8 deletions(-) diff --git a/headers/flat_hpp/flat_map.hpp b/headers/flat_hpp/flat_map.hpp index 85718a1..191e310 100644 --- a/headers/flat_hpp/flat_map.hpp +++ b/headers/flat_hpp/flat_map.hpp @@ -98,7 +98,9 @@ namespace flat_hpp : key_compare(std::move(compare)) {} }; public: - flat_map() {} + flat_map() + noexcept(std::is_nothrow_default_constructible::value + && std::is_nothrow_default_constructible::value) {} explicit flat_map(const Compare& c) : base_type(c) {} diff --git a/headers/flat_hpp/flat_multimap.hpp b/headers/flat_hpp/flat_multimap.hpp index 27bedee..f6b5b7b 100644 --- a/headers/flat_hpp/flat_multimap.hpp +++ b/headers/flat_hpp/flat_multimap.hpp @@ -98,7 +98,9 @@ namespace flat_hpp : key_compare(std::move(compare)) {} }; public: - flat_multimap() {} + flat_multimap() + noexcept(std::is_nothrow_default_constructible::value + && std::is_nothrow_default_constructible::value) {} explicit flat_multimap(const Compare& c) : base_type(c) {} diff --git a/headers/flat_hpp/flat_multiset.hpp b/headers/flat_hpp/flat_multiset.hpp index a87fdf6..a3b9c17 100644 --- a/headers/flat_hpp/flat_multiset.hpp +++ b/headers/flat_hpp/flat_multiset.hpp @@ -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::value + && std::is_nothrow_default_constructible::value) {} explicit flat_multiset(const Compare& c) : base_type(c) {} diff --git a/headers/flat_hpp/flat_set.hpp b/headers/flat_hpp/flat_set.hpp index e1cdeec..7d53d76 100644 --- a/headers/flat_hpp/flat_set.hpp +++ b/headers/flat_hpp/flat_set.hpp @@ -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::value + && std::is_nothrow_default_constructible::value) {} explicit flat_set(const Compare& c) : base_type(c) {} diff --git a/untests/flat_map_tests.cpp b/untests/flat_map_tests.cpp index 8e79f08..8c59382 100644 --- a/untests/flat_map_tests.cpp +++ b/untests/flat_map_tests.cpp @@ -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>; + using map_t = flat_map, std::vector, alloc_t>>; + + static_assert( + std::is_nothrow_default_constructible::value, + "unit test static error"); + static_assert( + std::is_nothrow_move_constructible::value, + "unit test static error"); + static_assert( + std::is_nothrow_move_assignable::value, + "unit test static error"); + } SECTION("types") { using map_t = flat_map; diff --git a/untests/flat_multimap_tests.cpp b/untests/flat_multimap_tests.cpp index 99bfa2e..9f23252 100644 --- a/untests/flat_multimap_tests.cpp +++ b/untests/flat_multimap_tests.cpp @@ -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>; + using map_t = flat_multimap, std::vector, alloc_t>>; + + static_assert( + std::is_nothrow_default_constructible::value, + "unit test static error"); + static_assert( + std::is_nothrow_move_constructible::value, + "unit test static error"); + static_assert( + std::is_nothrow_move_assignable::value, + "unit test static error"); + } SECTION("types") { using map_t = flat_multimap; diff --git a/untests/flat_multiset_tests.cpp b/untests/flat_multiset_tests.cpp index 35dc06f..b3e6bb2 100644 --- a/untests/flat_multiset_tests.cpp +++ b/untests/flat_multiset_tests.cpp @@ -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; + using set_t = flat_multiset, std::vector>; + + static_assert( + std::is_nothrow_default_constructible::value, + "unit test static error"); + static_assert( + std::is_nothrow_move_constructible::value, + "unit test static error"); + static_assert( + std::is_nothrow_move_assignable::value, + "unit test static error"); + } SECTION("types") { using set_t = flat_multiset; diff --git a/untests/flat_set_tests.cpp b/untests/flat_set_tests.cpp index 8c4b98d..18f1e80 100644 --- a/untests/flat_set_tests.cpp +++ b/untests/flat_set_tests.cpp @@ -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; + using set_t = flat_set, std::vector>; + + static_assert( + std::is_nothrow_default_constructible::value, + "unit test static error"); + static_assert( + std::is_nothrow_move_constructible::value, + "unit test static error"); + static_assert( + std::is_nothrow_move_assignable::value, + "unit test static error"); + } SECTION("types") { using set_t = flat_set;