aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/util/exception
diff options
context:
space:
mode:
authorFrançois Dumont <fdumont@gcc.gnu.org>2011-12-09 20:01:04 +0000
committerFrançois Dumont <fdumont@gcc.gnu.org>2011-12-09 20:01:04 +0000
commit9b81593bbcb4151c135af547647cb9b65ecbd6bd (patch)
treedba467050250a28c9ead1c5187c57648cec07cd2 /libstdc++-v3/testsuite/util/exception
parent60ef5d4e7fcf2789986bcf24e2db82dc0ef79bab (diff)
downloadgcc-9b81593bbcb4151c135af547647cb9b65ecbd6bd.zip
gcc-9b81593bbcb4151c135af547647cb9b65ecbd6bd.tar.gz
gcc-9b81593bbcb4151c135af547647cb9b65ecbd6bd.tar.bz2
hashtable.h (_Hashtable<>::emplace, [...]): Add.
2011-12-09 François Dumont <fdumont@gcc.gnu.org> * include/bits/hashtable.h (_Hashtable<>::emplace, _Hashtable<>::emplace_hint): Add. * include/debug/unordered_set (unordered_set<>::emplace, unordered_set<>::emplace_hint, unordered_multiset<>::emplace, unordered_multiset<>::emplace_hint): Add. * include/profile/unordered_set: Likewise. * include/debug/unordered_map (unordered_map<>::emplace, unordered_map<>::emplace_hint, unordered_multimap<>::emplace, unordered_multimap<>::emplace_hint): Add. * include/profile/unordered_map: Likewise. * testsuite/23_containers/unordered_map/modifiers/emplace.cc: New. * testsuite/23_containers/unordered_multimap/modifiers/emplace.cc: New. * testsuite/23_containers/unordered_set/modifiers/emplace.cc: New. * testsuite/23_containers/unordered_multiset/modifiers/emplace.cc: New. * testsuite/util/testsuite_container_traits.h (traits_base::has_emplace): Add and defined as std::true_type for unordered containers. * testsuite/util/exception/safety.h (emplace, emplace_hint): Add and use them in basic_safety exception test case. * doc/xml/manual/status_cxx2011.xml: Update unordered containers status. From-SVN: r182174
Diffstat (limited to 'libstdc++-v3/testsuite/util/exception')
-rw-r--r--libstdc++-v3/testsuite/util/exception/safety.h110
1 files changed, 110 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/util/exception/safety.h b/libstdc++-v3/testsuite/util/exception/safety.h
index b85f7fe..5041898 100644
--- a/libstdc++-v3/testsuite/util/exception/safety.h
+++ b/libstdc++-v3/testsuite/util/exception/safety.h
@@ -826,6 +826,110 @@ namespace __gnu_test
operator()(_Tp&, _Tp&) { }
};
+ template<typename _Tp,
+ bool = traits<_Tp>::has_emplace::value>
+ struct emplace;
+
+ // Specialization for most containers.
+ template<typename _Tp>
+ struct emplace<_Tp, true>
+ {
+ typedef _Tp container_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename container_type::size_type size_type;
+
+ void
+ operator()(_Tp& __test)
+ {
+ try
+ {
+ const value_type cv = generate_unique<value_type>();
+ __test.emplace(cv);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+
+ // Assumes containers start out equivalent.
+ void
+ operator()(_Tp& __control, _Tp& __test)
+ {
+ try
+ {
+ const value_type cv = generate_unique<value_type>();
+ __test.emplace(cv);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+
+ // Specialization, empty.
+ template<typename _Tp>
+ struct emplace<_Tp, false>
+ {
+ void
+ operator()(_Tp&) { }
+
+ void
+ operator()(_Tp&, _Tp&) { }
+ };
+
+ template<typename _Tp,
+ bool = traits<_Tp>::has_emplace::value>
+ struct emplace_hint;
+
+ // Specialization for most containers.
+ template<typename _Tp>
+ struct emplace_hint<_Tp, true>
+ {
+ typedef _Tp container_type;
+ typedef typename container_type::value_type value_type;
+
+ void
+ operator()(_Tp& __test)
+ {
+ try
+ {
+ const value_type cv = generate_unique<value_type>();
+ const size_type sz = std::distance(__test.begin(), __test.end());
+ size_type s = generate(sz);
+ auto i = __test.begin();
+ std::advance(i, s);
+ __test.emplace_hint(i, cv);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+
+ // Assumes containers start out equivalent.
+ void
+ operator()(_Tp& __control, _Tp& __test)
+ {
+ try
+ {
+ const value_type cv = generate_unique<value_type>();
+ const size_type sz = std::distance(__test.begin(), __test.end());
+ size_type s = generate(sz);
+ auto i = __test.begin();
+ std::advance(i, s);
+ __test.emplace_hint(i, cv);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+
+ // Specialization, empty.
+ template<typename _Tp>
+ struct emplace_hint<_Tp, false>
+ {
+ void
+ operator()(_Tp&) { }
+
+ void
+ operator()(_Tp&, _Tp&) { }
+ };
template<typename _Tp, bool = traits<_Tp>::is_associative::value
|| traits<_Tp>::is_unordered::value>
@@ -1023,6 +1127,8 @@ namespace __gnu_test
typedef erase_point<container_type> erase_point;
typedef erase_range<container_type> erase_range;
typedef insert_point<container_type> insert_point;
+ typedef emplace<container_type> emplace;
+ typedef emplace_hint<container_type> emplace_hint;
typedef pop_front<container_type> pop_front;
typedef pop_back<container_type> pop_back;
typedef push_front<container_type> push_front;
@@ -1039,6 +1145,8 @@ namespace __gnu_test
erase_point _M_erasep;
erase_range _M_eraser;
insert_point _M_insertp;
+ emplace _M_emplace;
+ emplace_hint _M_emplaceh;
pop_front _M_popf;
pop_back _M_popb;
push_front _M_pushf;
@@ -1098,6 +1206,8 @@ namespace __gnu_test
_M_functions.push_back(function_type(base_type::_M_erasep));
_M_functions.push_back(function_type(base_type::_M_eraser));
_M_functions.push_back(function_type(base_type::_M_insertp));
+ _M_functions.push_back(function_type(base_type::_M_emplace));
+ _M_functions.push_back(function_type(base_type::_M_emplaceh));
_M_functions.push_back(function_type(base_type::_M_popf));
_M_functions.push_back(function_type(base_type::_M_popb));
_M_functions.push_back(function_type(base_type::_M_pushf));