+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
{
_GLIBCXX_DEBUG_ONLY(map_debug_base::clear();)
s_node_allocator.deallocate(m_p_head, 1);
- throw;
+ __throw_exception_again;
}
_GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();)
}
catch(...)
{
s_node_allocator.deallocate(p_ret, 1);
- throw;
+ __throw_exception_again;
}
p_ret->m_p_left = p_ret->m_p_right = NULL;
catch(...)
{
clear_imp(p_ret);
- throw;
+ __throw_exception_again;
}
if (p_ret->m_p_left != NULL)
join_prep(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
-
- if (other.m_size == 0)
- return (false);
+ _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ if (other.m_size == 0)
+ return false;
if (m_size == 0)
{
value_swap(other);
-
- return (false);
+ return false;
}
- 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));
+ 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));
- 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));
+ 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));
- if (!greater&& !lesser)
- throw join_error();
+ if (!greater && !lesser)
+ __throw_join_error();
if (lesser)
value_swap(other);
m_size += other.m_size;
-
_GLIBCXX_DEBUG_ONLY(map_debug_base::join(other);)
-
- return (true);
+ return true;
}
PB_DS_CLASS_T_DEC
join_finish(PB_DS_CLASS_C_DEC& other)
{
initialize_min_max();
-
other.initialize();
}
split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
-
- other.clear();
+ _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ other.clear();
if (m_size == 0)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
-
- return (false);
+ _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ return false;
}
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_left->m_value)))
{
value_swap(other);
-
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
-
- return (false);
+ _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ return false;
}
- if (!Cmp_Fn::operator()(
- r_key,
- PB_DS_V2F(m_p_head->m_p_right->m_value)))
+ if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_right->m_value)))
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
-
- return (false);
+ _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ return false;
}
if (m_size == 1)
{
value_swap(other);
-
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
-
- return (false);
+ _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ return false;
}
- _GLIBCXX_DEBUG_ONLY(map_debug_base::split(
- r_key,(Cmp_Fn& )(*this),
- other);)
-
- return (true);
+ _GLIBCXX_DEBUG_ONLY(map_debug_base::split(r_key,(Cmp_Fn& )(*this), other);)
+ return true;
}
PB_DS_CLASS_T_DEC
split_finish(PB_DS_CLASS_C_DEC& other)
{
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;
-
initialize_min_max();
-
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
- }
+ _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+}
PB_DS_CLASS_T_DEC
typename PB_DS_CLASS_C_DEC::size_type
PB_DS_CLASS_C_DEC::
-recursive_count(node_pointer p_nd) const
+recursive_count(node_pointer p) const
{
- if (p_nd == NULL)
- return (0);
-
- return (1 +
- recursive_count(p_nd->m_p_left) +
- recursive_count(p_nd->m_p_right));
+ if (p == NULL)
+ return 0;
+ return 1 + recursive_count(p->m_p_left) + recursive_count(p->m_p_right);
}
while (first_it != last_it)
{
insert_value(*first_it, s_no_throw_copies_ind);
-
++first_it;
}
std::make_heap(m_a_entries, m_a_entries + m_size, static_cast<entry_cmp& >(*this));
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- }
+}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
m_a_entries(s_entry_allocator.allocate(m_actual_size))
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- }
+}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
m_a_entries(s_entry_allocator.allocate(m_actual_size))
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- }
+}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
m_a_entries(s_entry_allocator.allocate(m_actual_size))
{
_GLIBCXX_DEBUG_ONLY(other.assert_valid();)
- _GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
+ _GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
const_iterator first_it = other.begin();
const_iterator last_it = other.end();
while (first_it != last_it)
{
insert_value(*first_it, s_no_throw_copies_ind);
-
++first_it;
}
}
erase_at(m_a_entries, i, s_no_throw_copies_ind);
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
-
- throw;
+ __throw_exception_again;
}
-
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- }
+}
PB_DS_CLASS_T_DEC
void
swap(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
- _GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
+ _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ _GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
value_swap(other);
-
std::swap((entry_cmp& )(*this), (entry_cmp& )other);
-
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
- }
+ _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+}
PB_DS_CLASS_T_DEC
void
value_swap(PB_DS_CLASS_C_DEC& other)
{
std::swap(m_a_entries, other.m_a_entries);
-
std::swap(m_size, other.m_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
{
for (size_type i = 0; i < m_size; ++i)
erase_at(m_a_entries, i, s_no_throw_copies_ind);
-
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
}
if (a_other_entries != NULL)
s_entry_allocator.deallocate(a_other_entries, other_actual_size);
- throw;
+ __throw_exception_again;
};
for (size_type i = 0; i < other.m_size; ++i)
join(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
- const size_type size = m_size + other.m_size;
+ const size_type size = m_size + other.m_size;
const size_type actual_size = resize_policy::get_new_size_for_arbitrary(size);
entry_pointer a_entries = NULL;
try
{
a_entries = s_entry_allocator.allocate(actual_size);
-
a_other_entries = s_entry_allocator.allocate(resize_policy::min_size);
}
catch(...)
if (a_other_entries != NULL)
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);
other.notify_arbitrary(resize_policy::min_size);
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
- }
+ _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+}
catch(...)
{
deallocate_all();
- throw;
+ __throw_exception_again;
}
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
}
catch(...)
{
ranged_hash_fn_base::notify_resized(old_size);
- throw;
+ __throw_exception_again;
}
// At this point no exceptions can be thrown.
catch(...)
{
deallocate_all();
- throw;
+ __throw_exception_again;
}
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();)
}
}
resize_base::notify_insert_search_end();
if (ins_pos == m_num_e)
- throw insert_error();
+ __throw_insert_error();
return ins_pos;
}
}
resize_base::notify_insert_search_end();
if (ins_pos == m_num_e)
- throw insert_error();
+ __throw_insert_error();
return std::make_pair(ins_pos, pos_hash_pair.second);
}
m_num_e = old_size;
s_entry_allocator.deallocate(a_entries_resized, new_size);
ranged_probe_fn_base::notify_resized(old_size);
- throw;
+ __throw_exception_again;
}
// At this point no exceptions can be thrown.
_GLIBCXX_DEBUG_ASSERT(0);
};
}
- throw insert_error();
+ __throw_insert_error();
}
_GLIBCXX_DEBUG_ASSERT(0);
};
}
- throw insert_error();
+ __throw_insert_error();
}
m_size(0)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- }
+}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
m_size(0)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- }
+}
PB_DS_CLASS_T_DEC
PB_DS_CLASS_C_DEC::
-left_child_next_sibling_heap_(const PB_DS_CLASS_C_DEC& other) :
- Cmp_Fn(other),
- m_p_root(NULL),
- m_size(0)
+left_child_next_sibling_heap_(const PB_DS_CLASS_C_DEC& other)
+: Cmp_Fn(other), m_p_root(NULL), m_size(0)
{
m_size = other.m_size;
-
_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;
-
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- }
+}
PB_DS_CLASS_T_DEC
void
swap(PB_DS_CLASS_C_DEC& other)
{
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
-
- value_swap(other);
-
+ _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+ value_swap(other);
std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
-
_GLIBCXX_DEBUG_ONLY(assert_valid();)
- _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
- }
+ _GLIBCXX_DEBUG_ONLY(other.assert_valid();)
+}
PB_DS_CLASS_T_DEC
void
value_swap(PB_DS_CLASS_C_DEC& other)
{
std::swap(m_p_root, other.m_p_root);
-
std::swap(m_size, other.m_size);
}
catch(...)
{
s_node_allocator.deallocate(p_ret, 1);
-
- throw;
+ __throw_exception_again;
}
p_ret->m_p_l_child = p_ret->m_p_next_sibling =
try
{
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);
}
catch(...)
{
clear_imp(p_ret);
-
- throw;
+ __throw_exception_again;
}
if (p_ret->m_p_l_child != NULL)
if (p_ret->m_p_next_sibling != NULL)
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_ret :
- NULL;
+ p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd ? p_ret : NULL;
- return (p_ret);
+ return p_ret;
}
catch(...)
{
deallocate_all();
- throw;
+ __throw_exception_again;
}
_GLIBCXX_DEBUG_ONLY(assert_valid();)
}
const bool lesser = Cmp_Fn::operator()(PB_DS_V2F(*(other.end() - 1)),
PB_DS_V2F(*begin()));
- if (!greater&& !lesser)
- throw join_error();
+ if (!greater && !lesser)
+ __throw_join_error();
PB_DS_CLASS_C_DEC new_this(*this, *this);
catch(...)
{
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);
{
while (child_i-- > 0)
clear_imp(a_p_children[child_i]);
- throw;
+ __throw_exception_again;
}
new (p_ret) internal_node(p_other_internal_nd->get_e_ind(),
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)
- throw join_error();
+ __throw_join_error();
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);)
catch(...)
{
s_internal_node_allocator.deallocate(p_nd, 1);
- throw;
+ __throw_exception_again;
}
}
{
const size_type next_ret = ret* m_grow_factor;
if (next_ret < ret)
- throw insert_error();
+ __throw_insert_error();
ret = next_ret;
}
return ret;
{
const size_type next_ret = ret* m_grow_factor;
if (next_ret < ret)
- throw resize_error();
+ __throw_resize_error();
if (next_ret >= size)
return (ret);
ret = next_ret;
m_next_shrink_size = old_next_shrink_size;
m_next_grow_size = old_next_grow_size;
m_resize_needed = old_resize_needed;
- throw;
+ __throw_exception_again;
}
}
detail::g_a_sizes + detail::num_distinct_sizes, n);
if (p_upper == detail::g_a_sizes + detail::num_distinct_sizes)
- throw resize_error();
+ __throw_resize_error();
return *p_upper;
}
const size_type pot = size_policy_base::get_nearest_larger_size(actual_size);
if (pot == actual_size && pot < new_size)
- throw resize_error();
+ __throw_resize_error();
actual_size = pot;
}
catch(insert_error& )
{
m_size = old_size;
- throw resize_error();
+ __throw_resize_error();
}
catch(...)
{
m_size = old_size;
- throw;
+ __throw_exception_again;
}
}
namespace pb_ds
{
+#if __EXCEPTIONS
+
// Base class for exceptions.
struct container_error : public std::logic_error
{
// A container cannot be resized.
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
#endif
#else
void
__throw_bad_exception(void)
- { abort(); }
+ { std::abort(); }
void
__throw_bad_alloc(void)
- { abort(); }
+ { std::abort(); }
void
__throw_bad_cast(void)
- { abort(); }
+ { std::abort(); }
void
__throw_bad_typeid(void)
- { abort(); }
+ { std::abort(); }
void
__throw_logic_error(const char*)
- { abort(); }
+ { std::abort(); }
void
__throw_domain_error(const char*)
- { abort(); }
+ { std::abort(); }
void
__throw_invalid_argument(const char*)
- { abort(); }
+ { std::abort(); }
void
__throw_length_error(const char*)
- { abort(); }
+ { std::abort(); }
void
__throw_out_of_range(const char*)
- { abort(); }
+ { std::abort(); }
void
__throw_runtime_error(const char*)
- { abort(); }
+ { std::abort(); }
void
__throw_range_error(const char*)
- { abort(); }
+ { std::abort(); }
void
__throw_overflow_error(const char*)
- { abort(); }
+ { std::abort(); }
void
__throw_underflow_error(const char*)
- { abort(); }
+ { std::abort(); }
void
__throw_ios_failure(const char*)
- { abort(); }
+ { std::abort(); }
#endif //__EXCEPTIONS
_GLIBCXX_END_NAMESPACE