Commit 714902c8 by Paolo Carlini Committed by Paolo Carlini

testsuite_container_traits.h (traits_base): Add has_throwing_erase trait.

2010-03-04  Paolo Carlini  <paolo.carlini@oracle.com>

	* testsuite/util/testsuite_container_traits.h (traits_base): Add
	has_throwing_erase trait.
	(traits<vector>, traits<deque>): Typedef the latter to true_type.
	* testsuite/util/exception/safety.h (generation_prohibited):
	Do not test vector::erase and deque::erase: can throw if
	either copy constructor or assignment operator of value_type
	throws.
	* testsuite/23_containers/vector/requirements/exception/
	generation_prohibited.cc: Remove xfail.
	* testsuite/23_containers/deque/requirements/exception/
	generation_prohibited.cc: Likewise.

	* include/ext/throw_allocator.h (hash<__gnu_cxx::throw_value_limit>::
	operator(), hash<__gnu_cxx::throw_value_random>::operator()): Pass
	argument by const ref.

	* testsuite/util/testsuite_container_traits.h (traits<map>,
	traits<multimap>, traits<set>, traits<multiset>,
	traits<unordered_map>, traits<unordered_multimap>,
	traits<unordered_set>, traits<unordered_multiset>): Typedef
	consistently has_erase and has_insert as true_type.

	* testsuite/util/testsuite_container_traits.h
	(traits<unordered_map>, traits<unordered_multimap>,
	traits<unordered_set>, traits<unordered_multiset>): Do not wrongly
	typedef has_size_type_constructor as true_type: the constructor
	accepting a size_type actually gets the initial number of
	buckets.

