Commit 8fafc2d3 by Benjamin Kosnik Committed by Benjamin Kosnik

exception.hpp (pb_ds): Modify for -fno-exceptions.

2006-11-07  Benjamin Kosnik  <bkoz@redhat.com>

	* include/ext/pb_ds/exception.hpp (pb_ds): Modify for -fno-exceptions.
	(__throw_container_error): New. Conditionalize based on __EXCEPTIONS.
	(__throw_insert_error): New.
	(__throw_join_error): New.
	(__throw_resize_error): New.
	* include/ext/pb_ds/detail/resize_policy/
	hash_prime_size_policy_imp.hpp: Use them.
	* include/ext/pb_ds/detail/resize_policy/
	hash_exponential_size_policy_imp.hpp: Same.
	* include/ext/pb_ds/detail/resize_policy/
	hash_load_check_resize_trigger_imp.hpp: Same.
	* include/ext/pb_ds/detail/resize_policy/
	hash_standard_resize_policy_imp.hpp: Same.
	* include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp
	* include/ext/pb_ds/detail/cc_hash_table_map_/
	constructor_destructor_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp
	* include/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp
	* include/ext/pb_ds/detail/pat_trie_/
	constructors_destructor_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/bin_search_tree_/
	constructors_destructor_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/bin_search_tree_/
	split_join_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	insert_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	resize_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	insert_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	constructor_destructor_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/gp_hash_table_map_/
	resize_no_store_hash_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/binary_heap_/
	constructors_destructor_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
	constructors_destructor_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp: Same.
	* include/ext/pb_ds/detail/list_update_map_/
	constructor_destructor_fn_imps.hpp: Same.
	* include/ext/pb_ds/exception.hpp: Same.	
	* src/functexcept.cc: Qualify abort with std.

From-SVN: r118554
parent 8f81c3c6
2006-11-07 Benjamin Kosnik <bkoz@redhat.com> 2006-11-07 Benjamin Kosnik <bkoz@redhat.com>
* include/ext/pb_ds/exception.hpp (pb_ds): Modify for -fno-exceptions.
(__throw_container_error): New. Conditionalize based on __EXCEPTIONS.
(__throw_insert_error): New.
(__throw_join_error): New.
(__throw_resize_error): New.
* include/ext/pb_ds/detail/resize_policy/
hash_prime_size_policy_imp.hpp: Use them.
* include/ext/pb_ds/detail/resize_policy/
hash_exponential_size_policy_imp.hpp: Same.
* include/ext/pb_ds/detail/resize_policy/
hash_load_check_resize_trigger_imp.hpp: Same.
* include/ext/pb_ds/detail/resize_policy/
hash_standard_resize_policy_imp.hpp: Same.
* include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp
* include/ext/pb_ds/detail/cc_hash_table_map_/
constructor_destructor_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp
* include/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp
* include/ext/pb_ds/detail/pat_trie_/
constructors_destructor_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/bin_search_tree_/
constructors_destructor_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/bin_search_tree_/
split_join_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
insert_no_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
resize_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
insert_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
constructor_destructor_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/gp_hash_table_map_/
resize_no_store_hash_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/binary_heap_/
constructors_destructor_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
constructors_destructor_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp: Same.
* include/ext/pb_ds/detail/list_update_map_/
constructor_destructor_fn_imps.hpp: Same.
* include/ext/pb_ds/exception.hpp: Same.
* src/functexcept.cc: Qualify abort with std.
2006-11-07 Benjamin Kosnik <bkoz@redhat.com>
* include/ext/pb_ds/exception.hpp: Add translation support to * include/ext/pb_ds/exception.hpp: Add translation support to
exception strings. exception strings.
* include/ext/concurrence.h: Same. * include/ext/concurrence.h: Same.
......
...@@ -107,7 +107,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : ...@@ -107,7 +107,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
{ {
_GLIBCXX_DEBUG_ONLY(map_debug_base::clear();) _GLIBCXX_DEBUG_ONLY(map_debug_base::clear();)
s_node_allocator.deallocate(m_p_head, 1); s_node_allocator.deallocate(m_p_head, 1);
throw; __throw_exception_again;
} }
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
} }
...@@ -170,7 +170,7 @@ recursive_copy_node(const node_pointer p_nd) ...@@ -170,7 +170,7 @@ recursive_copy_node(const node_pointer p_nd)
catch(...) catch(...)
{ {
s_node_allocator.deallocate(p_ret, 1); s_node_allocator.deallocate(p_ret, 1);
throw; __throw_exception_again;
} }
p_ret->m_p_left = p_ret->m_p_right = NULL; p_ret->m_p_left = p_ret->m_p_right = NULL;
...@@ -183,7 +183,7 @@ recursive_copy_node(const node_pointer p_nd) ...@@ -183,7 +183,7 @@ recursive_copy_node(const node_pointer p_nd)
catch(...) catch(...)
{ {
clear_imp(p_ret); clear_imp(p_ret);
throw; __throw_exception_again;
} }
if (p_ret->m_p_left != NULL) if (p_ret->m_p_left != NULL)
......
...@@ -51,36 +51,28 @@ join_prep(PB_DS_CLASS_C_DEC& other) ...@@ -51,36 +51,28 @@ join_prep(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
if (other.m_size == 0) if (other.m_size == 0)
return (false); return false;
if (m_size == 0) if (m_size == 0)
{ {
value_swap(other); value_swap(other);
return false;
return (false);
} }
const bool greater = Cmp_Fn::operator()( const bool greater = Cmp_Fn::operator()(PB_DS_V2F(m_p_head->m_p_right->m_value), PB_DS_V2F(other.m_p_head->m_p_left->m_value));
PB_DS_V2F(m_p_head->m_p_right->m_value),
PB_DS_V2F(other.m_p_head->m_p_left->m_value));
const bool lesser = Cmp_Fn::operator()( const bool lesser = Cmp_Fn::operator()(PB_DS_V2F(other.m_p_head->m_p_right->m_value), PB_DS_V2F(m_p_head->m_p_left->m_value));
PB_DS_V2F(other.m_p_head->m_p_right->m_value),
PB_DS_V2F(m_p_head->m_p_left->m_value));
if (!greater&& !lesser) if (!greater && !lesser)
throw join_error(); __throw_join_error();
if (lesser) if (lesser)
value_swap(other); value_swap(other);
m_size += other.m_size; m_size += other.m_size;
_GLIBCXX_DEBUG_ONLY(map_debug_base::join(other);) _GLIBCXX_DEBUG_ONLY(map_debug_base::join(other);)
return true;
return (true);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -89,7 +81,6 @@ PB_DS_CLASS_C_DEC:: ...@@ -89,7 +81,6 @@ PB_DS_CLASS_C_DEC::
join_finish(PB_DS_CLASS_C_DEC& other) join_finish(PB_DS_CLASS_C_DEC& other)
{ {
initialize_min_max(); initialize_min_max();
other.initialize(); other.initialize();
} }
...@@ -100,52 +91,40 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) ...@@ -100,52 +91,40 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
other.clear(); other.clear();
if (m_size == 0) if (m_size == 0)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return false;
return (false);
} }
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_left->m_value))) if (Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_left->m_value)))
{ {
value_swap(other); value_swap(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return false;
return (false);
} }
if (!Cmp_Fn::operator()( if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_right->m_value)))
r_key,
PB_DS_V2F(m_p_head->m_p_right->m_value)))
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return false;
return (false);
} }
if (m_size == 1) if (m_size == 1)
{ {
value_swap(other); value_swap(other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
return false;
return (false);
} }
_GLIBCXX_DEBUG_ONLY(map_debug_base::split( _GLIBCXX_DEBUG_ONLY(map_debug_base::split(r_key,(Cmp_Fn& )(*this), other);)
r_key,(Cmp_Fn& )(*this), return true;
other);)
return (true);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -154,28 +133,20 @@ PB_DS_CLASS_C_DEC:: ...@@ -154,28 +133,20 @@ PB_DS_CLASS_C_DEC::
split_finish(PB_DS_CLASS_C_DEC& other) split_finish(PB_DS_CLASS_C_DEC& other)
{ {
other.initialize_min_max(); other.initialize_min_max();
other.m_size = std::distance(other.begin(), other.end());
other.m_size =
std::distance(other.begin(), other.end());
m_size -= other.m_size; m_size -= other.m_size;
initialize_min_max(); initialize_min_max();
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
recursive_count(node_pointer p_nd) const recursive_count(node_pointer p) const
{ {
if (p_nd == NULL) if (p == NULL)
return (0); return 0;
return 1 + recursive_count(p->m_p_left) + recursive_count(p->m_p_right);
return (1 +
recursive_count(p_nd->m_p_left) +
recursive_count(p_nd->m_p_right));
} }
...@@ -65,14 +65,13 @@ copy_from_range(It first_it, It last_it) ...@@ -65,14 +65,13 @@ copy_from_range(It first_it, It last_it)
while (first_it != last_it) while (first_it != last_it)
{ {
insert_value(*first_it, s_no_throw_copies_ind); insert_value(*first_it, s_no_throw_copies_ind);
++first_it; ++first_it;
} }
std::make_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this)); std::make_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this));
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
...@@ -82,7 +81,7 @@ binary_heap_() : ...@@ -82,7 +81,7 @@ binary_heap_() :
m_a_entries(s_entry_allocator.allocate(m_actual_size)) m_a_entries(s_entry_allocator.allocate(m_actual_size))
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
...@@ -93,7 +92,7 @@ binary_heap_(const Cmp_Fn& r_cmp_fn) : ...@@ -93,7 +92,7 @@ binary_heap_(const Cmp_Fn& r_cmp_fn) :
m_a_entries(s_entry_allocator.allocate(m_actual_size)) m_a_entries(s_entry_allocator.allocate(m_actual_size))
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
...@@ -115,7 +114,6 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) : ...@@ -115,7 +114,6 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) :
while (first_it != last_it) while (first_it != last_it)
{ {
insert_value(*first_it, s_no_throw_copies_ind); insert_value(*first_it, s_no_throw_copies_ind);
++first_it; ++first_it;
} }
} }
...@@ -125,12 +123,10 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) : ...@@ -125,12 +123,10 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) :
erase_at(m_a_entries, i, s_no_throw_copies_ind); erase_at(m_a_entries, i, s_no_throw_copies_ind);
s_entry_allocator.deallocate(m_a_entries, m_actual_size); s_entry_allocator.deallocate(m_a_entries, m_actual_size);
__throw_exception_again;
throw;
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
...@@ -142,12 +138,10 @@ swap(PB_DS_CLASS_C_DEC& other) ...@@ -142,12 +138,10 @@ swap(PB_DS_CLASS_C_DEC& other)
_GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries); _GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
value_swap(other); value_swap(other);
std::swap((entry_cmp& )(*this), (entry_cmp& )other); std::swap((entry_cmp& )(*this), (entry_cmp& )other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
...@@ -155,12 +149,9 @@ PB_DS_CLASS_C_DEC:: ...@@ -155,12 +149,9 @@ PB_DS_CLASS_C_DEC::
value_swap(PB_DS_CLASS_C_DEC& other) value_swap(PB_DS_CLASS_C_DEC& other)
{ {
std::swap(m_a_entries, other.m_a_entries); std::swap(m_a_entries, other.m_a_entries);
std::swap(m_size, other.m_size); std::swap(m_size, other.m_size);
std::swap(m_actual_size, other.m_actual_size); std::swap(m_actual_size, other.m_actual_size);
static_cast<resize_policy*>(this)->swap(other);
static_cast<resize_policy* >(this)->swap(other);
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
...@@ -169,7 +160,6 @@ PB_DS_CLASS_C_DEC:: ...@@ -169,7 +160,6 @@ PB_DS_CLASS_C_DEC::
{ {
for (size_type i = 0; i < m_size; ++i) for (size_type i = 0; i < m_size; ++i)
erase_at(m_a_entries, i, s_no_throw_copies_ind); erase_at(m_a_entries, i, s_no_throw_copies_ind);
s_entry_allocator.deallocate(m_a_entries, m_actual_size); s_entry_allocator.deallocate(m_a_entries, m_actual_size);
} }
...@@ -91,7 +91,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) ...@@ -91,7 +91,7 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other)
if (a_other_entries != NULL) if (a_other_entries != NULL)
s_entry_allocator.deallocate(a_other_entries, other_actual_size); s_entry_allocator.deallocate(a_other_entries, other_actual_size);
throw; __throw_exception_again;
}; };
for (size_type i = 0; i < other.m_size; ++i) for (size_type i = 0; i < other.m_size; ++i)
...@@ -140,7 +140,6 @@ join(PB_DS_CLASS_C_DEC& other) ...@@ -140,7 +140,6 @@ join(PB_DS_CLASS_C_DEC& other)
try try
{ {
a_entries = s_entry_allocator.allocate(actual_size); a_entries = s_entry_allocator.allocate(actual_size);
a_other_entries = s_entry_allocator.allocate(resize_policy::min_size); a_other_entries = s_entry_allocator.allocate(resize_policy::min_size);
} }
catch(...) catch(...)
...@@ -151,7 +150,7 @@ join(PB_DS_CLASS_C_DEC& other) ...@@ -151,7 +150,7 @@ join(PB_DS_CLASS_C_DEC& other)
if (a_other_entries != NULL) if (a_other_entries != NULL)
s_entry_allocator.deallocate(a_other_entries, resize_policy::min_size); s_entry_allocator.deallocate(a_other_entries, resize_policy::min_size);
throw; __throw_exception_again;
} }
std::copy(m_a_entries, m_a_entries + m_size, a_entries); std::copy(m_a_entries, m_a_entries + m_size, a_entries);
...@@ -175,5 +174,5 @@ join(PB_DS_CLASS_C_DEC& other) ...@@ -175,5 +174,5 @@ join(PB_DS_CLASS_C_DEC& other)
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
} }
...@@ -146,7 +146,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : ...@@ -146,7 +146,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
catch(...) catch(...)
{ {
deallocate_all(); deallocate_all();
throw; __throw_exception_again;
} }
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
} }
......
...@@ -103,7 +103,7 @@ resize_imp(size_type new_size) ...@@ -103,7 +103,7 @@ resize_imp(size_type new_size)
catch(...) catch(...)
{ {
ranged_hash_fn_base::notify_resized(old_size); ranged_hash_fn_base::notify_resized(old_size);
throw; __throw_exception_again;
} }
// At this point no exceptions can be thrown. // At this point no exceptions can be thrown.
......
...@@ -164,7 +164,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : ...@@ -164,7 +164,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
catch(...) catch(...)
{ {
deallocate_all(); deallocate_all();
throw; __throw_exception_again;
} }
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
} }
......
...@@ -92,7 +92,7 @@ find_ins_pos(const_key_reference r_key, false_type) ...@@ -92,7 +92,7 @@ find_ins_pos(const_key_reference r_key, false_type)
} }
resize_base::notify_insert_search_end(); resize_base::notify_insert_search_end();
if (ins_pos == m_num_e) if (ins_pos == m_num_e)
throw insert_error(); __throw_insert_error();
return ins_pos; return ins_pos;
} }
......
...@@ -97,7 +97,7 @@ find_ins_pos(const_key_reference r_key, true_type) ...@@ -97,7 +97,7 @@ find_ins_pos(const_key_reference r_key, true_type)
} }
resize_base::notify_insert_search_end(); resize_base::notify_insert_search_end();
if (ins_pos == m_num_e) if (ins_pos == m_num_e)
throw insert_error(); __throw_insert_error();
return std::make_pair(ins_pos, pos_hash_pair.second); return std::make_pair(ins_pos, pos_hash_pair.second);
} }
......
...@@ -114,7 +114,7 @@ resize_imp(size_type new_size) ...@@ -114,7 +114,7 @@ resize_imp(size_type new_size)
m_num_e = old_size; m_num_e = old_size;
s_entry_allocator.deallocate(a_entries_resized, new_size); s_entry_allocator.deallocate(a_entries_resized, new_size);
ranged_probe_fn_base::notify_resized(old_size); ranged_probe_fn_base::notify_resized(old_size);
throw; __throw_exception_again;
} }
// At this point no exceptions can be thrown. // At this point no exceptions can be thrown.
......
...@@ -73,6 +73,6 @@ resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, ...@@ -73,6 +73,6 @@ resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized,
_GLIBCXX_DEBUG_ASSERT(0); _GLIBCXX_DEBUG_ASSERT(0);
}; };
} }
throw insert_error(); __throw_insert_error();
} }
...@@ -75,6 +75,6 @@ resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, ...@@ -75,6 +75,6 @@ resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized,
_GLIBCXX_DEBUG_ASSERT(0); _GLIBCXX_DEBUG_ASSERT(0);
}; };
} }
throw insert_error(); __throw_insert_error();
} }
...@@ -59,7 +59,7 @@ left_child_next_sibling_heap_() : ...@@ -59,7 +59,7 @@ left_child_next_sibling_heap_() :
m_size(0) m_size(0)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
...@@ -69,25 +69,19 @@ left_child_next_sibling_heap_(const Cmp_Fn& r_cmp_fn) : ...@@ -69,25 +69,19 @@ left_child_next_sibling_heap_(const Cmp_Fn& r_cmp_fn) :
m_size(0) m_size(0)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC:: PB_DS_CLASS_C_DEC::
left_child_next_sibling_heap_(const PB_DS_CLASS_C_DEC& other) : left_child_next_sibling_heap_(const PB_DS_CLASS_C_DEC& other)
Cmp_Fn(other), : Cmp_Fn(other), m_p_root(NULL), m_size(0)
m_p_root(NULL),
m_size(0)
{ {
m_size = other.m_size; m_size = other.m_size;
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
m_p_root = recursive_copy_node(other.m_p_root); m_p_root = recursive_copy_node(other.m_p_root);
m_size = other.m_size; m_size = other.m_size;
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
...@@ -96,14 +90,11 @@ swap(PB_DS_CLASS_C_DEC& other) ...@@ -96,14 +90,11 @@ swap(PB_DS_CLASS_C_DEC& other)
{ {
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
value_swap(other); value_swap(other);
std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other); std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
_GLIBCXX_DEBUG_ONLY(other.assert_valid();) _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
} }
PB_DS_CLASS_T_DEC PB_DS_CLASS_T_DEC
void void
...@@ -111,7 +102,6 @@ PB_DS_CLASS_C_DEC:: ...@@ -111,7 +102,6 @@ PB_DS_CLASS_C_DEC::
value_swap(PB_DS_CLASS_C_DEC& other) value_swap(PB_DS_CLASS_C_DEC& other)
{ {
std::swap(m_p_root, other.m_p_root); std::swap(m_p_root, other.m_p_root);
std::swap(m_size, other.m_size); std::swap(m_size, other.m_size);
} }
...@@ -139,8 +129,7 @@ recursive_copy_node(const_node_pointer p_nd) ...@@ -139,8 +129,7 @@ recursive_copy_node(const_node_pointer p_nd)
catch(...) catch(...)
{ {
s_node_allocator.deallocate(p_ret, 1); s_node_allocator.deallocate(p_ret, 1);
__throw_exception_again;
throw;
} }
p_ret->m_p_l_child = p_ret->m_p_next_sibling = p_ret->m_p_l_child = p_ret->m_p_next_sibling =
...@@ -149,14 +138,12 @@ recursive_copy_node(const_node_pointer p_nd) ...@@ -149,14 +138,12 @@ recursive_copy_node(const_node_pointer p_nd)
try try
{ {
p_ret->m_p_l_child = recursive_copy_node(p_nd->m_p_l_child); p_ret->m_p_l_child = recursive_copy_node(p_nd->m_p_l_child);
p_ret->m_p_next_sibling = recursive_copy_node(p_nd->m_p_next_sibling); p_ret->m_p_next_sibling = recursive_copy_node(p_nd->m_p_next_sibling);
} }
catch(...) catch(...)
{ {
clear_imp(p_ret); clear_imp(p_ret);
__throw_exception_again;
throw;
} }
if (p_ret->m_p_l_child != NULL) if (p_ret->m_p_l_child != NULL)
...@@ -164,10 +151,8 @@ recursive_copy_node(const_node_pointer p_nd) ...@@ -164,10 +151,8 @@ recursive_copy_node(const_node_pointer p_nd)
if (p_ret->m_p_next_sibling != NULL) if (p_ret->m_p_next_sibling != NULL)
p_ret->m_p_next_sibling->m_p_prev_or_parent = p_ret->m_p_next_sibling->m_p_prev_or_parent =
p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd? p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd ? p_ret : NULL;
p_ret :
NULL;
return (p_ret); return p_ret;
} }
...@@ -107,7 +107,7 @@ m_p_l(NULL) ...@@ -107,7 +107,7 @@ m_p_l(NULL)
catch(...) catch(...)
{ {
deallocate_all(); deallocate_all();
throw; __throw_exception_again;
} }
_GLIBCXX_DEBUG_ONLY(assert_valid();) _GLIBCXX_DEBUG_ONLY(assert_valid();)
} }
......
...@@ -122,8 +122,8 @@ join(PB_DS_CLASS_C_DEC& other) ...@@ -122,8 +122,8 @@ join(PB_DS_CLASS_C_DEC& other)
const bool lesser = Cmp_Fn::operator()(PB_DS_V2F(*(other.end() - 1)), const bool lesser = Cmp_Fn::operator()(PB_DS_V2F(*(other.end() - 1)),
PB_DS_V2F(*begin())); PB_DS_V2F(*begin()));
if (!greater&& !lesser) if (!greater && !lesser)
throw join_error(); __throw_join_error();
PB_DS_CLASS_C_DEC new_this(*this, *this); PB_DS_CLASS_C_DEC new_this(*this, *this);
......
...@@ -103,7 +103,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : ...@@ -103,7 +103,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) :
catch(...) catch(...)
{ {
s_head_allocator.deallocate(m_p_head, 1); s_head_allocator.deallocate(m_p_head, 1);
throw; __throw_exception_again;
} }
m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent); m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent);
...@@ -203,7 +203,7 @@ recursive_copy_node(const_node_pointer p_other_nd) ...@@ -203,7 +203,7 @@ recursive_copy_node(const_node_pointer p_other_nd)
{ {
while (child_i-- > 0) while (child_i-- > 0)
clear_imp(a_p_children[child_i]); clear_imp(a_p_children[child_i]);
throw; __throw_exception_again;
} }
new (p_ret) internal_node(p_other_internal_nd->get_e_ind(), new (p_ret) internal_node(p_other_internal_nd->get_e_ind(),
......
...@@ -95,7 +95,7 @@ join_prep(PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag) ...@@ -95,7 +95,7 @@ join_prep(PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag)
other.m_p_head->m_p_max)->value()),PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_min)->value())); other.m_p_head->m_p_max)->value()),PB_DS_V2F(static_cast<const_leaf_pointer>(m_p_head->m_p_min)->value()));
if (!greater && !lesser) if (!greater && !lesser)
throw join_error(); __throw_join_error();
rec_join_prep(m_p_head->m_p_parent, other.m_p_head->m_p_parent, r_bag); rec_join_prep(m_p_head->m_p_parent, other.m_p_head->m_p_parent, r_bag);
_GLIBCXX_DEBUG_ONLY(map_debug_base::join(other);) _GLIBCXX_DEBUG_ONLY(map_debug_base::join(other);)
......
...@@ -67,7 +67,7 @@ public: ...@@ -67,7 +67,7 @@ public:
catch(...) catch(...)
{ {
s_internal_node_allocator.deallocate(p_nd, 1); s_internal_node_allocator.deallocate(p_nd, 1);
throw; __throw_exception_again;
} }
} }
......
...@@ -70,7 +70,7 @@ get_nearest_larger_size(size_type size) const ...@@ -70,7 +70,7 @@ get_nearest_larger_size(size_type size) const
{ {
const size_type next_ret = ret* m_grow_factor; const size_type next_ret = ret* m_grow_factor;
if (next_ret < ret) if (next_ret < ret)
throw insert_error(); __throw_insert_error();
ret = next_ret; ret = next_ret;
} }
return ret; return ret;
...@@ -86,7 +86,7 @@ get_nearest_smaller_size(size_type size) const ...@@ -86,7 +86,7 @@ get_nearest_smaller_size(size_type size) const
{ {
const size_type next_ret = ret* m_grow_factor; const size_type next_ret = ret* m_grow_factor;
if (next_ret < ret) if (next_ret < ret)
throw resize_error(); __throw_resize_error();
if (next_ret >= size) if (next_ret >= size)
return (ret); return (ret);
ret = next_ret; ret = next_ret;
......
...@@ -275,7 +275,7 @@ set_loads(std::pair<float, float> load_pair) ...@@ -275,7 +275,7 @@ set_loads(std::pair<float, float> load_pair)
m_next_shrink_size = old_next_shrink_size; m_next_shrink_size = old_next_shrink_size;
m_next_grow_size = old_next_grow_size; m_next_grow_size = old_next_grow_size;
m_resize_needed = old_resize_needed; m_resize_needed = old_resize_needed;
throw; __throw_exception_again;
} }
} }
......
...@@ -145,7 +145,7 @@ get_nearest_larger_size(size_type n) const ...@@ -145,7 +145,7 @@ get_nearest_larger_size(size_type n) const
detail::g_a_sizes + detail::num_distinct_sizes, n); detail::g_a_sizes + detail::num_distinct_sizes, n);
if (p_upper == detail::g_a_sizes + detail::num_distinct_sizes) if (p_upper == detail::g_a_sizes + detail::num_distinct_sizes)
throw resize_error(); __throw_resize_error();
return *p_upper; return *p_upper;
} }
......
...@@ -200,7 +200,7 @@ resize(size_type new_size) ...@@ -200,7 +200,7 @@ resize(size_type new_size)
const size_type pot = size_policy_base::get_nearest_larger_size(actual_size); const size_type pot = size_policy_base::get_nearest_larger_size(actual_size);
if (pot == actual_size && pot < new_size) if (pot == actual_size && pot < new_size)
throw resize_error(); __throw_resize_error();
actual_size = pot; actual_size = pot;
} }
...@@ -215,12 +215,12 @@ resize(size_type new_size) ...@@ -215,12 +215,12 @@ resize(size_type new_size)
catch(insert_error& ) catch(insert_error& )
{ {
m_size = old_size; m_size = old_size;
throw resize_error(); __throw_resize_error();
} }
catch(...) catch(...)
{ {
m_size = old_size; m_size = old_size;
throw; __throw_exception_again;
} }
} }
......
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
namespace pb_ds namespace pb_ds
{ {
#if __EXCEPTIONS
// Base class for exceptions. // Base class for exceptions.
struct container_error : public std::logic_error struct container_error : public std::logic_error
{ {
...@@ -69,6 +71,42 @@ namespace pb_ds ...@@ -69,6 +71,42 @@ namespace pb_ds
// A container cannot be resized. // A container cannot be resized.
struct resize_error : public container_error { }; struct resize_error : public container_error { };
void
__throw_container_error(void)
{ throw container_error(); }
void
__throw_insert_error(void)
{ throw insert_error(); }
void
__throw_join_error(void)
{ throw join_error(); }
void
__throw_resize_error(void)
{ throw resize_error(); }
#else
void
__throw_container_error(void)
{ std::abort(); }
void
__throw_insert_error(void)
{ std::abort(); }
void
__throw_join_error(void)
{ std::abort(); }
void
__throw_resize_error(void)
{ std::abort(); }
#endif
} // namespace pb_ds } // namespace pb_ds
#endif #endif
...@@ -101,59 +101,59 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -101,59 +101,59 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
#else #else
void void
__throw_bad_exception(void) __throw_bad_exception(void)
{ abort(); } { std::abort(); }
void void
__throw_bad_alloc(void) __throw_bad_alloc(void)
{ abort(); } { std::abort(); }
void void
__throw_bad_cast(void) __throw_bad_cast(void)
{ abort(); } { std::abort(); }
void void
__throw_bad_typeid(void) __throw_bad_typeid(void)
{ abort(); } { std::abort(); }
void void
__throw_logic_error(const char*) __throw_logic_error(const char*)
{ abort(); } { std::abort(); }
void void
__throw_domain_error(const char*) __throw_domain_error(const char*)
{ abort(); } { std::abort(); }
void void
__throw_invalid_argument(const char*) __throw_invalid_argument(const char*)
{ abort(); } { std::abort(); }
void void
__throw_length_error(const char*) __throw_length_error(const char*)
{ abort(); } { std::abort(); }
void void
__throw_out_of_range(const char*) __throw_out_of_range(const char*)
{ abort(); } { std::abort(); }
void void
__throw_runtime_error(const char*) __throw_runtime_error(const char*)
{ abort(); } { std::abort(); }
void void
__throw_range_error(const char*) __throw_range_error(const char*)
{ abort(); } { std::abort(); }
void void
__throw_overflow_error(const char*) __throw_overflow_error(const char*)
{ abort(); } { std::abort(); }
void void
__throw_underflow_error(const char*) __throw_underflow_error(const char*)
{ abort(); } { std::abort(); }
void void
__throw_ios_failure(const char*) __throw_ios_failure(const char*)
{ abort(); } { std::abort(); }
#endif //__EXCEPTIONS #endif //__EXCEPTIONS
_GLIBCXX_END_NAMESPACE _GLIBCXX_END_NAMESPACE
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