From-SVN: r157239
parent 630e6f1b
2010-03-04 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/util/testsuite_container_traits.h (traits_base): Add
has_throwing_erase trait.
(traits<vector>, traits<deque>): Typedef the latter to true_type.
* testsuite/util/exception/safety.h (generation_prohibited):
Do not test vector::erase and deque::erase: can throw if
either copy constructor or assignment operator of value_type
throws.
* testsuite/23_containers/vector/requirements/exception/
generation_prohibited.cc: Remove xfail.
* testsuite/23_containers/deque/requirements/exception/
generation_prohibited.cc: Likewise.
* include/ext/throw_allocator.h (hash<__gnu_cxx::throw_value_limit>::
operator(), hash<__gnu_cxx::throw_value_random>::operator()): Pass
argument by const ref.
* testsuite/util/testsuite_container_traits.h (traits<map>,
traits<multimap>, traits<set>, traits<multiset>,
traits<unordered_map>, traits<unordered_multimap>,
traits<unordered_set>, traits<unordered_multiset>): Typedef
consistently has_erase and has_insert as true_type.
* testsuite/util/testsuite_container_traits.h
(traits<unordered_map>, traits<unordered_multimap>,
traits<unordered_set>, traits<unordered_multiset>): Do not wrongly
typedef has_size_type_constructor as true_type: the constructor
accepting a size_type actually gets the initial number of
buckets.
2010-03-03 Benjamin Kosnik <bkoz@redhat.com> 2010-03-03 Benjamin Kosnik <bkoz@redhat.com>
* doc/Makefile.am: Re-organize xml sources. * doc/Makefile.am: Re-organize xml sources.
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -728,7 +729,7 @@ namespace std ...@@ -728,7 +729,7 @@ namespace std
: public std::unary_function<__gnu_cxx::throw_value_limit, size_t> : public std::unary_function<__gnu_cxx::throw_value_limit, size_t>
{ {
size_t size_t
operator()(__gnu_cxx::throw_value_limit __val) const operator()(const __gnu_cxx::throw_value_limit& __val) const
{ {
std::hash<std::size_t> h; std::hash<std::size_t> h;
size_t __result = h(__val._M_i); size_t __result = h(__val._M_i);
...@@ -742,7 +743,7 @@ namespace std ...@@ -742,7 +743,7 @@ namespace std
: public std::unary_function<__gnu_cxx::throw_value_random, size_t> : public std::unary_function<__gnu_cxx::throw_value_random, size_t>
{ {
size_t size_t
operator()(__gnu_cxx::throw_value_random __val) const operator()(const __gnu_cxx::throw_value_random& __val) const
{ {
std::hash<std::size_t> h; std::hash<std::size_t> h;
size_t __result = h(__val._M_i); size_t __result = h(__val._M_i);
......
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-do run { xfail *-*-* } }
// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> // 2009-09-09 Benjamin Kosnik <benjamin@redhat.com>
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
......
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// { dg-do run { xfail *-*-* } }
// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> // 2009-09-09 Benjamin Kosnik <benjamin@redhat.com>
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
......
...@@ -1096,8 +1096,13 @@ namespace __gnu_test ...@@ -1096,8 +1096,13 @@ namespace __gnu_test
{ {
condition_type::always_adjustor on; condition_type::always_adjustor on;
_M_erasep(_M_container); // NB: Vector and deque are special, erase can throw if the copy
_M_eraser(_M_container); // constructor or assignment operator of value_type throws.
if (!traits<container_type>::has_throwing_erase::value)
{
_M_erasep(_M_container);
_M_eraser(_M_container);
}
_M_popf(_M_container); _M_popf(_M_container);
_M_popb(_M_container); _M_popb(_M_container);
......
...@@ -39,6 +39,7 @@ namespace __gnu_test ...@@ -39,6 +39,7 @@ namespace __gnu_test
typedef std::false_type is_mapped; typedef std::false_type is_mapped;
typedef std::false_type has_erase; typedef std::false_type has_erase;
typedef std::false_type has_throwing_erase;
typedef std::false_type has_insert; typedef std::false_type has_insert;
typedef std::false_type has_push_pop; typedef std::false_type has_push_pop;
typedef std::false_type has_size_type_constructor; typedef std::false_type has_size_type_constructor;
...@@ -65,6 +66,7 @@ namespace __gnu_test ...@@ -65,6 +66,7 @@ namespace __gnu_test
typedef std::true_type is_allocator_aware; typedef std::true_type is_allocator_aware;
typedef std::true_type has_erase; typedef std::true_type has_erase;
typedef std::true_type has_throwing_erase;
typedef std::true_type has_insert; typedef std::true_type has_insert;
typedef std::true_type has_push_pop; typedef std::true_type has_push_pop;
typedef std::true_type has_size_type_constructor; typedef std::true_type has_size_type_constructor;
...@@ -103,6 +105,7 @@ namespace __gnu_test ...@@ -103,6 +105,7 @@ namespace __gnu_test
typedef std::true_type is_allocator_aware; typedef std::true_type is_allocator_aware;
typedef std::true_type has_erase; typedef std::true_type has_erase;
typedef std::true_type has_throwing_erase;
typedef std::true_type has_insert; typedef std::true_type has_insert;
typedef std::true_type has_size_type_constructor; typedef std::true_type has_size_type_constructor;
}; };
...@@ -140,6 +143,7 @@ namespace __gnu_test ...@@ -140,6 +143,7 @@ namespace __gnu_test
typedef std::true_type is_associative; typedef std::true_type is_associative;
typedef std::true_type is_mapped; typedef std::true_type is_mapped;
typedef std::true_type has_erase;
typedef std::true_type has_insert; typedef std::true_type has_insert;
}; };
...@@ -152,6 +156,7 @@ namespace __gnu_test ...@@ -152,6 +156,7 @@ namespace __gnu_test
typedef std::true_type is_associative; typedef std::true_type is_associative;
typedef std::true_type is_mapped; typedef std::true_type is_mapped;
typedef std::true_type has_erase;
typedef std::true_type has_insert; typedef std::true_type has_insert;
}; };
...@@ -163,6 +168,7 @@ namespace __gnu_test ...@@ -163,6 +168,7 @@ namespace __gnu_test
typedef std::true_type is_allocator_aware; typedef std::true_type is_allocator_aware;
typedef std::true_type is_associative; typedef std::true_type is_associative;
typedef std::true_type has_erase;
typedef std::true_type has_insert; typedef std::true_type has_insert;
}; };
...@@ -174,6 +180,7 @@ namespace __gnu_test ...@@ -174,6 +180,7 @@ namespace __gnu_test
typedef std::true_type is_allocator_aware; typedef std::true_type is_allocator_aware;
typedef std::true_type is_associative; typedef std::true_type is_associative;
typedef std::true_type has_erase;
typedef std::true_type has_insert; typedef std::true_type has_insert;
}; };
...@@ -205,7 +212,7 @@ namespace __gnu_test ...@@ -205,7 +212,7 @@ namespace __gnu_test
typedef std::true_type is_unordered; typedef std::true_type is_unordered;
typedef std::true_type is_mapped; typedef std::true_type is_mapped;
typedef std::true_type has_size_type_constructor; typedef std::true_type has_erase;
typedef std::true_type has_insert; typedef std::true_type has_insert;
}; };
...@@ -219,7 +226,8 @@ namespace __gnu_test ...@@ -219,7 +226,8 @@ namespace __gnu_test
typedef std::true_type is_unordered; typedef std::true_type is_unordered;
typedef std::true_type is_mapped; typedef std::true_type is_mapped;
typedef std::true_type has_size_type_constructor; typedef std::true_type has_erase;
typedef std::true_type has_insert;
}; };
template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4> template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
...@@ -230,7 +238,7 @@ namespace __gnu_test ...@@ -230,7 +238,7 @@ namespace __gnu_test
typedef std::true_type is_allocator_aware; typedef std::true_type is_allocator_aware;
typedef std::true_type is_unordered; typedef std::true_type is_unordered;
typedef std::true_type has_size_type_constructor; typedef std::true_type has_erase;
typedef std::true_type has_insert; typedef std::true_type has_insert;
}; };
...@@ -242,7 +250,7 @@ namespace __gnu_test ...@@ -242,7 +250,7 @@ namespace __gnu_test
typedef std::true_type is_allocator_aware; typedef std::true_type is_allocator_aware;
typedef std::true_type is_unordered; typedef std::true_type is_unordered;
typedef std::true_type has_size_type_constructor; typedef std::true_type has_erase;
typedef std::true_type has_insert; typedef std::true_type has_insert;
}; };
} // namespace __gnu_test } // namespace __gnu_test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment