From f5886803ed0715d8bf874b3fd39d7d0763c2fb75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Dumont?= Date: Sat, 7 May 2011 15:45:24 +0200 Subject: [PATCH] macro.h (_GLIBCXX_DEBUG_VERIFY_AT): New. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2011-05-07 François Dumont * include/debug/macro.h (_GLIBCXX_DEBUG_VERIFY_AT): New. (_GLICXX_DEBUG_VERIFY): Use latter. * include/ext/pb_ds/detail/resize_policy/ hash_load_check_resize_trigger_imp.hpp: Emit assertion on the line containing the original assert call. * include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp, find_fn_imps.hpp, insert_fn_imps.hpp, binomial_heap_base_.hpp, constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, split_join_fn_imps.hpp: Likewise. * include/ext/pb_ds/detail/cc_hash_table_map_/ erase_store_hash_fn_imps.hpp, insert_no_store_hash_fn_imps.hpp, find_fn_imps.hpp, insert_store_hash_fn_imps.hpp, debug_fn_imps.hpp, debug_no_store_hash_fn_imps.hpp, cc_ht_map_.hpp, resize_fn_imps.hpp, constructor_destructor_fn_imps.hpp, debug_store_hash_fn_imps.hpp, erase_no_store_hash_fn_imps.hpp: Likewise. * include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp, insert_join_fn_imps.hpp, pat_trie_/head.hpp, debug_fn_imps.hpp, constructors_destructor_fn_imps.hpp, pat_trie_.hpp, split_fn_imps.hpp, leaf.hpp, erase_fn_imps.hpp, node_base.hpp, internal_node.hpp: Likewise. * include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp, r_erase_fn_imps.hpp, constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, rotate_fn_imps.hpp, erase_fn_imps.hpp, bin_search_tree_.hpp, insert_fn_imps.hpp, split_join_fn_imps.hpp: Likewise. * include/ext/pb_ds/detail/gp_hash_table_map_/ erase_store_hash_fn_imps.hpp, insert_no_store_hash_fn_imps.hpp, find_fn_imps.hpp, gp_ht_map_.hpp, insert_store_hash_fn_imps.hpp, debug_fn_imps.hpp, erase_fn_imps.hpp, debug_no_store_hash_fn_imps.hpp, resize_fn_imps.hpp, constructor_destructor_fn_imps.hpp, debug_store_hash_fn_imps.hpp, erase_no_store_hash_fn_imps.hpp: Likewise. * include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp, constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, erase_fn_imps.hpp, insert_fn_imps.hpp, binary_heap_.hpp, resize_policy.hpp, split_join_fn_imps.hpp: Likewise. * include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp, find_fn_imps.hpp, insert_fn_imps.hpp, constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, pairing_heap_.hpp, split_join_fn_imps.hpp: Likewise. * include/ext/pb_ds/detail/binomial_heap_/ constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, binomial_heap_.hpp: Likewise. * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ erase_fn_imps.hpp, left_child_next_sibling_heap_.hpp, constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp: Likewise. * include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp, find_fn_imps.hpp, thin_heap_.hpp, insert_fn_imps.hpp, constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, split_join_fn_imps.hpp: Likewise. * include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp, ov_tree_map_.hpp, constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, split_join_fn_imps.hpp, info_fn_imps.hpp: Likewise. * include/ext/pb_ds/detail/debug_map_base.hpp: Likewise. * include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp, find_fn_imps.hpp, insert_fn_imps.hpp, constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, splay_fn_imps.hpp, split_join_fn_imps.hpp, splay_tree_.hpp: Likewise. * include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp, find_fn_imps.hpp, lu_map_.hpp, constructor_destructor_fn_imps.hpp, insert_fn_imps.hpp, debug_fn_imps.hpp: Likewise. * include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp, rc_binomial_heap_.hpp, insert_fn_imps.hpp, constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, rc.hpp, split_join_fn_imps.hpp: Likewise. * include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp, insert_fn_imps.hpp, constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, rb_tree_.hpp, split_join_fn_imps.hpp: Likewise. * include/ext/pb_ds/hash_policy.hpp: Likewise. From-SVN: r173529 --- libstdc++-v3/ChangeLog | 72 +++++++++ libstdc++-v3/include/debug/macros.h | 11 +- .../bin_search_tree_/bin_search_tree_.hpp | 69 +++++--- .../constructors_destructor_fn_imps.hpp | 22 +-- .../detail/bin_search_tree_/debug_fn_imps.hpp | 147 +++++++++--------- .../detail/bin_search_tree_/erase_fn_imps.hpp | 12 +- .../detail/bin_search_tree_/find_fn_imps.hpp | 26 ++-- .../bin_search_tree_/insert_fn_imps.hpp | 73 ++++----- .../bin_search_tree_/r_erase_fn_imps.hpp | 10 +- .../bin_search_tree_/rotate_fn_imps.hpp | 19 ++- .../bin_search_tree_/split_join_fn_imps.hpp | 38 +++-- .../detail/binary_heap_/binary_heap_.hpp | 15 +- .../constructors_destructor_fn_imps.hpp | 21 +-- .../detail/binary_heap_/debug_fn_imps.hpp | 16 +- .../detail/binary_heap_/erase_fn_imps.hpp | 14 +- .../detail/binary_heap_/find_fn_imps.hpp | 6 +- .../detail/binary_heap_/insert_fn_imps.hpp | 12 +- .../detail/binary_heap_/resize_policy.hpp | 33 ++-- .../binary_heap_/split_join_fn_imps.hpp | 20 +-- .../detail/binomial_heap_/binomial_heap_.hpp | 8 +- .../constructors_destructor_fn_imps.hpp | 8 +- .../detail/binomial_heap_/debug_fn_imps.hpp | 6 +- .../binomial_heap_base_.hpp | 25 ++- .../constructors_destructor_fn_imps.hpp | 26 ++-- .../binomial_heap_base_/debug_fn_imps.hpp | 40 ++--- .../binomial_heap_base_/erase_fn_imps.hpp | 34 ++-- .../binomial_heap_base_/find_fn_imps.hpp | 6 +- .../binomial_heap_base_/insert_fn_imps.hpp | 24 +-- .../split_join_fn_imps.hpp | 36 ++--- .../detail/cc_hash_table_map_/cc_ht_map_.hpp | 61 +++++--- .../constructor_destructor_fn_imps.hpp | 27 ++-- .../cc_hash_table_map_/debug_fn_imps.hpp | 16 +- .../debug_no_store_hash_fn_imps.hpp | 7 +- .../debug_store_hash_fn_imps.hpp | 9 +- .../erase_no_store_hash_fn_imps.hpp | 22 +-- .../erase_store_hash_fn_imps.hpp | 20 +-- .../cc_hash_table_map_/find_fn_imps.hpp | 6 +- .../insert_no_store_hash_fn_imps.hpp | 8 +- .../insert_store_hash_fn_imps.hpp | 8 +- .../cc_hash_table_map_/resize_fn_imps.hpp | 13 +- .../ext/pb_ds/detail/debug_map_base.hpp | 94 ++++++----- .../constructor_destructor_fn_imps.hpp | 25 +-- .../gp_hash_table_map_/debug_fn_imps.hpp | 9 +- .../debug_no_store_hash_fn_imps.hpp | 11 +- .../debug_store_hash_fn_imps.hpp | 13 +- .../gp_hash_table_map_/erase_fn_imps.hpp | 6 +- .../erase_no_store_hash_fn_imps.hpp | 7 +- .../erase_store_hash_fn_imps.hpp | 5 +- .../gp_hash_table_map_/find_fn_imps.hpp | 8 +- .../detail/gp_hash_table_map_/gp_ht_map_.hpp | 64 +++++--- .../insert_no_store_hash_fn_imps.hpp | 10 +- .../insert_store_hash_fn_imps.hpp | 12 +- .../gp_hash_table_map_/resize_fn_imps.hpp | 12 +- .../constructors_destructor_fn_imps.hpp | 18 +-- .../debug_fn_imps.hpp | 40 +++-- .../erase_fn_imps.hpp | 4 +- .../left_child_next_sibling_heap_.hpp | 22 ++- .../constructor_destructor_fn_imps.hpp | 19 +-- .../detail/list_update_map_/debug_fn_imps.hpp | 8 +- .../detail/list_update_map_/erase_fn_imps.hpp | 9 +- .../detail/list_update_map_/find_fn_imps.hpp | 6 +- .../list_update_map_/insert_fn_imps.hpp | 10 +- .../pb_ds/detail/list_update_map_/lu_map_.hpp | 30 +++- .../constructors_destructor_fn_imps.hpp | 38 ++--- .../detail/ov_tree_map_/debug_fn_imps.hpp | 27 ++-- .../detail/ov_tree_map_/erase_fn_imps.hpp | 22 ++- .../detail/ov_tree_map_/info_fn_imps.hpp | 4 +- .../detail/ov_tree_map_/ov_tree_map_.hpp | 61 +++++--- .../ov_tree_map_/split_join_fn_imps.hpp | 34 ++-- .../constructors_destructor_fn_imps.hpp | 26 ++-- .../detail/pairing_heap_/debug_fn_imps.hpp | 8 +- .../detail/pairing_heap_/erase_fn_imps.hpp | 43 +++-- .../detail/pairing_heap_/find_fn_imps.hpp | 6 +- .../detail/pairing_heap_/insert_fn_imps.hpp | 22 +-- .../detail/pairing_heap_/pairing_heap_.hpp | 45 ++++-- .../pairing_heap_/split_join_fn_imps.hpp | 50 +++--- .../constructors_destructor_fn_imps.hpp | 20 +-- .../pb_ds/detail/pat_trie_/debug_fn_imps.hpp | 45 +++--- .../pb_ds/detail/pat_trie_/erase_fn_imps.hpp | 52 +++---- .../pb_ds/detail/pat_trie_/find_fn_imps.hpp | 18 +-- .../ext/pb_ds/detail/pat_trie_/head.hpp | 13 +- .../detail/pat_trie_/insert_join_fn_imps.hpp | 84 +++++----- .../pb_ds/detail/pat_trie_/internal_node.hpp | 33 ++-- .../ext/pb_ds/detail/pat_trie_/leaf.hpp | 53 ++++--- .../ext/pb_ds/detail/pat_trie_/node_base.hpp | 13 +- .../ext/pb_ds/detail/pat_trie_/pat_trie_.hpp | 45 +++++- .../pb_ds/detail/pat_trie_/split_fn_imps.hpp | 40 ++--- .../constructors_destructor_fn_imps.hpp | 14 +- .../detail/rb_tree_map_/debug_fn_imps.hpp | 27 ++-- .../detail/rb_tree_map_/erase_fn_imps.hpp | 16 +- .../detail/rb_tree_map_/insert_fn_imps.hpp | 8 +- .../pb_ds/detail/rb_tree_map_/rb_tree_.hpp | 28 +++- .../rb_tree_map_/split_join_fn_imps.hpp | 55 +++---- .../constructors_destructor_fn_imps.hpp | 27 ++-- .../rc_binomial_heap_/debug_fn_imps.hpp | 26 ++-- .../rc_binomial_heap_/erase_fn_imps.hpp | 4 +- .../rc_binomial_heap_/insert_fn_imps.hpp | 22 +-- .../ext/pb_ds/detail/rc_binomial_heap_/rc.hpp | 47 +++--- .../rc_binomial_heap_/rc_binomial_heap_.hpp | 18 ++- .../rc_binomial_heap_/split_join_fn_imps.hpp | 24 +-- .../hash_load_check_resize_trigger_imp.hpp | 55 ++++--- .../constructors_destructor_fn_imps.hpp | 18 +-- .../detail/splay_tree_/debug_fn_imps.hpp | 21 +-- .../detail/splay_tree_/erase_fn_imps.hpp | 20 +-- .../pb_ds/detail/splay_tree_/find_fn_imps.hpp | 7 +- .../detail/splay_tree_/insert_fn_imps.hpp | 13 +- .../detail/splay_tree_/splay_fn_imps.hpp | 70 ++++----- .../pb_ds/detail/splay_tree_/splay_tree_.hpp | 33 +++- .../detail/splay_tree_/split_join_fn_imps.hpp | 26 ++-- .../constructors_destructor_fn_imps.hpp | 14 +- .../pb_ds/detail/thin_heap_/debug_fn_imps.hpp | 57 ++++--- .../pb_ds/detail/thin_heap_/erase_fn_imps.hpp | 45 +++--- .../pb_ds/detail/thin_heap_/find_fn_imps.hpp | 6 +- .../detail/thin_heap_/insert_fn_imps.hpp | 52 +++---- .../detail/thin_heap_/split_join_fn_imps.hpp | 36 ++--- .../pb_ds/detail/thin_heap_/thin_heap_.hpp | 31 +++- .../include/ext/pb_ds/hash_policy.hpp | 4 +- 117 files changed, 1764 insertions(+), 1350 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ea642a1df74..af2f9b9a410 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,75 @@ +2011-05-07 François Dumont + + * include/debug/macro.h (_GLIBCXX_DEBUG_VERIFY_AT): New. + (_GLICXX_DEBUG_VERIFY): Use latter. + * include/ext/pb_ds/detail/resize_policy/ + hash_load_check_resize_trigger_imp.hpp: Emit assertion on the line + containing the original assert call. + * include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp, + find_fn_imps.hpp, insert_fn_imps.hpp, binomial_heap_base_.hpp, + constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, + split_join_fn_imps.hpp: Likewise. + * include/ext/pb_ds/detail/cc_hash_table_map_/ + erase_store_hash_fn_imps.hpp, insert_no_store_hash_fn_imps.hpp, + find_fn_imps.hpp, insert_store_hash_fn_imps.hpp, debug_fn_imps.hpp, + debug_no_store_hash_fn_imps.hpp, cc_ht_map_.hpp, resize_fn_imps.hpp, + constructor_destructor_fn_imps.hpp, debug_store_hash_fn_imps.hpp, + erase_no_store_hash_fn_imps.hpp: Likewise. + * include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp, + insert_join_fn_imps.hpp, pat_trie_/head.hpp, debug_fn_imps.hpp, + constructors_destructor_fn_imps.hpp, pat_trie_.hpp, split_fn_imps.hpp, + leaf.hpp, erase_fn_imps.hpp, node_base.hpp, internal_node.hpp: + Likewise. + * include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp, + r_erase_fn_imps.hpp, constructors_destructor_fn_imps.hpp, + debug_fn_imps.hpp, rotate_fn_imps.hpp, erase_fn_imps.hpp, + bin_search_tree_.hpp, insert_fn_imps.hpp, split_join_fn_imps.hpp: + Likewise. + * include/ext/pb_ds/detail/gp_hash_table_map_/ + erase_store_hash_fn_imps.hpp, insert_no_store_hash_fn_imps.hpp, + find_fn_imps.hpp, gp_ht_map_.hpp, insert_store_hash_fn_imps.hpp, + debug_fn_imps.hpp, erase_fn_imps.hpp, debug_no_store_hash_fn_imps.hpp, + resize_fn_imps.hpp, constructor_destructor_fn_imps.hpp, + debug_store_hash_fn_imps.hpp, erase_no_store_hash_fn_imps.hpp: + Likewise. + * include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp, + constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, + erase_fn_imps.hpp, insert_fn_imps.hpp, binary_heap_.hpp, + resize_policy.hpp, split_join_fn_imps.hpp: Likewise. + * include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp, + find_fn_imps.hpp, insert_fn_imps.hpp, + constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, + pairing_heap_.hpp, split_join_fn_imps.hpp: Likewise. + * include/ext/pb_ds/detail/binomial_heap_/ + constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, + binomial_heap_.hpp: Likewise. + * include/ext/pb_ds/detail/left_child_next_sibling_heap_/ + erase_fn_imps.hpp, left_child_next_sibling_heap_.hpp, + constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp: Likewise. + * include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp, + find_fn_imps.hpp, thin_heap_.hpp, insert_fn_imps.hpp, + constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, + split_join_fn_imps.hpp: Likewise. + * include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp, + ov_tree_map_.hpp, constructors_destructor_fn_imps.hpp, + debug_fn_imps.hpp, split_join_fn_imps.hpp, info_fn_imps.hpp: Likewise. + * include/ext/pb_ds/detail/debug_map_base.hpp: Likewise. + * include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp, + find_fn_imps.hpp, insert_fn_imps.hpp, + constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, + splay_fn_imps.hpp, split_join_fn_imps.hpp, splay_tree_.hpp: Likewise. + * include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp, + find_fn_imps.hpp, lu_map_.hpp, constructor_destructor_fn_imps.hpp, + insert_fn_imps.hpp, debug_fn_imps.hpp: Likewise. + * include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp, + rc_binomial_heap_.hpp, insert_fn_imps.hpp, + constructors_destructor_fn_imps.hpp, debug_fn_imps.hpp, rc.hpp, + split_join_fn_imps.hpp: Likewise. + * include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp, + insert_fn_imps.hpp, constructors_destructor_fn_imps.hpp, + debug_fn_imps.hpp, rb_tree_.hpp, split_join_fn_imps.hpp: Likewise. + * include/ext/pb_ds/hash_policy.hpp: Likewise. + 2011-05-06 Paolo Carlini * testsuite/22_locale/messages_byname/named_equivalence.cc: Fix. diff --git a/libstdc++-v3/include/debug/macros.h b/libstdc++-v3/include/debug/macros.h index c90bec5cf01..391839bcad8 100644 --- a/libstdc++-v3/include/debug/macros.h +++ b/libstdc++-v3/include/debug/macros.h @@ -1,6 +1,6 @@ // Debugging support implementation -*- C++ -*- -// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -39,14 +39,17 @@ * the user error and where the error is reported. * */ -#define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \ - do \ +#define _GLIBCXX_DEBUG_VERIFY_AT(_Condition,_ErrorMessage,_File,_Line) \ + do \ { \ if (! (_Condition)) \ - __gnu_debug::_Error_formatter::_M_at(__FILE__, __LINE__) \ + __gnu_debug::_Error_formatter::_M_at(_File, _Line) \ ._ErrorMessage._M_error(); \ } while (false) +#define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Condition,_ErrorMessage,__FILE__,__LINE__) + // Verify that [_First, _Last) forms a valid iterator range. #define __glibcxx_check_valid_range(_First,_Last) \ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last), \ diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp index ec836922a3b..8be0f80c5b2 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -403,51 +403,58 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; void - structure_only_assert_valid() const; + structure_only_assert_valid(const char* file, int line) const; void - assert_node_consistent(const node_pointer p_nd) const; + assert_node_consistent(const node_pointer p_nd, + const char* file, int line) const; #endif private: #ifdef _GLIBCXX_DEBUG void - assert_iterators() const; + assert_iterators(const char* file, int line) const; void - assert_consistent_with_debug_base() const; + assert_consistent_with_debug_base(const char* file, int line) const; void - assert_node_consistent_with_left(const node_pointer p_nd) const; + assert_node_consistent_with_left(const node_pointer p_nd, + const char* file, int line) const; void - assert_node_consistent_with_right(const node_pointer p_nd) const; + assert_node_consistent_with_right(const node_pointer p_nd, + const char* file, int line) const; void - assert_consistent_with_debug_base(const node_pointer p_nd) const; + assert_consistent_with_debug_base(const node_pointer p_nd, + const char* file, int line) const; void - assert_min() const; + assert_min(const char* file, int line) const; void - assert_min_imp(const node_pointer p_nd) const; + assert_min_imp(const node_pointer p_nd, + const char* file, int line) const; void - assert_max() const; + assert_max(const char* file, int line) const; void - assert_max_imp(const node_pointer p_nd) const; + assert_max_imp(const node_pointer p_nd, + const char* file, int line) const; void - assert_size() const; + assert_size(const char* file, int line) const; typedef std::pair< const_pointer, const_pointer> node_consistent_t; node_consistent_t - assert_node_consistent_(const node_pointer p_nd) const; + assert_node_consistent_(const node_pointer p_nd, + const char* file, int line) const; #endif void @@ -464,6 +471,28 @@ namespace __gnu_pbds static node_allocator s_node_allocator; }; +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_STRUCT_ONLY_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.structure_only_assert_valid(__FILE__, __LINE__);) + +#define PB_DS_ASSERT_NODE_CONSISTENT(_Node) \ + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, __FILE__, __LINE__);) + +#define PB_DS_CHECK_KEY_EXISTS(_Key) \ + _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);) + +#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \ + _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \ + __FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + #include #include #include @@ -475,14 +504,16 @@ namespace __gnu_pbds #include #include +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST +#undef PB_DS_CHECK_KEY_EXISTS +#undef PB_DS_ASSERT_NODE_CONSISTENT +#undef PB_DS_STRUCT_ONLY_ASSERT_VALID +#undef PB_DS_ASSERT_VALID #undef PB_DS_CLASS_C_DEC - #undef PB_DS_CLASS_T_DEC - #undef PB_DS_CLASS_NAME - #undef PB_DS_TYPES_TRAITS_C_DEC - #undef PB_DS_DEBUG_MAP_BASE_C_DEC #ifdef PB_DS_TREE_TRACE diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp index 1aa2fd47636..d7b5985cc6d 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -48,7 +48,7 @@ PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME() : m_p_head(s_node_allocator.allocate(1)), m_size(0) { initialize(); - _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -57,7 +57,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : Cmp_Fn(r_cmp_fn), m_p_head(s_node_allocator.allocate(1)), m_size(0) { initialize(); - _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -69,7 +69,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) : m_size(0) { initialize(); - _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -88,7 +88,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : { initialize(); m_size = other.m_size; - _GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID(other) __try { @@ -104,7 +104,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : s_node_allocator.deallocate(m_p_head, 1); __throw_exception_again; } - _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -112,12 +112,12 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) + PB_DS_STRUCT_ONLY_ASSERT_VALID(other) value_swap(other); std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other); - _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) + PB_DS_STRUCT_ONLY_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC @@ -187,7 +187,7 @@ recursive_copy_node(const node_pointer p_nd) if (p_ret->m_p_right != 0) p_ret->m_p_right->m_p_parent = p_ret; - _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_ret);) + PB_DS_ASSERT_NODE_CONSISTENT(p_ret) return p_ret; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp index 2d3001a2a11..86d5c2e87f7 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,230 +43,237 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid() const +assert_valid(const char* __file, int __line) const { - structure_only_assert_valid(); - assert_consistent_with_debug_base(); - assert_size(); - assert_iterators(); + structure_only_assert_valid(__file, __line); + assert_consistent_with_debug_base(__file, __line); + assert_size(__file, __line); + assert_iterators(__file, __line); if (m_p_head->m_p_parent == 0) { - _GLIBCXX_DEBUG_ASSERT(m_size == 0); + PB_DS_DEBUG_VERIFY(m_size == 0); } else { - _GLIBCXX_DEBUG_ASSERT(m_size > 0); + PB_DS_DEBUG_VERIFY(m_size > 0); } } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -structure_only_assert_valid() const +structure_only_assert_valid(const char* __file, int __line) const { - _GLIBCXX_DEBUG_ASSERT(m_p_head != 0); + PB_DS_DEBUG_VERIFY(m_p_head != 0); if (m_p_head->m_p_parent == 0) { - _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_left == m_p_head); - _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right == m_p_head); + PB_DS_DEBUG_VERIFY(m_p_head->m_p_left == m_p_head); + PB_DS_DEBUG_VERIFY(m_p_head->m_p_right == m_p_head); } else { - _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent->m_p_parent == m_p_head); - _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_left != m_p_head); - _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right != m_p_head); + PB_DS_DEBUG_VERIFY(m_p_head->m_p_parent->m_p_parent == m_p_head); + PB_DS_DEBUG_VERIFY(m_p_head->m_p_left != m_p_head); + PB_DS_DEBUG_VERIFY(m_p_head->m_p_right != m_p_head); } if (m_p_head->m_p_parent != 0) - assert_node_consistent(m_p_head->m_p_parent); - assert_min(); - assert_max(); + assert_node_consistent(m_p_head->m_p_parent, __file, __line); + assert_min(__file, __line); + assert_max(__file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_node_consistent(const node_pointer p_nd) const +assert_node_consistent(const node_pointer p_nd, + const char* __file, int __line) const { - assert_node_consistent_(p_nd); + assert_node_consistent_(p_nd, __file, __line); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::node_consistent_t PB_DS_CLASS_C_DEC:: -assert_node_consistent_(const node_pointer p_nd) const +assert_node_consistent_(const node_pointer p_nd, + const char* __file, int __line) const { if (p_nd == 0) return (std::make_pair((const_pointer)0,(const_pointer)0)); - assert_node_consistent_with_left(p_nd); - assert_node_consistent_with_right(p_nd); + assert_node_consistent_with_left(p_nd, __file, __line); + assert_node_consistent_with_right(p_nd, __file, __line); const std::pair - l_range = assert_node_consistent_(p_nd->m_p_left); + l_range = assert_node_consistent_(p_nd->m_p_left, __file, __line); if (l_range.second != 0) - _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*l_range.second), - PB_DS_V2F(p_nd->m_value))); + PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*l_range.second), + PB_DS_V2F(p_nd->m_value))); const std::pair - r_range = assert_node_consistent_(p_nd->m_p_right); + r_range = assert_node_consistent_(p_nd->m_p_right, __file, __line); if (r_range.first != 0) - _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), + PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), PB_DS_V2F(*r_range.first))); - return (std::make_pair((l_range.first != 0)? l_range.first :& p_nd->m_value,(r_range.second != 0)? r_range.second :& p_nd->m_value)); + return std::make_pair((l_range.first != 0) ? l_range.first : &p_nd->m_value, + (r_range.second != 0)? r_range.second : &p_nd->m_value); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_node_consistent_with_left(const node_pointer p_nd) const +assert_node_consistent_with_left(const node_pointer p_nd, + const char* __file, int __line) const { if (p_nd->m_p_left == 0) return; - _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left->m_p_parent == p_nd); - _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), - PB_DS_V2F(p_nd->m_p_left->m_value))); + PB_DS_DEBUG_VERIFY(p_nd->m_p_left->m_p_parent == p_nd); + PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), + PB_DS_V2F(p_nd->m_p_left->m_value))); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_node_consistent_with_right(const node_pointer p_nd) const +assert_node_consistent_with_right(const node_pointer p_nd, + const char* __file, int __line) const { if (p_nd->m_p_right == 0) return; - _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_right->m_p_parent == p_nd); - _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_p_right->m_value), - PB_DS_V2F(p_nd->m_value))); + PB_DS_DEBUG_VERIFY(p_nd->m_p_right->m_p_parent == p_nd); + PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_p_right->m_value), + PB_DS_V2F(p_nd->m_value))); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_min() const +assert_min(const char* __file, int __line) const { - assert_min_imp(m_p_head->m_p_parent); + assert_min_imp(m_p_head->m_p_parent, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_min_imp(const node_pointer p_nd) const +assert_min_imp(const node_pointer p_nd, const char* __file, int __line) const { if (p_nd == 0) { - _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_left == m_p_head); + PB_DS_DEBUG_VERIFY(m_p_head->m_p_left == m_p_head); return; } if (p_nd->m_p_left == 0) { - _GLIBCXX_DEBUG_ASSERT(p_nd == m_p_head->m_p_left); + PB_DS_DEBUG_VERIFY(p_nd == m_p_head->m_p_left); return; } - assert_min_imp(p_nd->m_p_left); + assert_min_imp(p_nd->m_p_left, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_max() const +assert_max(const char* __file, int __line) const { - assert_max_imp(m_p_head->m_p_parent); + assert_max_imp(m_p_head->m_p_parent, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_max_imp(const node_pointer p_nd) const +assert_max_imp(const node_pointer p_nd, + const char* __file, int __line) const { if (p_nd == 0) { - _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_right == m_p_head); + PB_DS_DEBUG_VERIFY(m_p_head->m_p_right == m_p_head); return; } if (p_nd->m_p_right == 0) { - _GLIBCXX_DEBUG_ASSERT(p_nd == m_p_head->m_p_right); + PB_DS_DEBUG_VERIFY(p_nd == m_p_head->m_p_right); return; } - assert_max_imp(p_nd->m_p_right); + assert_max_imp(p_nd->m_p_right, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_iterators() const +assert_iterators(const char* __file, int __line) const { size_type iterated_num = 0; const_iterator prev_it = end(); for (const_iterator it = begin(); it != end(); ++it) { ++iterated_num; - _GLIBCXX_DEBUG_ASSERT(lower_bound(PB_DS_V2F(*it)).m_p_nd == it.m_p_nd); + PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)).m_p_nd == it.m_p_nd); const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it)); --upper_bound_it; - _GLIBCXX_DEBUG_ASSERT(upper_bound_it.m_p_nd == it.m_p_nd); + PB_DS_DEBUG_VERIFY(upper_bound_it.m_p_nd == it.m_p_nd); if (prev_it != end()) - _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*prev_it), - PB_DS_V2F(*it))); + PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*prev_it), + PB_DS_V2F(*it))); prev_it = it; } - _GLIBCXX_DEBUG_ASSERT(iterated_num == m_size); + PB_DS_DEBUG_VERIFY(iterated_num == m_size); size_type reverse_iterated_num = 0; const_reverse_iterator reverse_prev_it = rend(); for (const_reverse_iterator reverse_it = rbegin(); reverse_it != rend(); ++reverse_it) { ++reverse_iterated_num; - _GLIBCXX_DEBUG_ASSERT(lower_bound( + PB_DS_DEBUG_VERIFY(lower_bound( PB_DS_V2F(*reverse_it)).m_p_nd == reverse_it.m_p_nd); const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*reverse_it)); --upper_bound_it; - _GLIBCXX_DEBUG_ASSERT(upper_bound_it.m_p_nd == reverse_it.m_p_nd); + PB_DS_DEBUG_VERIFY(upper_bound_it.m_p_nd == reverse_it.m_p_nd); if (reverse_prev_it != rend()) - _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(PB_DS_V2F(*reverse_prev_it), - PB_DS_V2F(*reverse_it))); + PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(*reverse_prev_it), + PB_DS_V2F(*reverse_it))); reverse_prev_it = reverse_it; } - _GLIBCXX_DEBUG_ASSERT(reverse_iterated_num == m_size); + PB_DS_DEBUG_VERIFY(reverse_iterated_num == m_size); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_consistent_with_debug_base() const +assert_consistent_with_debug_base(const char* __file, int __line) const { - debug_base::check_size(m_size); - assert_consistent_with_debug_base(m_p_head->m_p_parent); + debug_base::check_size(m_size, __file, __line); + assert_consistent_with_debug_base(m_p_head->m_p_parent, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_consistent_with_debug_base(const node_pointer p_nd) const +assert_consistent_with_debug_base(const node_pointer p_nd, + const char* __file, int __line) const { if (p_nd == 0) return; - debug_base::check_key_exists(PB_DS_V2F(p_nd->m_value)); - assert_consistent_with_debug_base(p_nd->m_p_left); - assert_consistent_with_debug_base(p_nd->m_p_right); + debug_base::check_key_exists(PB_DS_V2F(p_nd->m_value), __file, __line); + assert_consistent_with_debug_base(p_nd->m_p_left, __file, __line); + assert_consistent_with_debug_base(p_nd->m_p_right, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_size() const +assert_size(const char* __file, int __line) const { - _GLIBCXX_DEBUG_ASSERT(recursive_count(m_p_head->m_p_parent) == m_size); + PB_DS_DEBUG_VERIFY(recursive_count(m_p_head->m_p_parent) == m_size); } -#endif +#endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp index 86a663ee620..60a54903458 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -46,7 +46,7 @@ actual_erase_node(node_pointer p_z) _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; - _GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value))); + _GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value));) p_z->~node(); @@ -88,9 +88,9 @@ void PB_DS_CLASS_C_DEC:: clear() { - _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) - clear_imp(m_p_head->m_p_parent); + clear_imp(m_p_head->m_p_parent); m_size = 0; @@ -98,8 +98,8 @@ clear() _GLIBCXX_DEBUG_ONLY(debug_base::clear();) - _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) - } + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) +} PB_DS_CLASS_T_DEC void diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp index 082c7f0f79d..6b50dc8c594 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -133,9 +133,9 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) { - _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) - node_pointer p_pot = m_p_head; + node_pointer p_pot = m_p_head; node_pointer p_nd = m_p_head->m_p_parent; while (p_nd != 0) @@ -148,10 +148,10 @@ find(const_key_reference r_key) else p_nd = p_nd->m_p_right; - return point_iterator((p_pot != m_p_head&& Cmp_Fn::operator()( - r_key, - PB_DS_V2F(p_pot->m_value)))? - m_p_head : p_pot); + return point_iterator((p_pot != m_p_head + && Cmp_Fn::operator()(r_key, + PB_DS_V2F(p_pot->m_value))) + ? m_p_head : p_pot); } PB_DS_CLASS_T_DEC @@ -159,9 +159,9 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) const { - _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) - node_pointer p_pot = m_p_head; + node_pointer p_pot = m_p_head; node_pointer p_nd = m_p_head->m_p_parent; while (p_nd != 0) @@ -174,9 +174,9 @@ find(const_key_reference r_key) const else p_nd = p_nd->m_p_right; - return const_point_iterator((p_pot != m_p_head&& Cmp_Fn::operator()( - r_key, - PB_DS_V2F(p_pot->m_value)))? - m_p_head : p_pot); + return const_point_iterator((p_pot != m_p_head + && Cmp_Fn::operator()(r_key, + PB_DS_V2F(p_pot->m_value))) + ? m_p_head : p_pot); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp index 0c25ad23569..eb0f76d0ea2 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,19 +43,17 @@ inline std::pair PB_DS_CLASS_C_DEC:: insert_leaf(const_reference r_value) { - _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) - if (m_size == 0) - return (std::make_pair( - insert_imp_empty(r_value), - true)); + if (m_size == 0) + return std::make_pair(insert_imp_empty(r_value), + true); node_pointer p_nd = m_p_head->m_p_parent; node_pointer p_pot = m_p_head; while (p_nd != 0) - if (!Cmp_Fn::operator()( - PB_DS_V2F(p_nd->m_value), + if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), PB_DS_V2F(r_value))) { p_pot = p_nd; @@ -66,37 +64,29 @@ insert_leaf(const_reference r_value) p_nd = p_nd->m_p_right; if (p_pot == m_p_head) - return (std::make_pair( - insert_leaf_new(r_value, m_p_head->m_p_right, false), - true)); + return std::make_pair(insert_leaf_new(r_value, m_p_head->m_p_right, false), + true); - if (!Cmp_Fn::operator()( - PB_DS_V2F(r_value), + if (!Cmp_Fn::operator()(PB_DS_V2F(r_value), PB_DS_V2F(p_pot->m_value))) { - _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) - - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists( - PB_DS_V2F(r_value))); - - return (std::make_pair(p_pot, false)); + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) + PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_value)) + return std::make_pair(p_pot, false); } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist( - PB_DS_V2F(r_value))); + PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value)) p_nd = p_pot->m_p_left; if (p_nd == 0) - return (std::make_pair( - insert_leaf_new(r_value, p_pot, true), - true)); + return std::make_pair(insert_leaf_new(r_value, p_pot, true), + true); while (p_nd->m_p_right != 0) p_nd = p_nd->m_p_right; - return (std::make_pair( - insert_leaf_new(r_value, p_nd, false), - true)); + return std::make_pair(insert_leaf_new(r_value, p_nd, false), + true); } PB_DS_CLASS_T_DEC @@ -105,7 +95,8 @@ PB_DS_CLASS_C_DEC:: insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd) { node_pointer p_new_nd = - get_new_node_for_leaf_insert( r_value, traits_base::m_no_throw_copies_indicator); + get_new_node_for_leaf_insert(r_value, + traits_base::m_no_throw_copies_indicator); if (left_nd) { @@ -136,14 +127,13 @@ insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd) p_new_nd->m_p_left = p_new_nd->m_p_right = 0; - _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_nd)); + PB_DS_ASSERT_NODE_CONSISTENT(p_nd) update_to_top(p_new_nd, (node_update* )this); - _GLIBCXX_DEBUG_ONLY(debug_base::insert_new( - PB_DS_V2F(r_value))); + _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));) - return (iterator(p_new_nd)); + return iterator(p_new_nd); } PB_DS_CLASS_T_DEC @@ -152,7 +142,7 @@ PB_DS_CLASS_C_DEC:: insert_imp_empty(const_reference r_value) { node_pointer p_new_node = - get_new_node_for_leaf_insert( r_value, traits_base::m_no_throw_copies_indicator); + get_new_node_for_leaf_insert(r_value, traits_base::m_no_throw_copies_indicator); m_p_head->m_p_left = m_p_head->m_p_right = m_p_head->m_p_parent = p_new_node; @@ -161,12 +151,11 @@ insert_imp_empty(const_reference r_value) p_new_node->m_p_left = p_new_node->m_p_right = 0; - _GLIBCXX_DEBUG_ONLY(debug_base::insert_new( - PB_DS_V2F(r_value))); + _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));) - update_to_top(m_p_head->m_p_parent, (node_update* )this); + update_to_top(m_p_head->m_p_parent, (node_update*)this); - return (iterator(p_new_node)); + return iterator(p_new_node); } PB_DS_CLASS_T_DEC @@ -178,8 +167,7 @@ get_new_node_for_leaf_insert(const_reference r_val, false_type) cond_dealtor_t cond(p_new_nd); - new (const_cast( - static_cast(&p_new_nd->m_value))) + new (const_cast(static_cast(&p_new_nd->m_value))) typename node::value_type(r_val); cond.set_no_action(); @@ -188,7 +176,7 @@ get_new_node_for_leaf_insert(const_reference r_val, false_type) ++m_size; - return (p_new_nd); + return p_new_nd; } PB_DS_CLASS_T_DEC @@ -198,14 +186,13 @@ get_new_node_for_leaf_insert(const_reference r_val, true_type) { node_pointer p_new_nd = s_node_allocator.allocate(1); - new (const_cast( - static_cast(&p_new_nd->m_value))) + new (const_cast(static_cast(&p_new_nd->m_value))) typename node::value_type(r_val); p_new_nd->m_p_left = p_new_nd->m_p_right = 0; ++m_size; - return (p_new_nd); + return p_new_nd; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp index 3bdd1ebff14..bcf3ce6321f 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -46,7 +46,7 @@ actual_erase_node(node_pointer p_z) _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; - _GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value))); + _GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value));) p_z->~node(); @@ -88,7 +88,7 @@ void PB_DS_CLASS_C_DEC:: clear() { - _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) clear_imp(m_p_head->m_p_parent); @@ -98,8 +98,8 @@ clear() _GLIBCXX_DEBUG_ONLY(debug_base::clear();) - _GLIBCXX_DEBUG_ONLY(structure_only_assert_valid();) - } + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) +} PB_DS_CLASS_T_DEC void diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp index 6989ca6858b..c2090a17842 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -62,10 +62,10 @@ rotate_left(node_pointer p_x) p_y->m_p_left = p_x; p_x->m_p_parent = p_y; - _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);) - _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);) + PB_DS_ASSERT_NODE_CONSISTENT(p_x) + PB_DS_ASSERT_NODE_CONSISTENT(p_y) - apply_update(p_x, (node_update* )this); + apply_update(p_x, (node_update* )this); apply_update(p_x->m_p_parent, (node_update* )this); } @@ -93,10 +93,10 @@ rotate_right(node_pointer p_x) p_y->m_p_right = p_x; p_x->m_p_parent = p_y; - _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);) - _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y);) + PB_DS_ASSERT_NODE_CONSISTENT(p_x) + PB_DS_ASSERT_NODE_CONSISTENT(p_y) - apply_update(p_x, (node_update* )this); + apply_update(p_x, (node_update* )this); apply_update(p_x->m_p_parent, (node_update* )this); } @@ -129,9 +129,8 @@ inline void PB_DS_CLASS_C_DEC:: apply_update(node_pointer p_nd, Node_Update_* /*p_update*/) { - node_update::operator()( - node_iterator(p_nd), - const_node_iterator(static_cast(0))); + node_update::operator()(node_iterator(p_nd), + const_node_iterator(static_cast(0))); } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp index 11dc30860ae..00fbdf42612 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,8 +43,8 @@ bool PB_DS_CLASS_C_DEC:: join_prep(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) if (other.m_size == 0) return false; @@ -54,9 +54,13 @@ join_prep(PB_DS_CLASS_C_DEC& other) 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(); @@ -83,37 +87,37 @@ bool PB_DS_CLASS_C_DEC:: split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) other.clear(); if (m_size == 0) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) 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();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) return false; } 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();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) return false; } if (m_size == 1) { value_swap(other); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) return false; } @@ -130,8 +134,8 @@ split_finish(PB_DS_CLASS_C_DEC& other) 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();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp index 576cba265e7..e728e20c6c1 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -310,7 +310,7 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; #endif #ifdef PB_DS_BINARY_HEAP_TRACE_ @@ -335,6 +335,15 @@ namespace __gnu_pbds entry_pointer m_a_entries; }; +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + #include #include #include @@ -346,6 +355,8 @@ namespace __gnu_pbds #include #include +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_ASSERT_VALID #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC #undef PB_DS_ENTRY_CMP_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp index a77a02521b0..bdaa7ff7806 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp @@ -1,6 +1,7 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011 +// Free Software Foundation, Inc. // // 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 @@ -64,7 +65,7 @@ copy_from_range(It first_it, It last_it) std::make_heap(m_a_entries, m_a_entries + m_size, static_cast(*this)); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -74,7 +75,7 @@ binary_heap_() : m_actual_size(resize_policy::min_size), m_a_entries(s_entry_allocator.allocate(m_actual_size)) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -85,7 +86,7 @@ binary_heap_(const Cmp_Fn& r_cmp_fn) : m_actual_size(resize_policy::min_size), m_a_entries(s_entry_allocator.allocate(m_actual_size)) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -97,7 +98,7 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) : m_actual_size(other.m_actual_size), m_a_entries(s_entry_allocator.allocate(m_actual_size)) { - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID(other) _GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries); const_iterator first_it = other.begin(); @@ -119,7 +120,7 @@ binary_heap_(const PB_DS_CLASS_C_DEC& other) : s_entry_allocator.deallocate(m_a_entries, m_actual_size); __throw_exception_again; } - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -127,14 +128,14 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) _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();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp index fcfecfd5034..a2c6f307f17 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -43,14 +43,14 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid() const +assert_valid(const char* __file, int __line) const { #ifdef PB_DS_REGRESSION s_entry_allocator.check_allocated(m_a_entries, m_actual_size); #endif - resize_policy::assert_valid(); - _GLIBCXX_DEBUG_ASSERT(m_size <= m_actual_size); + resize_policy::assert_valid(__file, __line); + PB_DS_DEBUG_VERIFY(m_size <= m_actual_size); for (size_type i = 0; i < m_size; ++i) { #ifdef PB_DS_REGRESSION @@ -58,14 +58,14 @@ assert_valid() const #endif if (left_child(i) < m_size) - _GLIBCXX_DEBUG_ASSERT(!entry_cmp::operator()(m_a_entries[i], m_a_entries[left_child(i)])); + PB_DS_DEBUG_VERIFY(!entry_cmp::operator()(m_a_entries[i], m_a_entries[left_child(i)])); - _GLIBCXX_DEBUG_ASSERT(parent(left_child(i)) == i); + PB_DS_DEBUG_VERIFY(parent(left_child(i)) == i); if (right_child(i) < m_size) - _GLIBCXX_DEBUG_ASSERT(!entry_cmp::operator()(m_a_entries[i], m_a_entries[right_child(i)])); + PB_DS_DEBUG_VERIFY(!entry_cmp::operator()(m_a_entries[i], m_a_entries[right_child(i)])); - _GLIBCXX_DEBUG_ASSERT(parent(right_child(i)) == i); + PB_DS_DEBUG_VERIFY(parent(right_child(i)) == i); } } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp index a8426511908..2b6c9b79849 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp @@ -66,7 +66,7 @@ clear() m_size = 0; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -89,7 +89,7 @@ inline void PB_DS_CLASS_C_DEC:: pop() { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!empty()); erase_at(m_a_entries, 0, s_no_throw_copies_ind); @@ -102,7 +102,7 @@ pop() _GLIBCXX_DEBUG_ASSERT(m_size > 0); --m_size; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -111,7 +111,7 @@ typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) typedef typename entry_pred::type pred_t; @@ -148,7 +148,7 @@ erase_if(Pred pred) std::make_heap(m_a_entries, m_a_entries + m_size, static_cast(*this)); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return ersd; } @@ -158,7 +158,7 @@ inline void PB_DS_CLASS_C_DEC:: erase(point_iterator it) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!empty()); const size_type fix_pos = it.m_p_e - m_a_entries; @@ -177,7 +177,7 @@ erase(point_iterator it) if (fix_pos != m_size) fix(m_a_entries + fix_pos); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp index 28d4a8c80f5..116e9bcddaa 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -43,8 +43,8 @@ inline typename PB_DS_CLASS_C_DEC::const_reference PB_DS_CLASS_C_DEC:: top() const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ASSERT(!empty()); + PB_DS_ASSERT_VALID((*this)) + _GLIBCXX_DEBUG_ASSERT(!empty()); return top_imp(s_no_throw_copies_ind); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp index f13a3cb1985..c6c41e57264 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -43,11 +43,11 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: push(const_reference r_val) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) insert_value(r_val, s_no_throw_copies_ind); std::push_heap(m_a_entries, m_a_entries + m_size, static_cast(*this)); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return point_iterator(m_a_entries); } @@ -108,10 +108,10 @@ void PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) swap_value_imp(it.m_p_e, r_new_val, s_no_throw_copies_ind); fix(it.m_p_e); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -131,7 +131,7 @@ fix(entry_pointer p_e) parent_i = parent(i); } - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/resize_policy.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/resize_policy.hpp index 588fb3d1d80..e1961272f73 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/resize_policy.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/resize_policy.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -52,6 +52,15 @@ namespace __gnu_pbds #define PB_DS_CLASS_C_DEC resize_policy +#define PB_DS_ASSERT_VALID(X)\ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + template class resize_policy { @@ -102,7 +111,7 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; #endif #ifdef PB_DS_BINARY_HEAP_TRACE_ @@ -128,7 +137,7 @@ namespace __gnu_pbds resize_policy() : m_next_shrink_size(0), m_next_grow_size(min_size) - { _GLIBCXX_DEBUG_ONLY(assert_valid();) } + { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void @@ -188,11 +197,11 @@ namespace __gnu_pbds PB_DS_CLASS_C_DEC:: notify_grow_resize() { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= min_size); m_next_grow_size *= factor; m_next_shrink_size = m_next_grow_size / ratio; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -200,14 +209,14 @@ namespace __gnu_pbds PB_DS_CLASS_C_DEC:: notify_shrink_resize() { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) m_next_shrink_size /= factor; if (m_next_shrink_size == 1) m_next_shrink_size = 0; m_next_grow_size = std::max(m_next_grow_size / factor, static_cast(min_size)); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -217,19 +226,19 @@ namespace __gnu_pbds { m_next_grow_size = actual_size; m_next_shrink_size = m_next_grow_size / ratio; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } #ifdef _GLIBCXX_DEBUG PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: - assert_valid() const + assert_valid(const char* __file, int __line) const { - _GLIBCXX_DEBUG_ASSERT(m_next_shrink_size == 0 || + PB_DS_DEBUG_VERIFY(m_next_shrink_size == 0 || m_next_shrink_size* ratio == m_next_grow_size); - _GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= min_size); + PB_DS_DEBUG_VERIFY(m_next_grow_size >= min_size); } #endif @@ -244,6 +253,8 @@ namespace __gnu_pbds } #endif +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_ASSERT_VALID #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp index a2974429f57..675b4ec40db 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -45,9 +45,9 @@ void PB_DS_CLASS_C_DEC:: split(Pred pred, PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - typedef + typedef typename entry_pred< value_type, Pred, @@ -114,17 +114,17 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) resize_policy::notify_arbitrary(m_actual_size); other.notify_arbitrary(other.m_actual_size); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) +} PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) const size_type len = m_size + other.m_size; const size_type actual_size = resize_policy::get_new_size_for_arbitrary(len); @@ -167,7 +167,7 @@ join(PB_DS_CLASS_C_DEC& other) other.notify_arbitrary(resize_policy::min_size); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp index 3b4d6e91e85..c618a555afe 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -100,13 +100,17 @@ namespace __gnu_pbds protected: #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; #endif }; +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + #include #include +#undef PB_DS_ASSERT_VALID #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp index ef0937e42ea..ebe1f2e9ea8 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -41,19 +41,19 @@ PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binomial_heap_() -{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binomial_heap_(const Cmp_Fn& r_cmp_fn) : PB_DS_BASE_C_DEC(r_cmp_fn) -{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binomial_heap_(const PB_DS_CLASS_C_DEC& other) : PB_DS_BASE_C_DEC(other) -{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp index 10bec6959bb..80c0b048632 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -43,7 +43,7 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid() const -{ base_type::assert_valid(true); } +assert_valid(const char* __file, int __line) const +{ base_type::assert_valid(true, __file, __line); } #endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp index 1d66d1b14bc..0a1af721e10 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -187,10 +187,10 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid(bool strictly_binomial) const; + assert_valid(bool strictly_binomial, const char* file, int line) const; void - assert_max() const; + assert_max(const char* file, int line) const; #endif private: @@ -209,13 +209,27 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_node_consistent(const_node_pointer, bool, bool) const; + assert_node_consistent(const_node_pointer, bool, bool, + const char*, int) const; #endif protected: node_pointer m_p_max; }; +#define PB_DS_ASSERT_VALID(X, _StrictlyBinomial) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(_StrictlyBinomial,__FILE__, __LINE__);) + +#define PB_DS_ASSERT_BASE_NODE_CONSISTENT(_Node, _Bool) \ + _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, _Bool, \ + __FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + #include #include #include @@ -223,6 +237,9 @@ namespace __gnu_pbds #include #include +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_ASSERT_BASE_NODE_CONSISTENT +#undef PB_DS_ASSERT_VALID #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC #undef PB_DS_BASE_C_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp index 08cc43738b6..3e6df18ddca 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -47,16 +47,16 @@ copy_from_range(It first_it, It last_it) while (first_it != last_it) push(*(first_it++)); - _GLIBCXX_DEBUG_ONLY(assert_valid(false);) - } + PB_DS_ASSERT_VALID((*this),false) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: binomial_heap_base_() : m_p_max(0) { - _GLIBCXX_DEBUG_ONLY(assert_valid(false);) - } + PB_DS_ASSERT_VALID((*this),false) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -64,8 +64,8 @@ binomial_heap_base_(const Cmp_Fn& r_cmp_fn) : PB_DS_BASE_C_DEC(r_cmp_fn), m_p_max(0) { - _GLIBCXX_DEBUG_ONLY(assert_valid(false);) - } + PB_DS_ASSERT_VALID((*this),false) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -73,22 +73,22 @@ binomial_heap_base_(const PB_DS_CLASS_C_DEC& other) : PB_DS_BASE_C_DEC(other), m_p_max(0) { - _GLIBCXX_DEBUG_ONLY(assert_valid(false);) - } + PB_DS_ASSERT_VALID((*this),false) +} PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid(false);) + PB_DS_ASSERT_VALID((*this),false) - base_type::swap(other); + base_type::swap(other); std::swap(m_p_max, other.m_p_max); - _GLIBCXX_DEBUG_ONLY(assert_valid(false);) - } + PB_DS_ASSERT_VALID((*this),false) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp index 6cf01e00c5d..6f2aa2a7983 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -44,54 +44,56 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid(bool strictly_binomial) const +assert_valid(bool strictly_binomial, const char* __file, int __line) const { - base_type::assert_valid(); - assert_node_consistent(base_type::m_p_root, strictly_binomial, true); - assert_max(); + base_type::assert_valid(__file, __line); + assert_node_consistent(base_type::m_p_root, strictly_binomial, true, + __file, __line); + assert_max(__file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_max() const +assert_max(const char* __file, int __line) const { if (m_p_max == 0) return; - _GLIBCXX_DEBUG_ASSERT(base_type::parent(m_p_max) == 0); + PB_DS_DEBUG_VERIFY(base_type::parent(m_p_max) == 0); for (const_iterator it = base_type::begin(); it != base_type::end(); ++it) - _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(m_p_max->m_value, - it.m_p_nd->m_value)); + PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(m_p_max->m_value, + it.m_p_nd->m_value)); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: assert_node_consistent(const_node_pointer p_nd, bool strictly_binomial, - bool increasing) const + bool increasing, const char* __file, int __line) const { - _GLIBCXX_DEBUG_ASSERT(increasing || strictly_binomial); - base_type::assert_node_consistent(p_nd, false); + PB_DS_DEBUG_VERIFY(increasing || strictly_binomial); + base_type::assert_node_consistent(p_nd, false, __file, __line); if (p_nd == 0) return; - _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == base_type::degree(p_nd)); - _GLIBCXX_DEBUG_ASSERT(base_type::size_under_node(p_nd) == + PB_DS_DEBUG_VERIFY(p_nd->m_metadata == base_type::degree(p_nd)); + PB_DS_DEBUG_VERIFY(base_type::size_under_node(p_nd) == static_cast(1 << p_nd->m_metadata)); - assert_node_consistent(p_nd->m_p_next_sibling, strictly_binomial, increasing); - assert_node_consistent(p_nd->m_p_l_child, true, false); + assert_node_consistent(p_nd->m_p_next_sibling, strictly_binomial, increasing, + __file, __line); + assert_node_consistent(p_nd->m_p_l_child, true, false, __file, __line); if (p_nd->m_p_next_sibling != 0) { if (increasing) { if (strictly_binomial) - _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata + PB_DS_DEBUG_VERIFY(p_nd->m_metadata < p_nd->m_p_next_sibling->m_metadata); else - _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata + PB_DS_DEBUG_VERIFY(p_nd->m_metadata <= p_nd->m_p_next_sibling->m_metadata); } else - _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata + PB_DS_DEBUG_VERIFY(p_nd->m_metadata > p_nd->m_p_next_sibling->m_metadata); } } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp index df0ea6bdccd..05c8e075b17 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,8 +43,8 @@ void PB_DS_CLASS_C_DEC:: pop() { - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) - _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); + PB_DS_ASSERT_VALID((*this),true) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); if (m_p_max == 0) find_max(); @@ -59,8 +59,8 @@ pop() m_p_max = 0; - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) - } + PB_DS_ASSERT_VALID((*this),true) +} PB_DS_CLASS_T_DEC void @@ -113,8 +113,8 @@ void PB_DS_CLASS_C_DEC:: erase(point_iterator it) { - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) - _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); + PB_DS_ASSERT_VALID((*this),true) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); base_type::bubble_to_top(it.m_p_nd); @@ -124,8 +124,8 @@ erase(point_iterator it) m_p_max = 0; - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) - } + PB_DS_ASSERT_VALID((*this),true) +} PB_DS_CLASS_T_DEC template @@ -133,14 +133,14 @@ typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) + PB_DS_ASSERT_VALID((*this),true) - if (base_type::empty()) - { - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) + if (base_type::empty()) + { + PB_DS_ASSERT_VALID((*this),true) - return 0; - } + return 0; + } base_type::to_linked_list(); @@ -185,8 +185,8 @@ erase_if(Pred pred) m_p_max = 0; - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) + PB_DS_ASSERT_VALID((*this),true) - return ersd; + return ersd; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp index 48409d831e0..3f300dca290 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,8 +43,8 @@ inline typename PB_DS_CLASS_C_DEC::const_reference PB_DS_CLASS_C_DEC:: top() const { - _GLIBCXX_DEBUG_ONLY(assert_valid(false);) - _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); + PB_DS_ASSERT_VALID((*this),false) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); if (m_p_max == 0) const_cast(this)->find_max(); diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp index 1ccaddf4354..2d40cd4fd15 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,17 +43,17 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: push(const_reference r_val) { - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) + PB_DS_ASSERT_VALID((*this),true) - node_pointer p_nd = base_type::get_new_node_for_insert(r_val); + node_pointer p_nd = base_type::get_new_node_for_insert(r_val); insert_node(p_nd); m_p_max = 0; - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) + PB_DS_ASSERT_VALID((*this),true) - return point_iterator(p_nd); + return point_iterator(p_nd); } PB_DS_CLASS_T_DEC @@ -171,13 +171,13 @@ void PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) - node_pointer p_nd = it.m_p_nd; + PB_DS_ASSERT_VALID((*this),true) + node_pointer p_nd = it.m_p_nd; _GLIBCXX_DEBUG_ASSERT(p_nd != 0); - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false);) + PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd, false) - const bool bubble_up = Cmp_Fn::operator()(p_nd->m_value, r_new_val); + const bool bubble_up = Cmp_Fn::operator()(p_nd->m_value, r_new_val); p_nd->m_value = r_new_val; @@ -198,7 +198,7 @@ modify(point_iterator it, const_reference r_new_val) m_p_max = 0; - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) + PB_DS_ASSERT_VALID((*this),true) return; } @@ -211,6 +211,6 @@ modify(point_iterator it, const_reference r_new_val) m_p_max = 0; - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) - } + PB_DS_ASSERT_VALID((*this),true) +} diff --git a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp index 9f7e36e2b8f..405e59385dd 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -44,17 +44,17 @@ void PB_DS_CLASS_C_DEC:: split(Pred pred, PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) - _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) + PB_DS_ASSERT_VALID((*this),true) + PB_DS_ASSERT_VALID(other,true) - other.clear(); + other.clear(); if (base_type::empty()) { - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) - _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) + PB_DS_ASSERT_VALID((*this),true) + PB_DS_ASSERT_VALID(other,true) - return; + return; } base_type::to_linked_list(); @@ -86,9 +86,9 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) p_out = p_next; } - _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) + PB_DS_ASSERT_VALID(other,true) - node_pointer p_cur = base_type::m_p_root; + node_pointer p_cur = base_type::m_p_root; base_type::m_p_root = 0; @@ -114,19 +114,19 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) m_p_max = 0; - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) - _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) - } + PB_DS_ASSERT_VALID((*this),true) + PB_DS_ASSERT_VALID(other,true) +} PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) - _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) + PB_DS_ASSERT_VALID((*this),true) + PB_DS_ASSERT_VALID(other,true) - node_pointer p_other = other.m_p_root; + node_pointer p_other = other.m_p_root; if (p_other != 0) do @@ -147,9 +147,9 @@ join(PB_DS_CLASS_C_DEC& other) other.m_size = 0; other.m_p_max = 0; - _GLIBCXX_DEBUG_ONLY(assert_valid(true);) - _GLIBCXX_DEBUG_ONLY(other.assert_valid(true);) - } + PB_DS_ASSERT_VALID((*this),true) + PB_DS_ASSERT_VALID(other,true) +} PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp index 4529a15f4f2..47abe513508 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp @@ -1,6 +1,7 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011 +// Free Software Foundation, Inc. // // 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 @@ -98,7 +99,15 @@ namespace __gnu_pbds #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_V2F(X) (X) #define PB_DS_V2S(X) Mapped_Data() -#endif +#endif + +#define PB_DS_CHECK_KEY_EXISTS(_Key) \ + _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);) + +#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \ + _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \ + __FILE__, __LINE__);) + // <011i$i0|\|-<|-|4i|\|i|\|g |-|4$|-| 74813. templatem_value.second); } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return insert_new_imp(value_type(r_key, mapped_type()), pos)->second; } inline mapped_reference subscript_imp(const_key_reference r_key, true_type) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key); entry_pointer p_e = m_entries[pos_hash_pair.first]; resize_base::notify_insert_search_start(); @@ -409,11 +418,11 @@ namespace __gnu_pbds resize_base::notify_insert_search_end(); if (p_e != 0) { - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) + PB_DS_CHECK_KEY_EXISTS(r_key) return p_e->m_value.second; } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return insert_new_imp(value_type(r_key, mapped_type()), pos_hash_pair)->second; } @@ -440,7 +449,7 @@ namespace __gnu_pbds resize_base::notify_inserted(++m_num_used_e); _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) - _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) return &p_e->m_value; } @@ -459,7 +468,7 @@ namespace __gnu_pbds m_entries[r_pos_hash_pair.first] = p_e; resize_base::notify_inserted(++m_num_used_e); _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) - _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) return &p_e->m_value; } @@ -479,9 +488,9 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG if (p_e == 0) - debug_base::check_key_does_not_exist(r_key); + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) else - debug_base::check_key_exists(r_key); + PB_DS_CHECK_KEY_EXISTS(r_key) #endif return &p_e->m_value; } @@ -505,9 +514,9 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG if (p_e == 0) - debug_base::check_key_does_not_exist(r_key); + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) else - debug_base::check_key_exists(r_key); + PB_DS_CHECK_KEY_EXISTS(r_key) #endif return &p_e->m_value; } @@ -568,13 +577,16 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_entry_pointer_array_valid(const entry_pointer_array) const; + assert_entry_pointer_array_valid(const entry_pointer_array, + const char* file, int line) const; void - assert_entry_pointer_valid(const entry_pointer, true_type) const; + assert_entry_pointer_valid(const entry_pointer, true_type, + const char* file, int line) const; void - assert_entry_pointer_valid(const entry_pointer, false_type) const; + assert_entry_pointer_valid(const entry_pointer, false_type, + const char* file, int line) const; #endif #ifdef PB_DS_HT_MAP_TRACE_ @@ -609,6 +621,15 @@ namespace __gnu_pbds PB_DS_STATIC_ASSERT(sth, store_hash_ok); }; +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + #include #include #include @@ -621,6 +642,10 @@ namespace __gnu_pbds #include #include +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_ASSERT_VALID +#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST +#undef PB_DS_CHECK_KEY_EXISTS #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #undef PB_DS_HASH_EQ_FN_C_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp index 88a56800390..8278fd7e662 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -66,7 +66,7 @@ PB_DS_CLASS_NAME() : m_entries(s_entry_pointer_allocator.allocate(m_num_e)) { initialize(); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -77,7 +77,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn) : m_entries(s_entry_pointer_allocator.allocate(m_num_e)) { initialize(); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -91,7 +91,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) : std::fill(m_entries, m_entries + m_num_e, (entry_pointer)0); Resize_Policy::notify_cleared(); ranged_hash_fn_base::notify_resized(m_num_e); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -104,7 +104,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash m_entries(s_entry_pointer_allocator.allocate(m_num_e)) { initialize(); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -118,22 +118,19 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Hash m_entries(s_entry_pointer_allocator.allocate(m_num_e)) { initialize(); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : -#ifdef _GLIBCXX_DEBUG - debug_base(other), -#endif PB_DS_HASH_EQ_FN_C_DEC(other), resize_base(other), ranged_hash_fn_base(other), m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0), m_entries(s_entry_pointer_allocator.allocate(m_num_e)) { initialize(); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) __try { copy_from_range(other.begin(), other.end()); @@ -143,7 +140,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : deallocate_all(); __throw_exception_again; } - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -156,8 +153,8 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid()); - _GLIBCXX_DEBUG_ONLY(other.assert_valid()); + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) std::swap(m_entries, other.m_entries); std::swap(m_num_e, other.m_num_e); @@ -167,8 +164,8 @@ swap(PB_DS_CLASS_C_DEC& other) resize_base::swap(other); _GLIBCXX_DEBUG_ONLY(debug_base::swap(other)); - _GLIBCXX_DEBUG_ONLY(assert_valid()); - _GLIBCXX_DEBUG_ONLY(other.assert_valid()); + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp index b42ed7aa8a2..d10ff7862cc 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,16 +43,17 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid() const +assert_valid(const char* __file, int __line) const { - debug_base::check_size(m_num_used_e); - assert_entry_pointer_array_valid(m_entries); + debug_base::check_size(m_num_used_e, __file, __line); + assert_entry_pointer_array_valid(m_entries, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries) const +assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries, + const char* __file, int __line) const { size_type iterated_num_used_e = 0; for (size_type pos = 0; pos < m_num_e; ++pos) @@ -61,11 +62,12 @@ assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries) const while (p_e != 0) { ++iterated_num_used_e; - assert_entry_pointer_valid(p_e, traits_base::m_store_extra_indicator); + assert_entry_pointer_valid(p_e, traits_base::m_store_extra_indicator, + __file, __line); p_e = p_e->m_p_next; } } - _GLIBCXX_DEBUG_ASSERT(iterated_num_used_e == m_num_used_e); + PB_DS_DEBUG_VERIFY(iterated_num_used_e == m_num_used_e); } #include diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp index 770bed34ca7..4a02bbfcc5d 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -43,7 +43,8 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_entry_pointer_valid(const entry_pointer p, false_type) const -{ debug_base::check_key_exists(PB_DS_V2F(p->m_value)); } +assert_entry_pointer_valid(const entry_pointer p, false_type, + const char* __file, int __line) const +{ debug_base::check_key_exists(PB_DS_V2F(p->m_value), __file, __line); } #endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp index 3d17671e91d..07f2998bcec 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -43,11 +43,12 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_entry_pointer_valid(const entry_pointer p_e, true_type) const +assert_entry_pointer_valid(const entry_pointer p_e, true_type, + const char* __file, int __line) const { - debug_base::check_key_exists(PB_DS_V2F(p_e->m_value)); + debug_base::check_key_exists(PB_DS_V2F(p_e->m_value), __file, __line); comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value)); - _GLIBCXX_DEBUG_ASSERT(p_e->m_hash == pos_hash_pair.second); + PB_DS_DEBUG_VERIFY(p_e->m_hash == pos_hash_pair.second); } #endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp index 4f513e998bd..ffe32103cbe 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -44,7 +44,7 @@ inline bool PB_DS_CLASS_C_DEC:: erase(const_key_reference r_key) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return erase_in_pos_imp(r_key, ranged_hash_fn_base::operator()(r_key)); } @@ -53,24 +53,24 @@ inline bool PB_DS_CLASS_C_DEC:: erase_in_pos_imp(const_key_reference r_key, size_type pos) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) entry_pointer p_e = m_entries[pos]; resize_base::notify_erase_search_start(); if (p_e == 0) { resize_base::notify_erase_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) + PB_DS_ASSERT_VALID((*this)) return false; } if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key)) { resize_base::notify_erase_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base:: check_key_exists(r_key);) + PB_DS_CHECK_KEY_EXISTS(r_key) erase_entry_pointer(m_entries[pos]); do_resize_if_needed_no_throw(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return true; } @@ -80,18 +80,18 @@ erase_in_pos_imp(const_key_reference r_key, size_type pos) if (p_next_e == 0) { resize_base::notify_erase_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) + PB_DS_ASSERT_VALID((*this)) return false; } if (hash_eq_fn_base::operator()(PB_DS_V2F(p_next_e->m_value), r_key)) { resize_base::notify_erase_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) + PB_DS_CHECK_KEY_EXISTS(r_key) erase_entry_pointer(p_e->m_p_next); do_resize_if_needed_no_throw(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return true; } resize_base::notify_erase_search_collision(); diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp index 6e21aceb988..09d34f2c0b1 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -44,14 +44,14 @@ inline bool PB_DS_CLASS_C_DEC:: erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) entry_pointer p_e = m_entries[r_pos_hash_pair.first]; resize_base::notify_erase_search_start(); if (p_e == 0) { resize_base::notify_erase_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base:: check_key_does_not_exist(r_key);) - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) + PB_DS_ASSERT_VALID((*this)) return false; } @@ -59,10 +59,10 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) r_key, r_pos_hash_pair.second)) { resize_base::notify_erase_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) + PB_DS_CHECK_KEY_EXISTS(r_key) erase_entry_pointer(m_entries[r_pos_hash_pair.first]); do_resize_if_needed_no_throw(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return true; } @@ -72,8 +72,8 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) if (p_next_e == 0) { resize_base::notify_erase_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) + PB_DS_ASSERT_VALID((*this)) return false; } @@ -82,10 +82,10 @@ erase_in_pos_imp(const_key_reference r_key, const comp_hash& r_pos_hash_pair) r_pos_hash_pair.second)) { resize_base::notify_erase_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) + PB_DS_CHECK_KEY_EXISTS(r_key) erase_entry_pointer(p_e->m_p_next); do_resize_if_needed_no_throw(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return true; } resize_base::notify_erase_search_collision(); diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp index f8849418041..32ca47d6e3f 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return find_key_pointer(r_key, traits_base::m_store_extra_indicator); } @@ -52,7 +52,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return const_cast(*this).find_key_pointer(r_key, traits_base::m_store_extra_indicator); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp index 1de42e8d603..acbd8a78d07 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -44,7 +44,7 @@ inline std::pair PB_DS_CLASS_C_DEC:: insert_imp(const_reference r_val, false_type) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) const_key_reference r_key = PB_DS_V2F(r_val); const size_type pos = ranged_hash_fn_base::operator()(r_key); entry_pointer p_e = m_entries[pos]; @@ -60,11 +60,11 @@ insert_imp(const_reference r_val, false_type) resize_base::notify_insert_search_end(); if (p_e != 0) { - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) + PB_DS_CHECK_KEY_EXISTS(r_key) return std::make_pair(&p_e->m_value, false); } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return std::make_pair(insert_new_imp(r_val, pos), true); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp index c7b0bdc9a30..1224880ecc9 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -44,7 +44,7 @@ inline std::pair PB_DS_CLASS_C_DEC:: insert_imp(const_reference r_val, true_type) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) const_key_reference key = PB_DS_V2F(r_val); comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(key); entry_pointer p_e = m_entries[pos_hash_pair.first]; @@ -61,11 +61,11 @@ insert_imp(const_reference r_val, true_type) resize_base::notify_insert_search_end(); if (p_e != 0) { - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(key);) + PB_DS_CHECK_KEY_EXISTS(key) return std::make_pair(&p_e->m_value, false); } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(key);) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(key) return std::make_pair(insert_new_imp(r_val, pos_hash_pair), true); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp index 3db838bf820..4e3f48dd12d 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -71,7 +71,7 @@ do_resize_if_needed_no_throw() __catch(...) { } - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -79,7 +79,7 @@ void PB_DS_CLASS_C_DEC:: resize_imp(size_type new_size) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) if (new_size == m_num_e) return; @@ -104,7 +104,7 @@ resize_imp(size_type new_size) // At this point no exceptions can be thrown. resize_imp_no_exceptions(new_size, a_p_entries_resized, old_size); Resize_Policy::notify_resized(new_size); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -123,10 +123,11 @@ resize_imp_no_exceptions(size_type new_size, entry_pointer_array a_p_entries_res } m_num_e = new_size; - _GLIBCXX_DEBUG_ONLY(assert_entry_pointer_array_valid(a_p_entries_resized);) + _GLIBCXX_DEBUG_ONLY(assert_entry_pointer_array_valid(a_p_entries_resized, + __FILE__, __LINE__);) s_entry_pointer_allocator.deallocate(m_entries, old_size); m_entries = a_p_entries_resized; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } #include diff --git a/libstdc++-v3/include/ext/pb_ds/detail/debug_map_base.hpp b/libstdc++-v3/include/ext/pb_ds/detail/debug_map_base.hpp index 9dc76359560..1ade7957b66 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/debug_map_base.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/debug_map_base.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -51,6 +51,15 @@ #include #include +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + namespace __gnu_pbds { namespace detail @@ -98,13 +107,15 @@ namespace __gnu_pbds clear(); inline void - check_key_exists(const_key_reference r_key) const; + check_key_exists(const_key_reference r_key, + const char* file, int line) const; inline void - check_key_does_not_exist(const_key_reference r_key) const; + check_key_does_not_exist(const_key_reference r_key, + const char* file, int line) const; inline void - check_size(size_type size) const; + check_size(size_type size, const char* file, int line) const; void swap(PB_DS_CLASS_C_DEC& other); @@ -114,11 +125,11 @@ namespace __gnu_pbds split(const_key_reference, Cmp_Fn, PB_DS_CLASS_C_DEC&); void - join(PB_DS_CLASS_C_DEC& other); + join(PB_DS_CLASS_C_DEC& other, bool with_cleanup = true); private: void - assert_valid() const; + assert_valid(const char* file, int line) const; const_key_set_iterator find(const_key_reference r_key) const; @@ -133,24 +144,24 @@ namespace __gnu_pbds PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: debug_map_base() - { _GLIBCXX_DEBUG_ONLY(assert_valid();) } + { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: debug_map_base(const PB_DS_CLASS_C_DEC& other) : m_key_set(other.m_key_set) - { _GLIBCXX_DEBUG_ONLY(assert_valid();) } + { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~debug_map_base() - { _GLIBCXX_DEBUG_ONLY(assert_valid();) } + { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: insert_new(const_key_reference r_key) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) if (find(r_key) != m_key_set.end()) { @@ -169,7 +180,7 @@ namespace __gnu_pbds std::abort(); } - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -177,7 +188,7 @@ namespace __gnu_pbds PB_DS_CLASS_C_DEC:: erase_existing(const_key_reference r_key) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) key_set_iterator it = find(r_key); if (it == m_key_set.end()) { @@ -185,7 +196,7 @@ namespace __gnu_pbds std::abort(); } m_key_set.erase(it); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -193,36 +204,39 @@ namespace __gnu_pbds PB_DS_CLASS_C_DEC:: clear() { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) m_key_set.clear(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: - check_key_exists(const_key_reference r_key) const + check_key_exists(const_key_reference r_key, + const char* __file, int __line) const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + assert_valid(__file, __line); if (find(r_key) == m_key_set.end()) { - std::cerr << "check_key_exists " << r_key << std::endl; + std::cerr << __file << ':' << __line << ": check_key_exists " + << r_key << std::endl; std::abort(); } - _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: - check_key_does_not_exist(const_key_reference r_key) const + check_key_does_not_exist(const_key_reference r_key, + const char* __file, int __line) const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + assert_valid(__file, __line); if (find(r_key) != m_key_set.end()) { using std::cerr; using std::endl; - cerr << "check_key_does_not_exist " << r_key << endl; + cerr << __file << ':' << __line << ": check_key_does_not_exist " + << r_key << endl; std::abort(); } } @@ -230,17 +244,16 @@ namespace __gnu_pbds PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: - check_size(size_type size) const + check_size(size_type size, const char* __file, int __line) const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + assert_valid(__file, __line); const size_type key_set_size = m_key_set.size(); if (size != key_set_size) { - std::cerr << "check_size " << size - << " " << key_set_size << std::endl; + std::cerr << __file << ':' << __line << ": check_size " << size + << " != " << key_set_size << std::endl; std::abort(); } - _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC @@ -248,9 +261,9 @@ namespace __gnu_pbds PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) m_key_set.swap(other.m_key_set); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -258,7 +271,7 @@ namespace __gnu_pbds PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) typedef const_key_set_iterator iterator_type; for (iterator_type it = m_key_set.begin(); it != m_key_set.end(); ++it) if (m_eq(*it, r_key)) @@ -271,7 +284,7 @@ namespace __gnu_pbds PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) key_set_iterator it = m_key_set.begin(); while (it != m_key_set.end()) { @@ -280,13 +293,12 @@ namespace __gnu_pbds ++it; } return it; - _GLIBCXX_DEBUG_ONLY(assert_valid();) } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: - assert_valid() const + assert_valid(const char* __file, int __line) const { const_key_set_iterator prime_it = m_key_set.begin(); while (prime_it != m_key_set.end()) @@ -295,8 +307,8 @@ namespace __gnu_pbds ++sec_it; while (sec_it != m_key_set.end()) { - _GLIBCXX_DEBUG_ASSERT(!m_eq(*sec_it, *prime_it)); - _GLIBCXX_DEBUG_ASSERT(!m_eq(*prime_it, *sec_it)); + PB_DS_DEBUG_VERIFY(!m_eq(*sec_it, *prime_it)); + PB_DS_DEBUG_VERIFY(!m_eq(*prime_it, *sec_it)); ++sec_it; } ++prime_it; @@ -324,15 +336,18 @@ namespace __gnu_pbds PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: - join(PB_DS_CLASS_C_DEC& other) + join(PB_DS_CLASS_C_DEC& other, bool with_cleanup) { key_set_iterator it = other.m_key_set.begin(); while (it != other.m_key_set.end()) { insert_new(*it); - it = other.m_key_set.erase(it); + if (with_cleanup) + it = other.m_key_set.erase(it); + else + ++it; } - _GLIBCXX_DEBUG_ASSERT(other.m_key_set.empty()); + _GLIBCXX_DEBUG_ASSERT(!with_cleanup || other.m_key_set.empty()); } #undef PB_DS_CLASS_T_DEC @@ -341,6 +356,9 @@ namespace __gnu_pbds } // namespace detail } // namespace __gnu_pbds +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_ASSERT_VALID + #endif #endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp index 4ac145d3d54..90f17094a0f 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp @@ -1,6 +1,7 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011 +// Free Software Foundation, Inc. // // 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 @@ -61,7 +62,7 @@ PB_DS_CLASS_NAME() m_entries(s_entry_allocator.allocate(m_num_e)) { initialize(); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -72,7 +73,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn) m_entries(s_entry_allocator.allocate(m_num_e)) { initialize(); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -84,7 +85,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) m_entries(s_entry_allocator.allocate(m_num_e)) { initialize(); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -98,7 +99,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, m_entries(s_entry_allocator.allocate(m_num_e)) { initialize(); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -112,7 +113,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, m_entries(s_entry_allocator.allocate(m_num_e)) { initialize(); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -127,7 +128,7 @@ PB_DS_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, m_entries(s_entry_allocator.allocate(m_num_e)) { initialize(); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -160,7 +161,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : deallocate_all(); __throw_exception_again; } - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -173,8 +174,8 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid()); - _GLIBCXX_DEBUG_ONLY(other.assert_valid()); + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) std::swap(m_num_e, other.m_num_e); std::swap(m_num_used_e, other.m_num_used_e); std::swap(m_entries, other.m_entries); @@ -182,8 +183,8 @@ swap(PB_DS_CLASS_C_DEC& other) hash_eq_fn_base::swap(other); resize_base::swap(other); _GLIBCXX_DEBUG_ONLY(debug_base::swap(other)); - _GLIBCXX_DEBUG_ONLY(assert_valid()); - _GLIBCXX_DEBUG_ONLY(other.assert_valid()); + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp index d7018c62c40..eca853a2092 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -43,10 +43,11 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid() const +assert_valid(const char* __file, int __line) const { - debug_base::check_size(m_num_used_e); - assert_entry_array_valid(m_entries, traits_base::m_store_extra_indicator); + debug_base::check_size(m_num_used_e, __file, __line); + assert_entry_array_valid(m_entries, traits_base::m_store_extra_indicator, + __file, __line); } #include diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp index 86b4d7dafb1..ba8f54e5dea 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -43,7 +43,8 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_entry_array_valid(const entry_array a_entries, false_type) const +assert_entry_array_valid(const entry_array a_entries, false_type, + const char* __file, int __line) const { size_type iterated_num_used_e = 0; for (size_type pos = 0; pos < m_num_e; ++pos) @@ -57,15 +58,15 @@ assert_entry_array_valid(const entry_array a_entries, false_type) const case valid_entry_status: { const_key_reference r_key = PB_DS_V2F(p_e->m_value); - debug_base::check_key_exists(r_key); + debug_base::check_key_exists(r_key, __file, __line); ++iterated_num_used_e; break; } default: - _GLIBCXX_DEBUG_ASSERT(0); + PB_DS_DEBUG_VERIFY(0); }; } - _GLIBCXX_DEBUG_ASSERT(iterated_num_used_e == m_num_used_e); + PB_DS_DEBUG_VERIFY(iterated_num_used_e == m_num_used_e); } #endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp index 961f1436177..2c2833eacbf 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -43,7 +43,8 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_entry_array_valid(const entry_array a_entries, true_type) const +assert_entry_array_valid(const entry_array a_entries, true_type, + const char* __file, int __line) const { size_type iterated_num_used_e = 0; @@ -58,20 +59,20 @@ assert_entry_array_valid(const entry_array a_entries, true_type) const case valid_entry_status: { const_key_reference r_key = PB_DS_V2F(p_e->m_value); - debug_base::check_key_exists(r_key); + debug_base::check_key_exists(r_key, __file, __line); const comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key); - _GLIBCXX_DEBUG_ASSERT(p_e->m_hash == pos_hash_pair.second); + PB_DS_DEBUG_VERIFY(p_e->m_hash == pos_hash_pair.second); ++iterated_num_used_e; break; } default: - _GLIBCXX_DEBUG_ASSERT(0); + PB_DS_DEBUG_VERIFY(0); }; } - _GLIBCXX_DEBUG_ASSERT(iterated_num_used_e == m_num_used_e); + PB_DS_DEBUG_VERIFY(iterated_num_used_e == m_num_used_e); } #endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp index 68878eb2a1e..e57d5cc7f2d 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -72,7 +72,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) size_type num_ersd = 0; for (size_type pos = 0; pos < m_num_e; ++pos) { @@ -86,7 +86,7 @@ erase_if(Pred pred) } do_resize_if_needed_no_throw(); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) return num_ersd; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp index 40d578ebef5..67e64e91ab6 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -44,7 +44,7 @@ inline bool PB_DS_CLASS_C_DEC:: erase_imp(const_key_reference r_key, false_type) { - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) size_type hash = ranged_probe_fn_base::operator()(r_key); size_type i; resize_base::notify_erase_search_start(); @@ -58,8 +58,7 @@ erase_imp(const_key_reference r_key, false_type) case empty_entry_status: { resize_base::notify_erase_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist( - r_key)); + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return false; } break; diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp index 8155a526152..02dc63ea5bb 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -57,8 +57,7 @@ erase_imp(const_key_reference r_key, true_type) case empty_entry_status: { resize_base::notify_erase_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist( - r_key)); + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return false; } break; diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp index dbd056927f9..d8b32fe1719 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,8 +43,8 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - return find_key_pointer(r_key, traits_base::m_store_extra_indicator); + PB_DS_ASSERT_VALID((*this)) + return find_key_pointer(r_key, traits_base::m_store_extra_indicator); } PB_DS_CLASS_T_DEC @@ -52,7 +52,7 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return const_cast(*this).find_key_pointer(r_key, traits_base::m_store_extra_indicator); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp index 3e69b2ef059..ef3be7bd054 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp @@ -1,6 +1,7 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011 +// Free Software Foundation, Inc. // // 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 @@ -95,7 +96,14 @@ namespace __gnu_pbds #ifdef PB_DS_DATA_FALSE_INDICATOR #define PB_DS_V2F(X) (X) #define PB_DS_V2S(X) Mapped() -#endif +#endif + +#define PB_DS_CHECK_KEY_EXISTS(_Key) \ + _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);) + +#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \ + _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \ + __FILE__, __LINE__);) template insert(const_reference r_val) { - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid(__FILE__, __LINE__);) return insert_imp(r_val, traits_base::m_store_extra_indicator); } @@ -331,7 +339,7 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; #endif #ifdef PB_DS_HT_MAP_TRACE_ @@ -406,7 +414,7 @@ namespace __gnu_pbds _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(p_e->m_value));) - _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) return &p_e->m_value; } @@ -432,7 +440,7 @@ namespace __gnu_pbds _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(p_e->m_value));) - _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) return &p_e->m_value; } @@ -440,7 +448,7 @@ namespace __gnu_pbds inline mapped_reference subscript_imp(const_key_reference key, false_type) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) const size_type pos = find_ins_pos(key, traits_base::m_store_extra_indicator); @@ -449,14 +457,14 @@ namespace __gnu_pbds if (p_e->m_stat != valid_entry_status) return insert_new_imp(value_type(key, mapped_type()), pos)->second; - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(key);) + PB_DS_CHECK_KEY_EXISTS(key) return p_e->m_value.second; } inline mapped_reference subscript_imp(const_key_reference key, true_type) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) comp_hash pos_hash_pair = find_ins_pos(key, traits_base::m_store_extra_indicator); @@ -465,7 +473,7 @@ namespace __gnu_pbds return insert_new_imp(value_type(key, mapped_type()), pos_hash_pair)->second; - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(key)); + PB_DS_CHECK_KEY_EXISTS(key) return (m_entries + pos_hash_pair.first)->m_value.second; } #endif @@ -488,17 +496,15 @@ namespace __gnu_pbds case empty_entry_status: { resize_base::notify_find_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(key);) - - return 0; + PB_DS_CHECK_KEY_DOES_NOT_EXIST(key) + return 0; } break; case valid_entry_status: if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), key)) { resize_base::notify_find_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(key);) - + PB_DS_CHECK_KEY_EXISTS(key) return pointer(&p_e->m_value); } break; @@ -511,7 +517,7 @@ namespace __gnu_pbds resize_base::notify_find_search_collision(); } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(key);) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(key) resize_base::notify_find_search_end(); return 0; } @@ -536,8 +542,7 @@ namespace __gnu_pbds case empty_entry_status: { resize_base::notify_find_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(key);) - + PB_DS_CHECK_KEY_DOES_NOT_EXIST(key) return 0; } break; @@ -547,7 +552,7 @@ namespace __gnu_pbds key, pos_hash_pair.second)) { resize_base::notify_find_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(key);) + PB_DS_CHECK_KEY_EXISTS(key) return pointer(&p_e->m_value); } break; @@ -560,7 +565,7 @@ namespace __gnu_pbds resize_base::notify_find_search_collision(); } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(key);) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(key) resize_base::notify_find_search_end(); return 0; } @@ -628,10 +633,12 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_entry_array_valid(const entry_array, false_type) const; + assert_entry_array_valid(const entry_array, false_type, + const char* file, int line) const; void - assert_entry_array_valid(const entry_array, true_type) const; + assert_entry_array_valid(const entry_array, true_type, + const char* file, int line) const; #endif static entry_allocator s_entry_allocator; @@ -651,6 +658,15 @@ namespace __gnu_pbds PB_DS_STATIC_ASSERT(sth, store_hash_ok); }; +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + #include #include #include @@ -662,6 +678,10 @@ namespace __gnu_pbds #include #include +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_ASSERT_VALID +#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST +#undef PB_DS_CHECK_KEY_EXISTS #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #undef PB_DS_HASH_EQ_FN_C_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp index 3227a4aaac4..95c9054f3b7 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -62,7 +62,7 @@ find_ins_pos(const_key_reference r_key, false_type) case empty_entry_status: { resize_base::notify_insert_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return (ins_pos == m_num_e) ? pos : ins_pos; } break; @@ -74,7 +74,7 @@ find_ins_pos(const_key_reference r_key, false_type) if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key)) { resize_base::notify_insert_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) + PB_DS_CHECK_KEY_EXISTS(r_key) return pos; } break; @@ -101,11 +101,11 @@ insert_imp(const_reference r_val, false_type) if (m_entries[pos].m_stat == valid_entry_status) { - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) + PB_DS_CHECK_KEY_EXISTS(r_key) return std::make_pair(&(m_entries + pos)->m_value, false); } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key)); + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return std::make_pair(insert_new_imp(r_val, pos), true); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp index f4310b62951..a27d9d202c9 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -44,7 +44,7 @@ inline typename PB_DS_CLASS_C_DEC::comp_hash PB_DS_CLASS_C_DEC:: find_ins_pos(const_key_reference r_key, true_type) { - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key); size_type i; @@ -64,7 +64,7 @@ find_ins_pos(const_key_reference r_key, true_type) case empty_entry_status: { resize_base::notify_insert_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return ((ins_pos == m_num_e) ? std::make_pair(pos, pos_hash_pair.second) : @@ -80,7 +80,7 @@ find_ins_pos(const_key_reference r_key, true_type) r_key, pos_hash_pair.second)) { resize_base::notify_insert_search_end(); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) + PB_DS_CHECK_KEY_EXISTS(r_key) return std::make_pair(pos, pos_hash_pair.second); } break; @@ -108,11 +108,11 @@ insert_imp(const_reference r_val, true_type) entry_pointer p_e =& m_entries[pos_hash_pair.first]; if (p_e->m_stat == valid_entry_status) { - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key)); + PB_DS_CHECK_KEY_EXISTS(r_key) return std::make_pair(&p_e->m_value, false); } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key)); + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return std::make_pair(insert_new_imp(r_val, pos_hash_pair), true); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp index e1b837aa1cd..70381f10602 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -71,7 +71,7 @@ do_resize_if_needed_no_throw() __catch(...) { } - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -86,7 +86,7 @@ resize_imp(size_type new_size) if (new_size == m_num_e) return; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) const size_type old_size = m_num_e; entry_array a_entries_resized = 0; @@ -113,13 +113,15 @@ resize_imp(size_type new_size) } // At this point no exceptions can be thrown. - _GLIBCXX_DEBUG_ONLY(assert_entry_array_valid(a_entries_resized, traits_base::m_store_extra_indicator);) + _GLIBCXX_DEBUG_ONLY(assert_entry_array_valid(a_entries_resized, + traits_base::m_store_extra_indicator, + __FILE__, __LINE__);) Resize_Policy::notify_resized(new_size); erase_all_valid_entries(m_entries, old_size); s_entry_allocator.deallocate(m_entries, old_size); m_entries = a_entries_resized; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp index 5b6ada36095..5bec709fb50 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -53,7 +53,7 @@ left_child_next_sibling_heap_() : m_p_root(0), m_size(0) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -63,7 +63,7 @@ left_child_next_sibling_heap_(const Cmp_Fn& r_cmp_fn) : m_p_root(0), m_size(0) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -72,10 +72,10 @@ left_child_next_sibling_heap_(const PB_DS_CLASS_C_DEC& other) : Cmp_Fn(other), m_p_root(0), m_size(0) { m_size = other.m_size; - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID(other) m_p_root = recursive_copy_node(other.m_p_root); m_size = other.m_size; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -83,12 +83,12 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) value_swap(other); std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp index 0408d14bf7b..77c23c1eb36 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,31 +43,32 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid() const +assert_valid(const char* __file, int __line) const { - _GLIBCXX_DEBUG_ASSERT(m_p_root == 0 || m_p_root->m_p_prev_or_parent == 0); + PB_DS_DEBUG_VERIFY(m_p_root == 0 || m_p_root->m_p_prev_or_parent == 0); if (m_p_root != 0) - assert_node_consistent(m_p_root, Single_Link_Roots); - assert_size(); - assert_iterators(); + assert_node_consistent(m_p_root, Single_Link_Roots, __file, __line); + assert_size(__file, __line); + assert_iterators(__file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_node_consistent(const_node_pointer p_nd, bool single_link) const +assert_node_consistent(const_node_pointer p_nd, bool single_link, + const char* __file, int __line) const { if (p_nd == 0) return; - assert_node_consistent(p_nd->m_p_l_child, false); - assert_node_consistent(p_nd->m_p_next_sibling, single_link); + assert_node_consistent(p_nd->m_p_l_child, false, __file, __line); + assert_node_consistent(p_nd->m_p_next_sibling, single_link, __file, __line); if (single_link) - _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_prev_or_parent == 0); + PB_DS_DEBUG_VERIFY(p_nd->m_p_prev_or_parent == 0); else if (p_nd->m_p_next_sibling != 0) - _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd); + PB_DS_DEBUG_VERIFY(p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd); if (p_nd->m_p_l_child == 0) return; @@ -76,31 +77,26 @@ assert_node_consistent(const_node_pointer p_nd, bool single_link) const while (p_child != 0) { const_node_pointer p_next_child = p_child->m_p_next_sibling; - _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(p_nd->m_value, p_child->m_value)); + PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(p_nd->m_value, p_child->m_value)); p_child = p_next_child; } - _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child->m_p_prev_or_parent == p_nd); + PB_DS_DEBUG_VERIFY(p_nd->m_p_l_child->m_p_prev_or_parent == p_nd); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_iterators() const +assert_iterators(const char* __file, int __line) const { - const size_type calc_size = std::distance(begin(), end()); - if (calc_size == size()) - return; - _GLIBCXX_DEBUG_ASSERT(0); + PB_DS_DEBUG_VERIFY(std::distance(begin(), end()) == size()); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_size() const +assert_size(const char* __file, int __line) const { - if (size_from_node(m_p_root) == m_size) - return; - _GLIBCXX_DEBUG_ASSERT(0); + PB_DS_DEBUG_VERIFY(size_from_node(m_p_root) == m_size); } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp index 2d8ab2d2c6c..056cc38fc94 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -78,7 +78,7 @@ void PB_DS_CLASS_C_DEC:: to_linked_list() { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) node_pointer p_cur = m_p_root; while (p_cur != 0) if (p_cur->m_p_l_child != 0) diff --git a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp index 34ad4bee008..b433f359209 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -273,10 +273,11 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; void - assert_node_consistent(const_node_pointer p_nd, bool single_link) const; + assert_node_consistent(const_node_pointer p_nd, bool single_link, + const char* file, int line) const; static size_type size_under_node(const_node_pointer p_nd); @@ -298,10 +299,10 @@ namespace __gnu_pbds private: #ifdef _GLIBCXX_DEBUG void - assert_iterators() const; + assert_iterators(const char* file, int line) const; void - assert_size() const; + assert_size(const char* file, int line) const; static size_type size_from_node(const_node_pointer p_nd); @@ -331,6 +332,15 @@ namespace __gnu_pbds static no_throw_copies_t s_no_throw_copies_ind; }; +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + #include #include #include @@ -340,6 +350,8 @@ namespace __gnu_pbds #include #include +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_ASSERT_VALID #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp index 05648852167..17ddaaf3e69 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -69,7 +69,7 @@ copy_from_range(It first_it, It last_it) PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME() : m_p_l(0) -{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC template @@ -77,15 +77,12 @@ PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(It first_it, It last_it) : m_p_l(0) { copy_from_range(first_it, last_it); - _GLIBCXX_DEBUG_ONLY(assert_valid();); + PB_DS_ASSERT_VALID((*this)); } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : -#ifdef _GLIBCXX_DEBUG - debug_base(), -#endif m_p_l(0) { __try @@ -104,7 +101,7 @@ m_p_l(0) deallocate_all(); __throw_exception_again; } - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -112,12 +109,12 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) _GLIBCXX_DEBUG_ONLY(debug_base::swap(other);) std::swap(m_p_l, other.m_p_l); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp index 95e9e22b15a..98391802945 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -43,15 +43,15 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid() const +assert_valid(const char* __file, int __line) const { size_type calc_size = 0; for (const_iterator it = begin(); it != end(); ++it) { - debug_base::check_key_exists(PB_DS_V2F(*it)); + debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line); ++calc_size; } - debug_base::check_size(calc_size); + debug_base::check_size(calc_size, __file, __line); } #endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp index c481aaa2d0c..dd60ea6cdce 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,7 +43,7 @@ inline bool PB_DS_CLASS_C_DEC:: erase(const_key_reference r_key) { - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) if (m_p_l == 0) return false; @@ -81,7 +81,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) size_type num_ersd = 0; while (m_p_l != 0 && pred(m_p_l->m_value)) { @@ -106,7 +106,7 @@ erase_if(Pred pred) p_l = p_l->m_p_next; } - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) return num_ersd; } @@ -116,7 +116,6 @@ PB_DS_CLASS_C_DEC:: erase_next(entry_pointer p_l) { _GLIBCXX_DEBUG_ASSERT(p_l != 0); - _GLIBCXX_DEBUG_ASSERT(p_l != m_p_l); _GLIBCXX_DEBUG_ASSERT(p_l->m_p_next != 0); entry_pointer p_next_l = p_l->m_p_next->m_p_next; actual_erase_entry(p_l->m_p_next); diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp index 0c872cbe0a7..9164b92255e 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -48,7 +48,7 @@ find_imp(const_key_reference r_key) const if (s_eq_fn(r_key, PB_DS_V2F(m_p_l->m_value))) { apply_update(m_p_l, s_metadata_type_indicator); - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key);) + PB_DS_CHECK_KEY_EXISTS(r_key) return m_p_l; } @@ -71,7 +71,7 @@ find_imp(const_key_reference r_key) const p_l = p_next; } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return 0; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp index 3e294fbdc96..2677683f8df 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -45,21 +45,21 @@ inline std::pair< PB_DS_CLASS_C_DEC:: insert(const_reference r_val) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) entry_pointer p_l = find_imp(PB_DS_V2F(r_val)); if (p_l != 0) { - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(PB_DS_V2F(r_val));) + PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_val)) return std::make_pair(point_iterator(&p_l->m_value), false); } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(PB_DS_V2F(r_val));) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_val)) p_l = allocate_new_entry(r_val, traits_base::m_no_throw_copies_indicator); p_l->m_p_next = m_p_l; m_p_l = p_l; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return std::make_pair(point_iterator(&p_l->m_value), true); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp index aa8dd1b522a..2e2f6a20d51 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -217,7 +217,7 @@ namespace __gnu_pbds operator[](const_key_reference r_key) { #ifdef PB_DS_DATA_TRUE_INDICATOR - _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) return insert(std::make_pair(r_key, mapped_type())).first->second; #else insert(r_key); @@ -231,7 +231,7 @@ namespace __gnu_pbds inline point_iterator find(const_key_reference r_key) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) entry_pointer p_e = find_imp(r_key); return point_iterator(p_e == 0 ? 0: &p_e->m_value); } @@ -239,7 +239,7 @@ namespace __gnu_pbds inline const_point_iterator find(const_key_reference r_key) const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) entry_pointer p_e = find_imp(r_key); return const_point_iterator(p_e == 0 ? 0: &p_e->m_value); } @@ -268,7 +268,7 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; #endif #ifdef PB_DS_LU_MAP_TRACE_ @@ -337,6 +337,22 @@ namespace __gnu_pbds mutable entry_pointer m_p_l; }; +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_CHECK_KEY_EXISTS(_Key) \ + _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);) + +#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \ + _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \ + __FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + #include #include #include @@ -346,6 +362,10 @@ namespace __gnu_pbds #include #include +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST +#undef PB_DS_CHECK_KEY_EXISTS +#undef PB_DS_ASSERT_VALID #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #undef PB_DS_TYPES_TRAITS_C_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp index d6844fc1eec..1c3b9dd6e47 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -53,7 +53,7 @@ PB_DS_OV_TREE_CLASS_NAME() : m_a_metadata(0), m_end_it(0), m_size(0) -{ _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -63,7 +63,7 @@ PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : m_a_metadata(0), m_end_it(0), m_size(0) -{ _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -74,14 +74,11 @@ PB_DS_OV_TREE_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_updat m_a_metadata(0), m_end_it(0), m_size(0) -{ _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: PB_DS_OV_TREE_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : -#ifdef _GLIBCXX_DEBUG - debug_base(other), -#endif #ifdef PB_DS_TREE_TRACE PB_DS_TREE_TRACE_BASE_C_DEC(other), #endif @@ -93,7 +90,7 @@ PB_DS_OV_TREE_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : m_size(0) { copy_from_ordered_range(other.begin(), other.end()); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -123,6 +120,7 @@ copy_from_range(It first_it, It last_it) map_type m(first_it, last_it); copy_from_ordered_range(m.begin(), m.end()); + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -157,14 +155,11 @@ copy_from_ordered_range(It first_it, It last_it) update(PB_DS_node_begin_imp(), (node_update* )this); #ifdef _GLIBCXX_DEBUG - const_iterator dbg_it = m_a_values; - while (dbg_it != m_end_it) + for (const_iterator dbg_it = m_a_values; dbg_it != m_end_it; ++dbg_it) { debug_base::insert_new(PB_DS_V2F(*dbg_it)); - dbg_it++; } - PB_DS_CLASS_C_DEC::assert_valid(); -#endif +#endif } PB_DS_CLASS_T_DEC @@ -210,14 +205,11 @@ copy_from_ordered_range(It first_it, It last_it, It other_first_it, update(PB_DS_node_begin_imp(), (node_update* )this); #ifdef _GLIBCXX_DEBUG - const_iterator dbg_it = m_a_values; - while (dbg_it != m_end_it) + for (const_iterator dbg_it = m_a_values; dbg_it != m_end_it; ++dbg_it) { debug_base::insert_new(PB_DS_V2F(*dbg_it)); - dbg_it++; } - PB_DS_CLASS_C_DEC::assert_valid(); -#endif +#endif } PB_DS_CLASS_T_DEC @@ -225,10 +217,12 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) value_swap(other); std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID(other) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -247,9 +241,9 @@ PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~PB_DS_OV_TREE_CLASS_NAME() { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + //PB_DS_ASSERT_VALID((*this)) cond_dtor cd(m_a_values, m_end_it, m_size); - reallocate_metadata((node_update* )this, 0); + reallocate_metadata((node_update*)this, 0); } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp index 66f4ed66773..1ba96d8edbb 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp @@ -43,40 +43,37 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid() const +assert_valid(const char* __file, int __line) const { - std::cout << "av1" << std::endl; if (m_a_values == 0 || m_end_it == 0 || m_size == 0) - _GLIBCXX_DEBUG_ASSERT(m_a_values == 0 && m_end_it == 0 && m_size == 0); + PB_DS_DEBUG_VERIFY(m_a_values == 0 && m_end_it == 0 && m_size == 0); - std::cout << "av2" << std::endl; - assert_iterators(); - std::cout << "av3" << std::endl; + assert_iterators(__file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_iterators() const +assert_iterators(const char* __file, int __line) const { - debug_base::check_size(m_size); + debug_base::check_size(m_size, __file, __line); size_type iterated_num = 0; const_iterator prev_it = end(); - _GLIBCXX_DEBUG_ASSERT(m_end_it == m_a_values + m_size); + PB_DS_DEBUG_VERIFY(m_end_it == m_a_values + m_size); for (const_iterator it = begin(); it != end(); ++it) { ++iterated_num; - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(PB_DS_V2F(*it));) - _GLIBCXX_DEBUG_ASSERT(lower_bound(PB_DS_V2F(*it)) == it); + debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line); + PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)) == it); const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it)); --upper_bound_it; - _GLIBCXX_DEBUG_ASSERT(upper_bound_it == it); + PB_DS_DEBUG_VERIFY(upper_bound_it == it); if (prev_it != end()) - _GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(*prev_it), - PB_DS_V2F(*it))); + PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*prev_it), + PB_DS_V2F(*it))); prev_it = it; } - _GLIBCXX_DEBUG_ASSERT(iterated_num == m_size); + PB_DS_DEBUG_VERIFY(iterated_num == m_size); } #endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp index 6f9a09d8d01..a9bfab64e12 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,10 +43,9 @@ void PB_DS_CLASS_C_DEC:: clear() { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) if (m_size == 0) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) return; } else @@ -59,7 +58,7 @@ clear() m_a_values = 0; m_size = 0; m_end_it = m_a_values; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -68,7 +67,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) #ifdef PB_DS_REGRESSION typename Allocator::group_adjustor adjust(m_size); @@ -76,8 +75,7 @@ erase_if(Pred pred) size_type new_size = 0; size_type num_val_ersd = 0; - iterator source_it = m_a_values; - for (source_it = begin(); source_it != m_end_it; ++source_it) + for (iterator source_it = begin(); source_it != m_end_it; ++source_it) if (!pred(*source_it)) ++new_size; else @@ -93,7 +91,7 @@ erase_if(Pred pred) iterator target_it = a_new_values; cond_dtor cd(a_new_values, target_it, new_size); _GLIBCXX_DEBUG_ONLY(debug_base::clear()); - for (source_it = begin(); source_it != m_end_it; ++source_it) + for (iterator source_it = begin(); source_it != m_end_it; ++source_it) { if (!pred(*source_it)) { @@ -116,7 +114,7 @@ erase_if(Pred pred) m_size = new_size; m_end_it = target_it; update(node_begin(), (node_update* )this); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return num_val_ersd; } @@ -126,11 +124,11 @@ It PB_DS_CLASS_C_DEC:: erase_imp(It it) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) if (it == end()) return end(); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::check_key_exists(PB_DS_V2F(*it));) + PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(*it)) #ifdef PB_DS_REGRESSION typename Allocator::group_adjustor adjust(m_size); @@ -175,7 +173,7 @@ erase_imp(It it) --m_size; m_end_it = m_a_values + m_size; update(node_begin(), (node_update* )this); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return It(ret_it); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp index c9421af397c..7eeb85b7c19 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -43,7 +43,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: size() const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return m_size; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp index 7d2ed3f1aaa..d6ba00b8856 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -102,10 +102,20 @@ namespace __gnu_pbds #ifdef PB_DS_TREE_TRACE #define PB_DS_TREE_TRACE_BASE_C_DEC \ - tree_trace_base -#endif +#endif + +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_CHECK_KEY_EXISTS(_Key) \ + _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);) + +#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \ + _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \ + __FILE__, __LINE__);) // Ordered-vector tree associative-container. templatesecond; } - _GLIBCXX_DEBUG_ONLY(assert_valid();) return (insert_new_val(it, std::make_pair(r_key, mapped_type()))->second); #else insert(r_key); @@ -254,18 +263,17 @@ namespace __gnu_pbds inline std::pair insert(const_reference r_value) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) const_key_reference r_key = PB_DS_V2F(r_value); point_iterator it = lower_bound(r_key); if (it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it))) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key)); + PB_DS_ASSERT_VALID((*this)) + PB_DS_CHECK_KEY_EXISTS(r_key) return std::make_pair(it, false); } - _GLIBCXX_DEBUG_ONLY(assert_valid();) return std::make_pair(insert_new_val(it, r_value), true); } @@ -295,11 +303,11 @@ namespace __gnu_pbds iterator pot_it = lower_bound(r_key); if (pot_it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it))) { - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key)); + PB_DS_CHECK_KEY_EXISTS(r_key) return ++pot_it; } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key)); + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return pot_it; } @@ -310,15 +318,15 @@ namespace __gnu_pbds inline point_iterator find(const_key_reference r_key) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) iterator pot_it = lower_bound(r_key); if (pot_it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it))) { - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key)); + PB_DS_CHECK_KEY_EXISTS(r_key) return pot_it; } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key)); + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return end(); } @@ -412,12 +420,11 @@ namespace __gnu_pbds inline iterator insert_new_val(iterator it, const_reference r_value) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) #ifdef PB_DS_REGRESSION typename Allocator::group_adjustor adjust(m_size); #endif - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(PB_DS_V2F(r_value))); + PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value)) value_vector a_values = s_value_alloc.allocate(m_size + 1); @@ -457,16 +464,16 @@ namespace __gnu_pbds m_end_it = m_a_values + m_size; _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value))); update(node_begin(), (node_update* )this); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + PB_DS_ASSERT_VALID((*this)) return ret_it; } #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; void - assert_iterators() const; + assert_iterators(const char* file, int line) const; #endif template @@ -495,6 +502,12 @@ namespace __gnu_pbds size_type m_size; }; +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + #include #include #include @@ -504,6 +517,10 @@ namespace __gnu_pbds #include #include +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST +#undef PB_DS_CHECK_KEY_EXISTS +#undef PB_DS_ASSERT_VALID #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC #undef PB_DS_OV_TREE_CLASS_NAME diff --git a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp index 76bb6fafd5d..567a52e0218 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -43,37 +43,33 @@ void PB_DS_CLASS_C_DEC:: split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) if (m_size == 0) { other.clear(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) return; } if (Cmp_Fn::operator()(r_key, PB_DS_V2F(*begin()))) { value_swap(other); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) return; } if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(*(end() - 1)))) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) return; } if (m_size == 1) { value_swap(other); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) return; } @@ -90,8 +86,8 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) update(node_begin(), (node_update* )this); other.value_swap(new_other); value_swap(new_this); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC @@ -99,14 +95,16 @@ void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) if (other.m_size == 0) return; if (m_size == 0) { value_swap(other); + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) return; } @@ -129,9 +127,9 @@ join(PB_DS_CLASS_C_DEC& other) begin(), end()); // No exceptions from this point. - _GLIBCXX_DEBUG_ONLY(debug_base::join(other);) + _GLIBCXX_DEBUG_ONLY(debug_base::join(other, false);) value_swap(new_this); other.clear(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp index e292ed5d921..6a70ea47601 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -47,43 +47,43 @@ copy_from_range(It first_it, It last_it) while (first_it != last_it) push(*(first_it++)); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: pairing_heap_() { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: pairing_heap_(const Cmp_Fn& r_cmp_fn) : PB_DS_BASE_C_DEC(r_cmp_fn) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: pairing_heap_(const PB_DS_CLASS_C_DEC& other) : PB_DS_BASE_C_DEC(other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) +} PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - PB_DS_BASE_C_DEC::swap(other); + PB_DS_BASE_C_DEC::swap(other); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp index f6a1e943033..7212db2c539 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,11 +43,11 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid() const +assert_valid(const char* __file, int __line) const { - _GLIBCXX_DEBUG_ASSERT(base_type::m_p_root == 0 + PB_DS_DEBUG_VERIFY(base_type::m_p_root == 0 || base_type::m_p_root->m_p_next_sibling == 0); - base_type::assert_valid(); + base_type::assert_valid(__file, __line); } #endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp index 7ab31930ee1..be3a41c7827 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,17 +43,17 @@ void PB_DS_CLASS_C_DEC:: pop() { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); node_pointer p_new_root = join_node_children(base_type::m_p_root); - _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_new_root, false);) + PB_DS_ASSERT_NODE_CONSISTENT(p_new_root, false) if (p_new_root != 0) p_new_root->m_p_prev_or_parent = 0; base_type::actual_erase_node(base_type::m_p_root); base_type::m_p_root = p_new_root; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -61,11 +61,11 @@ void PB_DS_CLASS_C_DEC:: erase(point_iterator it) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); remove_node(it.m_p_nd); base_type::actual_erase_node(it.m_p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -73,21 +73,18 @@ void PB_DS_CLASS_C_DEC:: remove_node(node_pointer p_nd) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); node_pointer p_new_child = join_node_children(p_nd); -#ifdef _GLIBCXX_DEBUG - if (p_new_child != 0) - base_type::assert_node_consistent(p_new_child, false); -#endif + PB_DS_ASSERT_NODE_CONSISTENT(p_new_child, false) if (p_nd == base_type::m_p_root) { if (p_new_child != 0) p_new_child->m_p_prev_or_parent = 0; base_type::m_p_root = p_new_child; - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false);) + PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false) return; } @@ -101,14 +98,14 @@ remove_node(node_pointer p_nd) if (p_new_child->m_p_next_sibling != 0) p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child; p_nd->m_p_prev_or_parent->m_p_l_child = p_new_child; - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) + PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false) return; } p_nd->m_p_prev_or_parent->m_p_l_child = p_nd->m_p_next_sibling; if (p_nd->m_p_next_sibling != 0) p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) + PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false) return; } @@ -119,14 +116,14 @@ remove_node(node_pointer p_nd) if (p_new_child->m_p_next_sibling != 0) p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child; p_new_child->m_p_prev_or_parent->m_p_next_sibling = p_new_child; - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) + PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false) return; } p_nd->m_p_prev_or_parent->m_p_next_sibling = p_nd->m_p_next_sibling; if (p_nd->m_p_next_sibling != 0) p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd->m_p_prev_or_parent, false);) + PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false) } PB_DS_CLASS_T_DEC @@ -142,7 +139,7 @@ join_node_children(node_pointer p_nd) p_ret = forward_join(p_ret, p_ret->m_p_next_sibling); while (p_ret->m_p_prev_or_parent != p_nd) p_ret = back_join(p_ret->m_p_prev_or_parent, p_ret); - _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_ret, false);) + PB_DS_ASSERT_NODE_CONSISTENT(p_ret, false) return p_ret; } @@ -171,7 +168,7 @@ forward_join(node_pointer p_nd, node_pointer p_next) p_nd->m_p_next_sibling = 0; base_type::make_child_of(p_next, p_nd); - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false)); + PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false) return p_nd; } @@ -187,13 +184,13 @@ back_join(node_pointer p_nd, node_pointer p_next) { p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; base_type::make_child_of(p_nd, p_next); - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_next, false)); + PB_DS_ASSERT_NODE_CONSISTENT(p_next, false) return p_next; } p_nd->m_p_next_sibling = 0; base_type::make_child_of(p_next, p_nd); - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false)); + PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false) return p_nd; } @@ -203,10 +200,10 @@ typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) if (base_type::empty()) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return 0; } base_type::to_linked_list(); @@ -230,7 +227,7 @@ erase_if(Pred pred) push_imp(p_cur); p_cur = p_next; } - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return ersd; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp index 85efd70dca1..c02373b2f3a 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -43,8 +43,8 @@ inline typename PB_DS_CLASS_C_DEC::const_reference PB_DS_CLASS_C_DEC:: top() const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); + PB_DS_ASSERT_VALID((*this)) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); return base_type::m_p_root->m_value; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp index 9a5f5f64e6e..07e6b00cb83 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,15 +43,15 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: push(const_reference r_val) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - node_pointer p_new_nd = base_type::get_new_node_for_insert(r_val); + node_pointer p_new_nd = base_type::get_new_node_for_insert(r_val); push_imp(p_new_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - return point_iterator(p_new_nd); + return point_iterator(p_new_nd); } PB_DS_CLASS_T_DEC @@ -72,14 +72,14 @@ push_imp(node_pointer p_nd) p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = 0; base_type::make_child_of(base_type::m_p_root, p_nd); - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd, false)); + PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false) base_type::m_p_root = p_nd; } else { base_type::make_child_of(p_nd, base_type::m_p_root); - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false)); + PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false) } } @@ -88,14 +88,14 @@ void PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - remove_node(it.m_p_nd); + remove_node(it.m_p_nd); it.m_p_nd->m_value = r_new_val; push_imp(it.m_p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) +} diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp index e19bcb695bd..6677cc0fb24 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -57,26 +57,24 @@ namespace __gnu_pbds { #define PB_DS_CLASS_T_DEC \ - template + template #define PB_DS_CLASS_C_DEC \ - pairing_heap_ + pairing_heap_ #ifdef _GLIBCXX_DEBUG #define PB_DS_BASE_C_DEC \ - left_child_next_sibling_heap_< \ - Value_Type, \ - Cmp_Fn, \ - null_left_child_next_sibling_heap_node_metadata, \ - Allocator, \ - false> + left_child_next_sibling_heap_ #else #define PB_DS_BASE_C_DEC \ - left_child_next_sibling_heap_< \ - Value_Type, \ - Cmp_Fn, \ - null_left_child_next_sibling_heap_node_metadata, \ - Allocator> + left_child_next_sibling_heap_ #endif /** @@ -179,7 +177,7 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; #endif private: @@ -198,9 +196,21 @@ namespace __gnu_pbds void remove_node(node_pointer p_nd); - }; +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_ASSERT_NODE_CONSISTENT(_Node, _Bool) \ + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, _Bool, \ + __FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + #include #include #include @@ -208,6 +218,9 @@ namespace __gnu_pbds #include #include +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_ASSERT_NODE_CONSISTENT +#undef PB_DS_ASSERT_VALID #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC #undef PB_DS_BASE_C_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp index 1e6138c38d8..e5469b9b99b 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -44,17 +44,17 @@ void PB_DS_CLASS_C_DEC:: split(Pred pred, PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) - other.clear(); + other.clear(); if (base_type::empty()) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) - return; + return; } base_type::to_linked_list(); @@ -77,9 +77,9 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) p_out = p_next; } - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID(other) - node_pointer p_cur = base_type::m_p_root; + node_pointer p_cur = base_type::m_p_root; base_type::m_p_root = 0; @@ -94,39 +94,39 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) p_cur = p_next; } - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) +} PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) - if (other.m_p_root == 0) - { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + if (other.m_p_root == 0) + { + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) - return; - } + return; + } if (base_type::m_p_root == 0) base_type::m_p_root = other.m_p_root; else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, other.m_p_root->m_value)) { base_type::make_child_of(base_type::m_p_root, other.m_p_root); - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(other.m_p_root, false)); + PB_DS_ASSERT_NODE_CONSISTENT(other.m_p_root, false) base_type::m_p_root = other.m_p_root; } else { base_type::make_child_of(other.m_p_root, base_type::m_p_root); - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(base_type::m_p_root, false)); + PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false) } base_type::m_size += other.m_size; @@ -134,7 +134,7 @@ join(PB_DS_CLASS_C_DEC& other) other.m_p_root = 0; other.m_size = 0; - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) +} diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp index 17f7c55d404..6201b1d8525 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -58,7 +58,7 @@ PB_DS_CLASS_NAME() : m_size(0) { initialize(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -69,7 +69,7 @@ PB_DS_CLASS_NAME(const e_access_traits& r_e_access_traits) : m_size(0) { initialize(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -85,10 +85,10 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : { initialize(); m_size = other.m_size; - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID(other) if (other.m_p_head->m_p_parent == 0) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return; } __try @@ -104,7 +104,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent); m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent); m_p_head->m_p_parent->m_p_parent = m_p_head; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -112,12 +112,12 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) value_swap(other); std::swap((e_access_traits& )(*this), (e_access_traits& )other); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp index 514da0a2843..1beceb568ef 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,45 +43,45 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid() const +assert_valid(const char* __file, int __line) const { if (m_p_head->m_p_parent != 0) - m_p_head->m_p_parent->assert_valid(this); - assert_iterators(); - assert_reverse_iterators(); + m_p_head->m_p_parent->assert_valid(this, __file, __line); + assert_iterators(__file, __line); + assert_reverse_iterators(__file, __line); if (m_p_head->m_p_parent == 0) { - _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_min == m_p_head); - _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_max == m_p_head); - _GLIBCXX_DEBUG_ASSERT(empty()); + PB_DS_DEBUG_VERIFY(m_p_head->m_p_min == m_p_head); + PB_DS_DEBUG_VERIFY(m_p_head->m_p_max == m_p_head); + PB_DS_DEBUG_VERIFY(empty()); return; } - _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_min->m_type == pat_trie_leaf_node_type); - _GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_max->m_type == pat_trie_leaf_node_type); - _GLIBCXX_DEBUG_ASSERT(!empty()); + PB_DS_DEBUG_VERIFY(m_p_head->m_p_min->m_type == pat_trie_leaf_node_type); + PB_DS_DEBUG_VERIFY(m_p_head->m_p_max->m_type == pat_trie_leaf_node_type); + PB_DS_DEBUG_VERIFY(!empty()); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_iterators() const +assert_iterators(const char* __file, int __line) const { size_type calc_size = 0; for (const_iterator it = begin(); it != end(); ++it) { ++calc_size; - debug_base::check_key_exists(PB_DS_V2F(*it)); - _GLIBCXX_DEBUG_ASSERT(lower_bound(PB_DS_V2F(*it)) == it); - _GLIBCXX_DEBUG_ASSERT(--upper_bound(PB_DS_V2F(*it)) == it); + debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line); + PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)) == it); + PB_DS_DEBUG_VERIFY(--upper_bound(PB_DS_V2F(*it)) == it); } - _GLIBCXX_DEBUG_ASSERT(calc_size == m_size); + PB_DS_DEBUG_VERIFY(calc_size == m_size); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_reverse_iterators() const +assert_reverse_iterators(const char* __file, int __line) const { size_type calc_size = 0; for (const_reverse_iterator it = rbegin(); it != rend(); ++it) @@ -89,27 +89,28 @@ assert_reverse_iterators() const ++calc_size; const_node_pointer p_nd = const_cast(this)->find_imp(PB_DS_V2F(*it)); - _GLIBCXX_DEBUG_ASSERT(p_nd == it.m_p_nd); + PB_DS_DEBUG_VERIFY(p_nd == it.m_p_nd); } - _GLIBCXX_DEBUG_ASSERT(calc_size == m_size); + PB_DS_DEBUG_VERIFY(calc_size == m_size); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: -recursive_count_leafs(const_node_pointer p_nd) +recursive_count_leafs(const_node_pointer p_nd, + const char* __file, int __line) { if (p_nd == 0) return (0); if (p_nd->m_type == pat_trie_leaf_node_type) return (1); - _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_internal_node_type); + PB_DS_DEBUG_VERIFY(p_nd->m_type == pat_trie_internal_node_type); size_type ret = 0; for (typename internal_node::const_iterator it = static_cast(p_nd)->begin(); it != static_cast(p_nd)->end(); ++it) - ret += recursive_count_leafs(*it); + ret += recursive_count_leafs(*it, __file, __line); return ret; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp index 8c3c8b90d54..cbf1b417098 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -46,20 +46,20 @@ erase(const_key_reference r_key) node_pointer p_nd = find_imp(r_key); if (p_nd == 0 || p_nd->m_type == pat_trie_internal_node_type) { - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key)); + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return false; } _GLIBCXX_DEBUG_ASSERT(p_nd->m_type == pat_trie_leaf_node_type); if (!synth_e_access_traits::equal_keys(PB_DS_V2F(reinterpret_cast(p_nd)->value()), r_key)) { - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key)); + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return false; } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key)); + PB_DS_CHECK_KEY_EXISTS(r_key) erase_leaf(static_cast(p_nd)); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return true; } @@ -100,7 +100,7 @@ erase_fixup(internal_node_pointer p_nd) _GLIBCXX_DEBUG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) > 1); p_nd->update_prefixes(this); apply_update(p_nd, (node_update* )this); - _GLIBCXX_DEBUG_ONLY(p_nd->assert_valid(this);) + PB_DS_ASSERT_NODE_VALID(p_nd) if (p_nd->m_p_parent->m_type == pat_trie_head_node_type) return; @@ -128,7 +128,7 @@ void PB_DS_CLASS_C_DEC:: clear() { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) if (empty()) return; @@ -136,7 +136,7 @@ clear() m_size = 0; initialize(); _GLIBCXX_DEBUG_ONLY(debug_base::clear();) - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -169,7 +169,7 @@ inline typename PB_DS_CLASS_C_DEC::const_iterator PB_DS_CLASS_C_DEC:: erase(const_iterator it) { - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) if (it == end()) return it; @@ -178,7 +178,7 @@ erase(const_iterator it) ++ret_it; _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); erase_leaf(static_cast(it.m_p_nd)); - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) return ret_it; } @@ -188,7 +188,7 @@ inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: erase(iterator it) { - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) if (it == end()) return it; @@ -196,7 +196,7 @@ erase(iterator it) ++ret_it; _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); erase_leaf(static_cast(it.m_p_nd)); - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) return ret_it; } #endif // #ifdef PB_DS_DATA_TRUE_INDICATOR @@ -206,7 +206,7 @@ inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator PB_DS_CLASS_C_DEC:: erase(const_reverse_iterator it) { - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) if (it.m_p_nd == m_p_head) return it; @@ -215,7 +215,7 @@ erase(const_reverse_iterator it) _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); erase_leaf(static_cast(it.m_p_nd)); - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) return ret_it; } @@ -225,7 +225,7 @@ inline typename PB_DS_CLASS_C_DEC::reverse_iterator PB_DS_CLASS_C_DEC:: erase(reverse_iterator it) { - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) if (it.m_p_nd == m_p_head) return it; @@ -234,7 +234,7 @@ erase(reverse_iterator it) _GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == pat_trie_leaf_node_type); erase_leaf(static_cast(it.m_p_nd)); - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) return ret_it; } #endif // #ifdef PB_DS_DATA_TRUE_INDICATOR @@ -246,22 +246,22 @@ PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { size_type num_ersd = 0; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) iterator it = begin(); while (it != end()) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - if (pred(*it)) - { - ++num_ersd; - it = erase(it); - } - else - ++it; + PB_DS_ASSERT_VALID((*this)) + if (pred(*it)) + { + ++num_ersd; + it = erase(it); + } + else + ++it; } - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return num_ersd; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp index ebc3bf2d453..e2e20f186d7 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,22 +43,22 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) node_pointer p_nd = find_imp(r_key); if (p_nd == 0 || p_nd->m_type != pat_trie_leaf_node_type) { - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return end(); } if (synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast(p_nd)->value()), r_key)) { - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key)); + PB_DS_CHECK_KEY_EXISTS(r_key) return iterator(p_nd); } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return end(); } @@ -67,23 +67,23 @@ inline typename PB_DS_CLASS_C_DEC::const_point_iterator PB_DS_CLASS_C_DEC:: find(const_key_reference r_key) const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) const_node_pointer p_nd = const_cast(this)->find_imp(r_key); if (p_nd == 0 || p_nd->m_type != pat_trie_leaf_node_type) { - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return end(); } if (synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast(p_nd)->value()), r_key)) { - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(r_key)); + PB_DS_CHECK_KEY_EXISTS(r_key) return const_iterator(const_cast(p_nd)); } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(r_key);) + PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) return end(); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/head.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/head.hpp index 0c73812942b..bca847db784 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/head.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/head.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -88,7 +88,8 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG virtual subtree_debug_info - assert_valid_imp(const_e_access_traits_pointer p_traits) const; + assert_valid_imp(const_e_access_traits_pointer p_traits, + const char* file, int line) const; #endif public: @@ -106,9 +107,13 @@ namespace __gnu_pbds PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::subtree_debug_info PB_DS_CLASS_C_DEC:: - assert_valid_imp(const_e_access_traits_pointer /*p_traits*/) const + assert_valid_imp(const_e_access_traits_pointer /*p_traits*/, + const char* __file, int __line) const { - _GLIBCXX_DEBUG_ASSERT(false); + _GLIBCXX_DEBUG_VERIFY_AT(false, + _M_message("Assertion from %1;:%2;") + ._M_string(__FILE__)._M_integer(__LINE__), + __file, __line); return subtree_debug_info(); } #endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp index 84787f85c17..9afce8b0945 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,13 +43,13 @@ void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();); - _GLIBCXX_DEBUG_ONLY(other.assert_valid();); + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) split_join_branch_bag bag; if (!join_prep(other, bag)) { - _GLIBCXX_DEBUG_ONLY(assert_valid();); - _GLIBCXX_DEBUG_ONLY(other.assert_valid();); + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) return; } @@ -59,10 +59,10 @@ join(PB_DS_CLASS_C_DEC& other) m_p_head->m_p_parent->m_p_parent = m_p_head; m_size += other.m_size; other.initialize(); - _GLIBCXX_DEBUG_ONLY(other.assert_valid();); + PB_DS_ASSERT_VALID(other) m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent); m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent); - _GLIBCXX_DEBUG_ONLY(assert_valid();); + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -70,8 +70,8 @@ bool PB_DS_CLASS_C_DEC:: join_prep(PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) if (other.m_size == 0) return false; @@ -81,18 +81,19 @@ join_prep(PB_DS_CLASS_C_DEC& other, split_join_branch_bag& r_bag) return false; } - const bool greater = synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast( - m_p_head->m_p_max)->value()),PB_DS_V2F(static_cast( - other.m_p_head->m_p_min)->value())); + const bool greater = + synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast(m_p_head->m_p_max)->value()), + PB_DS_V2F(static_cast(other.m_p_head->m_p_min)->value())); - const bool lesser = synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast( - other.m_p_head->m_p_max)->value()),PB_DS_V2F(static_cast(m_p_head->m_p_min)->value())); + const bool lesser = + synth_e_access_traits::cmp_keys(PB_DS_V2F(static_cast(other.m_p_head->m_p_max)->value()), + PB_DS_V2F(static_cast(m_p_head->m_p_min)->value())); if (!greater && !lesser) __throw_join_error(); rec_join_prep(m_p_head->m_p_parent, other.m_p_head->m_p_parent, r_bag); - _GLIBCXX_DEBUG_ONLY(debug_base::join(other);) + _GLIBCXX_DEBUG_ONLY(debug_base::join(other, false);) return true; } @@ -249,7 +250,7 @@ rec_join(leaf_pointer p_l, leaf_pointer p_r, split_join_branch_bag& r_bag) if (p_l == 0) return (p_r); node_pointer p_ret = insert_branch(p_l, p_r, r_bag); - _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) == 2); + _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == 2); return p_ret; } @@ -260,13 +261,13 @@ rec_join(leaf_pointer p_l, internal_node_pointer p_r, size_type checked_ind, split_join_branch_bag& r_bag) { #ifdef _GLIBCXX_DEBUG - const size_type lhs_leafs = recursive_count_leafs(p_l); - const size_type rhs_leafs = recursive_count_leafs(p_r); + const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l); + const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r); #endif _GLIBCXX_DEBUG_ASSERT(p_r != 0); node_pointer p_ret = rec_join(p_r, p_l, checked_ind, r_bag); - _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) == lhs_leafs + rhs_leafs); + _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == lhs_leafs + rhs_leafs); return p_ret; } @@ -279,15 +280,15 @@ rec_join(internal_node_pointer p_l, leaf_pointer p_r, size_type checked_ind, spl _GLIBCXX_DEBUG_ASSERT(p_r != 0); #ifdef _GLIBCXX_DEBUG - const size_type lhs_leafs = recursive_count_leafs(p_l); - const size_type rhs_leafs = recursive_count_leafs(p_r); + const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l); + const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r); #endif if (!p_l->should_be_mine(pref_begin(p_r), pref_end(p_r), checked_ind, this)) { node_pointer p_ret = insert_branch(p_l, p_r, r_bag); - _GLIBCXX_DEBUG_ONLY(p_ret->assert_valid(this);) - _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) == + PB_DS_ASSERT_NODE_VALID(p_ret) + _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == lhs_leafs + rhs_leafs); return p_ret; } @@ -303,8 +304,8 @@ rec_join(internal_node_pointer p_l, leaf_pointer p_r, size_type checked_ind, spl pref_end(p_new_child), this); } - _GLIBCXX_DEBUG_ONLY(p_l->assert_valid(this)); - _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_l) == lhs_leafs + rhs_leafs); + PB_DS_ASSERT_NODE_VALID(p_l) + _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_l) == lhs_leafs + rhs_leafs); return p_l; } @@ -317,8 +318,8 @@ rec_join(internal_node_pointer p_l, internal_node_pointer p_r, split_join_branch _GLIBCXX_DEBUG_ASSERT(p_r != 0); #ifdef _GLIBCXX_DEBUG - const size_type lhs_leafs = recursive_count_leafs(p_l); - const size_type rhs_leafs = recursive_count_leafs(p_r); + const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l); + const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r); #endif if (p_l->get_e_ind() == p_r->get_e_ind() && @@ -336,8 +337,8 @@ rec_join(internal_node_pointer p_l, internal_node_pointer p_r, split_join_branch p_r->~internal_node(); s_internal_node_allocator.deallocate(p_r, 1); - _GLIBCXX_DEBUG_ONLY(p_l->assert_valid(this);) - _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_l) == lhs_leafs + rhs_leafs); + PB_DS_ASSERT_NODE_VALID(p_l) + _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_l) == lhs_leafs + rhs_leafs); return p_l; } @@ -348,7 +349,7 @@ rec_join(internal_node_pointer p_l, internal_node_pointer p_r, split_join_branch p_r, 0, r_bag); p_l->replace_child(p_new_child, pref_begin(p_new_child), pref_end(p_new_child), this); - _GLIBCXX_DEBUG_ONLY(p_l->assert_valid(this);) + PB_DS_ASSERT_NODE_VALID(p_l) return p_l; } @@ -361,14 +362,14 @@ rec_join(internal_node_pointer p_l, internal_node_pointer p_r, split_join_branch p_r->replace_child(p_new_child, pref_begin(p_new_child), pref_end(p_new_child), this); - _GLIBCXX_DEBUG_ONLY(p_r->assert_valid(this);) - _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_r) == lhs_leafs + rhs_leafs); + PB_DS_ASSERT_NODE_VALID(p_r) + _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_r) == lhs_leafs + rhs_leafs); return p_r; } node_pointer p_ret = insert_branch(p_l, p_r, r_bag); - _GLIBCXX_DEBUG_ONLY(p_ret->assert_valid(this);) - _GLIBCXX_DEBUG_ASSERT(recursive_count_leafs(p_ret) == lhs_leafs + rhs_leafs); + PB_DS_ASSERT_NODE_VALID(p_ret) + _GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == lhs_leafs + rhs_leafs); return p_ret; } @@ -381,12 +382,12 @@ insert(const_reference r_val) if (p_lf != 0 && p_lf->m_type == pat_trie_leaf_node_type && synth_e_access_traits::equal_keys(PB_DS_V2F(static_cast(p_lf)->value()), PB_DS_V2F(r_val))) { - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(PB_DS_V2F(r_val))); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_val)) + PB_DS_ASSERT_VALID((*this)) return std::make_pair(iterator(p_lf), false); } - _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(PB_DS_V2F(r_val))); + PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_val)) leaf_pointer p_new_lf = s_leaf_allocator.allocate(1); cond_dealtor cond(p_new_lf); @@ -402,14 +403,17 @@ insert(const_reference r_val) ++m_size; update_min_max_for_inserted_leaf(p_new_lf); _GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return std::make_pair(point_iterator(p_new_lf), true); } PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: -keys_diff_ind(typename e_access_traits::const_iterator b_l, typename e_access_traits::const_iterator e_l, typename e_access_traits::const_iterator b_r, typename e_access_traits::const_iterator e_r) +keys_diff_ind(typename e_access_traits::const_iterator b_l, + typename e_access_traits::const_iterator e_l, + typename e_access_traits::const_iterator b_r, + typename e_access_traits::const_iterator e_r) { size_type diff_pos = 0; while (b_l != e_l) @@ -445,7 +449,7 @@ insert_branch(node_pointer p_l, node_pointer p_r, split_join_branch_bag& r_bag) p_new_nd->add_child(p_r, right_b_it, right_e_it, this); p_l->m_p_parent = p_new_nd; p_r->m_p_parent = p_new_nd; - _GLIBCXX_DEBUG_ONLY(p_new_nd->assert_valid(this);) + PB_DS_ASSERT_NODE_VALID(p_new_nd) return (p_new_nd); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/internal_node.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/internal_node.hpp index 56cf1330497..9e30e65cd12 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/internal_node.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/internal_node.hpp @@ -1,6 +1,7 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011 +// Free Software Foundation, Inc. // // 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 @@ -94,7 +95,8 @@ namespace __gnu_pbds typedef typename base_type::subtree_debug_info subtree_debug_info; virtual subtree_debug_info - assert_valid_imp(const_e_access_traits_pointer) const; + assert_valid_imp(const_e_access_traits_pointer, + const char* file, int line) const; #endif inline size_type @@ -564,28 +566,37 @@ namespace __gnu_pbds } #ifdef _GLIBCXX_DEBUG +# define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::subtree_debug_info PB_DS_CLASS_C_DEC:: - assert_valid_imp(const_e_access_traits_pointer p_traits) const + assert_valid_imp(const_e_access_traits_pointer p_traits, + const char* __file, int __line) const { - _GLIBCXX_DEBUG_ASSERT(base_type::m_type == pat_trie_internal_node_type); - _GLIBCXX_DEBUG_ASSERT(static_cast(std::distance(pref_b_it(), pref_e_it())) == m_e_ind); - _GLIBCXX_DEBUG_ASSERT(std::distance(begin(), end()) >= 2); + PB_DS_DEBUG_VERIFY(base_type::m_type == pat_trie_internal_node_type); + PB_DS_DEBUG_VERIFY(static_cast(std::distance(pref_b_it(), pref_e_it())) == m_e_ind); + PB_DS_DEBUG_VERIFY(std::distance(begin(), end()) >= 2); for (typename pat_trie_internal_node::const_iterator it = begin(); it != end(); ++it) { const_node_pointer p_nd =* it; - _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_parent == this); - subtree_debug_info child_ret = p_nd->assert_valid_imp(p_traits); + PB_DS_DEBUG_VERIFY(p_nd->m_p_parent == this); + subtree_debug_info child_ret = + p_nd->assert_valid_imp(p_traits, __file, __line); - _GLIBCXX_DEBUG_ASSERT(static_cast(std::distance(child_ret.first, child_ret.second)) >= m_e_ind); - _GLIBCXX_DEBUG_ASSERT(should_be_mine(child_ret.first, child_ret.second, 0, p_traits)); - _GLIBCXX_DEBUG_ASSERT(get_pref_pos(child_ret.first, child_ret.second, p_traits) == static_cast(it.m_p_p_cur - m_a_p_children)); + PB_DS_DEBUG_VERIFY(static_cast(std::distance(child_ret.first, child_ret.second)) >= m_e_ind); + PB_DS_DEBUG_VERIFY(should_be_mine(child_ret.first, child_ret.second, 0, p_traits)); + PB_DS_DEBUG_VERIFY(get_pref_pos(child_ret.first, child_ret.second, p_traits) == static_cast(it.m_p_p_cur - m_a_p_children)); } return std::make_pair(pref_b_it(), pref_e_it()); } +# undef PB_DS_DEBUG_VERIFY #endif #undef PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/leaf.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/leaf.hpp index 91cf14faa2c..ba320434ca3 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/leaf.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/leaf.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -49,31 +49,27 @@ namespace __gnu_pbds { #define PB_DS_CLASS_T_DEC \ - template< \ - class Type_Traits, \ - class E_Access_Traits, \ - class Metadata, \ - class Allocator> + template #define PB_DS_CLASS_C_DEC \ - pat_trie_leaf< \ - Type_Traits, \ - E_Access_Traits, \ - Metadata, \ - Allocator> + pat_trie_leaf -#define PB_DS_BASE_C_DEC \ - pat_trie_node_base< \ - Type_Traits, \ - E_Access_Traits, \ - Metadata, \ - Allocator> +#define PB_DS_BASE_C_DEC \ + pat_trie_node_base #define PB_DS_PAT_TRIE_SUBTREE_DEBUG_INFO_C_DEC \ - pat_trie_subtree_debug_info< \ - Type_Traits, \ - E_Access_Traits, \ - Allocator> + pat_trie_subtree_debug_info templatebegin(p_traits->extract_key(r_val)), @@ -158,6 +162,7 @@ namespace __gnu_pbds PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: ~pat_trie_leaf() { } +# undef PB_DS_DEBUG_VERIFY #endif #undef PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/node_base.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/node_base.hpp index bb13068bcdd..6e131e4074c 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/node_base.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/node_base.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -95,10 +95,12 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid(const_e_access_traits_pointer p_traits) const; + assert_valid(const_e_access_traits_pointer p_traits, + const char* file, int line) const; virtual subtree_debug_info - assert_valid_imp(const_e_access_traits_pointer p_traits) const = 0; + assert_valid_imp(const_e_access_traits_pointer p_traits, + const char* file, int line) const = 0; #endif node_pointer m_p_parent; @@ -114,8 +116,9 @@ namespace __gnu_pbds PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: - assert_valid(const_e_access_traits_pointer p_traits) const - { assert_valid_imp(p_traits); } + assert_valid(const_e_access_traits_pointer p_traits, + const char* __file, int __line) const + { assert_valid_imp(p_traits, __file, __line); } #endif #undef PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp index 01e9e321264..738420f13f9 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp @@ -1,6 +1,7 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011 +// Free Software Foundation, Inc. // // 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 @@ -393,7 +394,10 @@ namespace __gnu_pbds split_join_branch_bag&); size_type - keys_diff_ind(typename e_access_traits::const_iterator, typename e_access_traits::const_iterator, typename e_access_traits::const_iterator, typename e_access_traits::const_iterator); + keys_diff_ind(typename e_access_traits::const_iterator, + typename e_access_traits::const_iterator, + typename e_access_traits::const_iterator, + typename e_access_traits::const_iterator); internal_node_pointer insert_branch(node_pointer, node_pointer, split_join_branch_bag&); @@ -445,16 +449,17 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; void - assert_iterators() const; + assert_iterators(const char* file, int line) const; void - assert_reverse_iterators() const; + assert_reverse_iterators(const char* file, int line) const; static size_type - recursive_count_leafs(const_node_pointer); + recursive_count_leafs(const_node_pointer, + const char* file, int line); #endif #ifdef PB_DS_PAT_TRIE_TRACE_ @@ -490,6 +495,28 @@ namespace __gnu_pbds size_type m_size; }; +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_ASSERT_NODE_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X->assert_valid(this, __FILE__, __LINE__);) + +#define PB_DS_RECURSIVE_COUNT_LEAFS(X) \ + recursive_count_leafs(X, __FILE__, __LINE__) + +#define PB_DS_CHECK_KEY_EXISTS(_Key) \ + _GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);) + +#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \ + _GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \ + __FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + #include #include #include @@ -502,6 +529,12 @@ namespace __gnu_pbds #include #include +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST +#undef PB_DS_CHECK_KEY_EXISTS +#undef PB_DS_RECURSIVE_COUNT_LEAFS +#undef PB_DS_ASSERT_NODE_VALID +#undef PB_DS_ASSERT_VALID #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_NAME diff --git a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp index c9738d9b5ff..06add93c1a9 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,15 +43,15 @@ void PB_DS_CLASS_C_DEC:: split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();); - _GLIBCXX_DEBUG_ONLY(other.assert_valid();); + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) split_join_branch_bag bag; leaf_pointer p_split_lf = split_prep(r_key, other, bag); if (p_split_lf == 0) { _GLIBCXX_DEBUG_ASSERT(bag.empty()); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) return; } @@ -73,8 +73,8 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) other.m_size = std::distance(other.PB_DS_CLASS_C_DEC::begin(), other.PB_DS_CLASS_C_DEC::end()); m_size -= other.m_size; - _GLIBCXX_DEBUG_ONLY(assert_valid();); - _GLIBCXX_DEBUG_ONLY(other.assert_valid();); + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC @@ -86,8 +86,8 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other, split_join_branc if (m_size == 0) { other.clear(); - _GLIBCXX_DEBUG_ONLY(assert_valid();); - _GLIBCXX_DEBUG_ONLY(other.assert_valid();); + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) return (0); } @@ -96,16 +96,16 @@ split_prep(const_key_reference r_key, PB_DS_CLASS_C_DEC& other, split_join_branc { other.clear(); value_swap(other); - _GLIBCXX_DEBUG_ONLY(assert_valid();); - _GLIBCXX_DEBUG_ONLY(other.assert_valid();); + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) return (0); } if (!synth_e_access_traits::cmp_keys(r_key, PB_DS_V2F(static_cast(m_p_head->m_p_max)->value()))) { - _GLIBCXX_DEBUG_ONLY(assert_valid();); - _GLIBCXX_DEBUG_ONLY(other.assert_valid();); + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) return (0); } @@ -143,7 +143,7 @@ rec_split(node_pointer p_nd, const_e_iterator b_it, const_e_iterator e_it, PB_DS node_pointer p_child_ret = rec_split(p_internal_nd->get_child_node(b_it, e_it, this), b_it, e_it, other, r_bag); - _GLIBCXX_DEBUG_ONLY(p_child_ret->assert_valid(this);) + PB_DS_ASSERT_NODE_VALID(p_child_ret) p_internal_nd->replace_child(p_child_ret, b_it, e_it, this); apply_update(p_internal_nd, (node_update* )this); @@ -184,7 +184,7 @@ rec_split(node_pointer p_nd, const_e_iterator b_it, const_e_iterator e_it, PB_DS if (std::distance(p_internal_nd->begin(), p_internal_nd->end()) > 1) { p_internal_nd->update_prefixes(this); - _GLIBCXX_DEBUG_ONLY(p_internal_nd->assert_valid(this);) + PB_DS_ASSERT_NODE_VALID(p_internal_nd) apply_update(p_internal_nd, (node_update* )this); return (p_internal_nd); } @@ -203,7 +203,7 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no { #ifdef _GLIBCXX_DEBUG if (m_p_head->m_p_parent != 0) - m_p_head->m_p_parent->assert_valid(this); + PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent) #endif const size_type total_num_children =((m_p_head->m_p_parent == 0)? 0 : 1) + num_children; @@ -218,7 +218,7 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no { if (m_p_head->m_p_parent != 0) { - _GLIBCXX_DEBUG_ONLY(m_p_head->m_p_parent->assert_valid(this);) + PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent) return; } @@ -226,7 +226,7 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no m_p_head->m_p_parent =* child_b_it; m_p_head->m_p_parent->m_p_parent = m_p_head; apply_update(m_p_head->m_p_parent, (node_update* )this); - _GLIBCXX_DEBUG_ONLY(m_p_head->m_p_parent->assert_valid(this);) + PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent) return; } @@ -236,7 +236,7 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no size_type num_inserted = 0; while (num_inserted++ < num_children) { - _GLIBCXX_DEBUG_ONLY((*child_b_it)->assert_valid(this);) + PB_DS_ASSERT_NODE_VALID((*child_b_it)) p_new_root->add_child(*child_b_it, pref_begin(*child_b_it), pref_end(*child_b_it), this); ++child_b_it; @@ -250,5 +250,5 @@ split_insert_branch(size_type e_ind, const_e_iterator b_it, typename internal_no m_p_head->m_p_parent = p_new_root; p_new_root->m_p_parent = m_p_head; apply_update(m_p_head->m_p_parent, (node_update* )this); - _GLIBCXX_DEBUG_ONLY(m_p_head->m_p_parent->assert_valid(this);) + PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp index 1abfe21dea6..19adc8edaad 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -53,7 +53,7 @@ PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME() { initialize(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -62,7 +62,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : base_type(r_cmp_fn) { initialize(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -71,7 +71,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) : base_type(r_cmp_fn, r_node_update) { initialize(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -80,7 +80,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : base_type(other) { initialize(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -88,9 +88,9 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) base_type::swap(other); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp index ca13ef873a0..fe90b0a6a3f 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,34 +43,37 @@ PB_DS_CLASS_T_DEC typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: -assert_node_consistent(const node_pointer p_nd) const +assert_node_consistent(const node_pointer p_nd, const char* __file, + int __line) const { if (p_nd == 0) return 1; - const size_type l_height = assert_node_consistent(p_nd->m_p_left); - const size_type r_height = assert_node_consistent(p_nd->m_p_right); + const size_type l_height = + assert_node_consistent(p_nd->m_p_left, __file, __line); + const size_type r_height = + assert_node_consistent(p_nd->m_p_right, __file, __line); if (p_nd->m_red) { - _GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_nd->m_p_left)); - _GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_nd->m_p_right)); + PB_DS_DEBUG_VERIFY(is_effectively_black(p_nd->m_p_left)); + PB_DS_DEBUG_VERIFY(is_effectively_black(p_nd->m_p_right)); } - _GLIBCXX_DEBUG_ASSERT(l_height == r_height); + PB_DS_DEBUG_VERIFY(l_height == r_height); return (p_nd->m_red ? 0 : 1) + l_height; } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid() const +assert_valid(const char* __file, int __line) const { - base_type::assert_valid(); + base_type::assert_valid(__file, __line); const node_pointer p_head = base_type::m_p_head; - _GLIBCXX_DEBUG_ASSERT(p_head->m_red); + PB_DS_DEBUG_VERIFY(p_head->m_red); if (p_head->m_p_parent != 0) { - _GLIBCXX_DEBUG_ASSERT(!p_head->m_p_parent->m_red); - assert_node_consistent(p_head->m_p_parent); + PB_DS_DEBUG_VERIFY(!p_head->m_p_parent->m_red); + assert_node_consistent(p_head->m_p_parent, __file, __line); } } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp index e097bc4f96f..5a335a6dd47 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -55,14 +55,14 @@ inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: erase(iterator it) { - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) if (it == base_type::end()) return it; iterator ret_it = it; ++ret_it; erase_node(it.m_p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) return ret_it; } @@ -71,14 +71,14 @@ inline typename PB_DS_CLASS_C_DEC::reverse_iterator PB_DS_CLASS_C_DEC:: erase(reverse_iterator it) { - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) if (it.m_p_nd == base_type::m_p_head) return it; reverse_iterator ret_it = it; ++ret_it; erase_node(it.m_p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) return ret_it; } @@ -88,7 +88,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) size_type num_ersd = 0; iterator it = base_type::begin(); while (it != base_type::end()) @@ -102,7 +102,7 @@ erase_if(Pred pred) ++it; } - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return num_ersd; } @@ -113,7 +113,7 @@ erase_node(node_pointer p_nd) { remove_node(p_nd); base_type::actual_erase_node(p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp index 632deab7038..55bd4ed1f0d 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,16 +43,16 @@ inline std::pair PB_DS_CLASS_C_DEC:: insert(const_reference r_value) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) std::pair ins_pair = base_type::insert_leaf(r_value); if (ins_pair.second == true) { ins_pair.first.m_p_nd->m_red = true; - _GLIBCXX_DEBUG_ONLY(this->structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) insert_fixup(ins_pair.first.m_p_nd); } - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return ins_pair; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp index 1d84a8e0d60..92ea7d65a75 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -167,17 +167,17 @@ namespace __gnu_pbds operator[](const_key_reference r_key) { #ifdef PB_DS_DATA_TRUE_INDICATOR - _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) std::pair ins_pair = base_type::insert_leaf(value_type(r_key, mapped_type())); if (ins_pair.second == true) { ins_pair.first.m_p_nd->m_red = true; - _GLIBCXX_DEBUG_ONLY(this->structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(this->structure_only_assert_valid(__FILE__, __LINE__);) insert_fixup(ins_pair.first.m_p_nd); } - _GLIBCXX_DEBUG_ONLY(assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) return ins_pair.first.m_p_nd->m_value.second; #else insert(r_key); @@ -210,10 +210,11 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; size_type - assert_node_consistent(const node_pointer) const; + assert_node_consistent(const node_pointer, const char* file, + int line) const; #endif inline static bool @@ -259,6 +260,18 @@ namespace __gnu_pbds split_at_node(node_pointer, PB_DS_CLASS_C_DEC&); }; +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_STRUCT_ONLY_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.structure_only_assert_valid(__FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + #include #include #include @@ -266,6 +279,9 @@ namespace __gnu_pbds #include #include +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_STRUCT_ONLY_ASSERT_VALID +#undef PB_DS_ASSERT_VALID #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_NAME diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp index e3cd399e873..a0d079b142f 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,23 +43,20 @@ inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.base_type::assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) if (base_type::join_prep(other) == false) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) return; } const node_pointer p_x = other.split_min(); join_imp(p_x, other.m_p_head->m_p_parent); base_type::join_finish(other); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(base_type::assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.base_type::assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC @@ -122,10 +119,10 @@ join_imp(node_pointer p_x, node_pointer p_r) p_x->m_red = true; base_type::initialize_min_max(); - _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) base_type::update_to_top(p_x, (node_update* )this); insert_fixup(p_x); - _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid()); + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -237,21 +234,18 @@ void PB_DS_CLASS_C_DEC:: split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid()); - _GLIBCXX_DEBUG_ONLY(base_type::assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) - _GLIBCXX_DEBUG_ONLY(other.assert_valid()); - _GLIBCXX_DEBUG_ONLY(other.base_type::assert_valid();) + if (base_type::split_prep(r_key, other) == false) + { + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) + return; + } - if (base_type::split_prep(r_key, other) == false) - { - _GLIBCXX_DEBUG_ONLY(assert_valid()); - _GLIBCXX_DEBUG_ONLY(other.assert_valid()); - return; - } - - _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.base_type::structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) + PB_DS_STRUCT_ONLY_ASSERT_VALID(other) node_pointer p_nd = upper_bound(r_key).m_p_nd; do { @@ -259,15 +253,14 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value))) split_at_node(p_nd, other); - _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.base_type::structure_only_assert_valid();) + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) + PB_DS_STRUCT_ONLY_ASSERT_VALID(other) p_nd = p_next_nd; } while (p_nd != base_type::m_p_head); base_type::split_finish(other); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -307,7 +300,7 @@ split_at_node(node_pointer p_nd, PB_DS_CLASS_C_DEC& other) base_type::initialize_min_max(); other.join_imp(p_nd, p_r); - _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid()); - _GLIBCXX_DEBUG_ONLY(other.base_type::structure_only_assert_valid()); + PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) + PB_DS_STRUCT_ONLY_ASSERT_VALID(other) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp index bf4dcfefdd3..35acb8f6bcd 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -42,16 +42,16 @@ PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: rc_binomial_heap_() { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: rc_binomial_heap_(const Cmp_Fn& r_cmp_fn) : PB_DS_BASE_C_DEC(r_cmp_fn) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -62,8 +62,8 @@ rc_binomial_heap_(const PB_DS_CLASS_C_DEC& other) : base_type::find_max(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) +} PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: @@ -75,14 +75,13 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) - base_type::swap(other); + base_type::swap(other); m_rc.swap(other.m_rc); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) - } - + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) +} diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp index 1f6246f968f..638810bfb44 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,21 +43,21 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid() const +assert_valid(const char* __file, int __line) const { - base_type::assert_valid(false); + base_type::assert_valid(false, __file, __line); if (!base_type::empty()) { - _GLIBCXX_DEBUG_ASSERT(base_type::m_p_max != 0); - base_type::assert_max(); + PB_DS_DEBUG_VERIFY(base_type::m_p_max != 0); + base_type::assert_max(__file, __line); } - m_rc.assert_valid(); + m_rc.assert_valid(__file, __line); if (m_rc.empty()) { - base_type::assert_valid(true); - _GLIBCXX_DEBUG_ASSERT(next_2_pointer(base_type::m_p_root) == 0); + base_type::assert_valid(true, __file, __line); + PB_DS_DEBUG_VERIFY(next_2_pointer(base_type::m_p_root) == 0); return; } @@ -67,17 +67,17 @@ assert_valid() const while (p_nd != 0) { - _GLIBCXX_DEBUG_ASSERT(*it == p_nd); + PB_DS_DEBUG_VERIFY(*it == p_nd); const_node_pointer p_next = p_nd->m_p_next_sibling; - _GLIBCXX_DEBUG_ASSERT(p_next != 0); - _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_next->m_metadata); - _GLIBCXX_DEBUG_ASSERT(p_next->m_p_next_sibling == 0 || + PB_DS_DEBUG_VERIFY(p_next != 0); + PB_DS_DEBUG_VERIFY(p_nd->m_metadata == p_next->m_metadata); + PB_DS_DEBUG_VERIFY(p_next->m_p_next_sibling == 0 || p_next->m_metadata < p_next->m_p_next_sibling->m_metadata); --it; p_nd = next_2_pointer(next_after_0_pointer(p_nd)); } - _GLIBCXX_DEBUG_ASSERT(it + 1 == m_rc.begin()); + PB_DS_DEBUG_VERIFY(it + 1 == m_rc.begin()); } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp index 29d240b4585..bf000625009 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -91,7 +91,7 @@ erase_if(Pred pred) make_binomial_heap(); const size_type ersd = base_type::erase_if(pred); base_type::find_max(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return ersd; } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp index 56d189d70c4..c252b49ad8a 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,13 +43,13 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: push(const_reference r_val) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - make_0_exposed(); + make_0_exposed(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - node_pointer p_nd = base_type::get_new_node_for_insert(r_val); + node_pointer p_nd = base_type::get_new_node_for_insert(r_val); p_nd->m_p_l_child = p_nd->m_p_prev_or_parent = 0; p_nd->m_metadata = 0; @@ -67,9 +67,9 @@ push(const_reference r_val) if (p_nd->m_p_next_sibling != 0&& p_nd->m_p_next_sibling->m_metadata == 0) m_rc.push(p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - return point_iterator(p_nd); + return point_iterator(p_nd); } PB_DS_CLASS_T_DEC @@ -77,16 +77,16 @@ void PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - make_binomial_heap(); + make_binomial_heap(); base_type::modify(it, r_new_val); base_type::find_max(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) +} PB_DS_CLASS_T_DEC inline typename PB_DS_CLASS_C_DEC::node_pointer diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp index 9b70accd9e1..d1942b99b17 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -41,6 +41,15 @@ #ifndef PB_DS_RC_HPP #define PB_DS_RC_HPP +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + namespace __gnu_pbds { namespace detail @@ -121,7 +130,7 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; #endif #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ @@ -138,20 +147,20 @@ namespace __gnu_pbds PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: rc() : m_over_top(0) - { _GLIBCXX_DEBUG_ONLY(assert_valid();) } + { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: rc(const PB_DS_CLASS_C_DEC& other) : m_over_top(0) - { _GLIBCXX_DEBUG_ONLY(assert_valid();) } + { PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) const size_type over_top = std::max(m_over_top, other.m_over_top); @@ -159,8 +168,8 @@ namespace __gnu_pbds std::swap(m_a_entries[i], other.m_a_entries[i]); std::swap(m_over_top, other.m_over_top); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC @@ -168,10 +177,10 @@ namespace __gnu_pbds PB_DS_CLASS_C_DEC:: push(entry p_nd) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(m_over_top < max_entries); m_a_entries[m_over_top++] = p_nd; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -179,10 +188,10 @@ namespace __gnu_pbds PB_DS_CLASS_C_DEC:: pop() { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!empty()); --m_over_top; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -190,7 +199,7 @@ namespace __gnu_pbds PB_DS_CLASS_C_DEC:: top() const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(!empty()); return *(m_a_entries + m_over_top - 1); } @@ -200,7 +209,7 @@ namespace __gnu_pbds PB_DS_CLASS_C_DEC:: empty() const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return m_over_top == 0; } @@ -215,9 +224,9 @@ namespace __gnu_pbds PB_DS_CLASS_C_DEC:: clear() { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) m_over_top = 0; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -236,8 +245,8 @@ namespace __gnu_pbds PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: - assert_valid() const - { _GLIBCXX_DEBUG_ASSERT(m_over_top < max_entries); } + assert_valid(const char* __file, int __line) const + { PB_DS_DEBUG_VERIFY(m_over_top < max_entries); } #endif #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ @@ -259,4 +268,6 @@ namespace __gnu_pbds } // namespace detail } // namespace __gnu_pbds +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_ASSERT_VALID #endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp index 762e29b3995..0bf8e4fd279 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -149,7 +149,7 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; #endif #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ @@ -180,6 +180,15 @@ namespace __gnu_pbds rc_t m_rc; }; +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + #include #include #include @@ -187,12 +196,11 @@ namespace __gnu_pbds #include #include +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_ASSERT_VALID #undef PB_DS_CLASS_C_DEC - #undef PB_DS_CLASS_T_DEC - #undef PB_DS_BASE_C_DEC - #undef PB_DS_RC_C_DEC } // namespace detail } // namespace __gnu_pbds diff --git a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp index 26965aec8c4..09d637c7d58 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -44,8 +44,8 @@ void PB_DS_CLASS_C_DEC:: split(Pred pred, PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) make_binomial_heap(); other.make_binomial_heap(); @@ -55,19 +55,19 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) base_type::find_max(); other.find_max(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) +} PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) - make_binomial_heap(); + make_binomial_heap(); other.make_binomial_heap(); base_type::join(other); @@ -75,7 +75,7 @@ join(PB_DS_CLASS_C_DEC& other) base_type::find_max(); other.find_max(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) +} diff --git a/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp b/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp index 1418bbe4555..3d1b3996991 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp @@ -39,66 +39,69 @@ * Contains a resize trigger implementation. */ +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + PB_DS_CLASS_T_DEC PB_DS_CLASS_C_DEC:: hash_load_check_resize_trigger(float load_min, float load_max) : m_load_min(load_min), m_load_max(load_max), m_next_shrink_size(0), m_next_grow_size(0), m_resize_needed(false) -{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_find_search_start() -{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_find_search_collision() -{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_find_search_end() -{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_insert_search_start() -{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_insert_search_collision() -{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_insert_search_end() -{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erase_search_start() -{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erase_search_collision() -{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: notify_erase_search_end() -{ _GLIBCXX_DEBUG_ONLY(assert_valid();) } +{ PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC inline void @@ -107,7 +110,7 @@ notify_inserted(size_type num_entries) { m_resize_needed = (num_entries >= m_next_grow_size); size_base::set_size(num_entries); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -117,7 +120,7 @@ notify_erased(size_type num_entries) { size_base::set_size(num_entries); m_resize_needed = num_entries <= m_next_shrink_size; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -125,7 +128,7 @@ inline bool PB_DS_CLASS_C_DEC:: is_resize_needed() const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return m_resize_needed; } @@ -160,7 +163,7 @@ notify_resized(size_type new_size) << "5 " << m_next_grow_size << std::endl; #endif - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -194,7 +197,7 @@ notify_externally_resized(size_type new_size) m_next_shrink_size = new_shrink_size; } - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -202,10 +205,10 @@ void PB_DS_CLASS_C_DEC:: notify_cleared() { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) size_base::set_size(0); m_resize_needed = (0 < m_next_shrink_size); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -213,8 +216,8 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) size_base::swap(other); std::swap(m_load_min, other.m_load_min); @@ -223,8 +226,8 @@ swap(PB_DS_CLASS_C_DEC& other) std::swap(m_next_grow_size, other.m_next_grow_size); std::swap(m_next_shrink_size, other.m_next_shrink_size); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC @@ -272,12 +275,20 @@ do_resize(size_type) { std::abort(); } #ifdef _GLIBCXX_DEBUG +# define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid() const +assert_valid(const char* __file, int __line) const { _GLIBCXX_DEBUG_ASSERT(m_load_max > m_load_min); _GLIBCXX_DEBUG_ASSERT(m_next_grow_size >= m_next_shrink_size); } +# undef PB_DS_DEBUG_VERIFY #endif +#undef PB_DS_ASSERT_VALID diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp index 22258953273..dea307c2bdc 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -53,7 +53,7 @@ PB_DS_CLASS_C_DEC:: PB_DS_CLASS_NAME() { initialize(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -62,7 +62,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn) : base_type(r_cmp_fn) { initialize(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -71,7 +71,7 @@ PB_DS_CLASS_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) : base_type(r_cmp_fn, r_node_update) { initialize(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -80,7 +80,7 @@ PB_DS_CLASS_NAME(const PB_DS_CLASS_C_DEC& other) : base_type(other) { initialize(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -88,11 +88,11 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) base_type::swap(other); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp index 385623f41f0..453567a0632 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,31 +43,32 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid() const +assert_valid(const char* __file, int __line) const { - base_type::assert_valid(); + base_type::assert_valid(__file, __line); const node_pointer p_head = base_type::m_p_head; - assert_special_imp(p_head); + assert_special_imp(p_head, __file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_special_imp(const node_pointer p_nd) const +assert_special_imp(const node_pointer p_nd, + const char* __file, int __line) const { if (p_nd == 0) return; if (p_nd == base_type::m_p_head) { - _GLIBCXX_DEBUG_ASSERT(p_nd->m_special); - assert_special_imp(p_nd->m_p_parent); + PB_DS_DEBUG_VERIFY(p_nd->m_special); + assert_special_imp(p_nd->m_p_parent, __file, __line); return; } - _GLIBCXX_DEBUG_ASSERT(!p_nd->m_special); - assert_special_imp(p_nd->m_p_left); - assert_special_imp(p_nd->m_p_right); + PB_DS_DEBUG_VERIFY(!p_nd->m_special); + assert_special_imp(p_nd->m_p_left, __file, __line); + assert_special_imp(p_nd->m_p_right, __file, __line); } #endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp index adfabb93ee4..207577cf492 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -55,13 +55,13 @@ inline typename PB_DS_CLASS_C_DEC::iterator PB_DS_CLASS_C_DEC:: erase(iterator it) { - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) if (it == base_type::end()) return it; iterator ret_it = it; ++ret_it; erase_node(it.m_p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) return ret_it; } @@ -70,13 +70,13 @@ inline typename PB_DS_CLASS_C_DEC::reverse_iterator PB_DS_CLASS_C_DEC:: erase(reverse_iterator it) { - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) if (it.m_p_nd == base_type::m_p_head) return (it); reverse_iterator ret_it = it; ++ret_it; erase_node(it.m_p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) return ret_it; } @@ -86,7 +86,7 @@ inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) size_type num_ersd = 0; iterator it = base_type::begin(); while (it != base_type::end()) @@ -99,7 +99,7 @@ erase_if(Pred pred) else ++it; } - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return num_ersd; } @@ -111,7 +111,7 @@ erase_node(node_pointer p_nd) _GLIBCXX_DEBUG_ASSERT(p_nd != 0); splay(p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) _GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent); node_pointer p_l = p_nd->m_p_left; @@ -124,7 +124,7 @@ erase_node(node_pointer p_nd) base_type::m_p_head->m_p_parent = p_l; if (p_l != 0) p_l->m_p_parent = base_type::m_p_head; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) return; } @@ -141,7 +141,7 @@ erase_node(node_pointer p_nd) p_target_r->m_p_left = p_l; if (p_l != 0) p_l->m_p_parent = p_target_r; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) apply_update(p_target_r, (node_update* )this); } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp index 9447011bd1c..9dfa926f402 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -65,7 +65,8 @@ inline typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: find_imp(const_key_reference r_key) { - _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid(__FILE__, + __LINE__);) node_pointer p_nd = base_type::m_p_head->m_p_parent; while (p_nd != 0) if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key)) @@ -84,7 +85,7 @@ inline const typename PB_DS_CLASS_C_DEC::node_pointer PB_DS_CLASS_C_DEC:: find_imp(const_key_reference r_key) const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) node_pointer p_nd = base_type::m_p_head->m_p_parent; while (p_nd != 0) if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key)) diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp index 69ab58ba373..97441c9df46 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010i, 2011 Free Software Foundation, Inc. // // 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 @@ -43,12 +43,12 @@ inline std::pair PB_DS_CLASS_C_DEC:: insert(const_reference r_value) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) std::pair ins_pair = insert_leaf_imp(r_value); ins_pair.first.m_p_nd->m_special = false; - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) splay(ins_pair.first.m_p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid()); + PB_DS_ASSERT_VALID((*this)) return ins_pair; } @@ -57,7 +57,8 @@ inline std::pair PB_DS_CLASS_C_DEC:: insert_leaf_imp(const_reference r_value) { - _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid();) + _GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid(__FILE__, + __LINE__);) if (base_type::m_size == 0) return std::make_pair(base_type::insert_imp_empty(r_value), true); @@ -80,7 +81,7 @@ insert_leaf_imp(const_reference r_value) if (p_pot == base_type::m_p_head) return std::make_pair(base_type::insert_leaf_new(r_value, base_type::m_p_head->m_p_right, false), true); - _GLIBCXX_DEBUG_ONLY(base_type::check_key_does_not_exist(PB_DS_V2F(r_value))); + PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value)) p_nd = p_pot->m_p_left; if (p_nd == 0) diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp index f9bae226318..ec38cf81314 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -48,44 +48,44 @@ splay(node_pointer p_nd) #ifdef _GLIBCXX_DEBUG { node_pointer p_head = base_type::m_p_head; - assert_special_imp(p_head); + assert_special_imp(p_head, __FILE__, __LINE__); } #endif - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd);) + PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd) - if (p_nd->m_p_parent->m_p_parent == base_type::m_p_head) - { - base_type::rotate_parent(p_nd); - _GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent); - } - else - { - const node_pointer p_parent = p_nd->m_p_parent; - const node_pointer p_grandparent = p_parent->m_p_parent; + if (p_nd->m_p_parent->m_p_parent == base_type::m_p_head) + { + base_type::rotate_parent(p_nd); + _GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent); + } + else + { + const node_pointer p_parent = p_nd->m_p_parent; + const node_pointer p_grandparent = p_parent->m_p_parent; #ifdef _GLIBCXX_DEBUG - const size_type total = - base_type::recursive_count(p_grandparent); - _GLIBCXX_DEBUG_ASSERT(total >= 3); + const size_type total = + base_type::recursive_count(p_grandparent); + _GLIBCXX_DEBUG_ASSERT(total >= 3); #endif - if (p_parent->m_p_left == p_nd && - p_grandparent->m_p_right == p_parent) - splay_zig_zag_left(p_nd, p_parent, p_grandparent); - else if (p_parent->m_p_right == p_nd && - p_grandparent->m_p_left == p_parent) - splay_zig_zag_right(p_nd, p_parent, p_grandparent); - else if (p_parent->m_p_left == p_nd && - p_grandparent->m_p_left == p_parent) - splay_zig_zig_left(p_nd, p_parent, p_grandparent); - else - splay_zig_zig_right(p_nd, p_parent, p_grandparent); - _GLIBCXX_DEBUG_ASSERT(total ==this->recursive_count(p_nd)); - } + if (p_parent->m_p_left == p_nd && + p_grandparent->m_p_right == p_parent) + splay_zig_zag_left(p_nd, p_parent, p_grandparent); + else if (p_parent->m_p_right == p_nd && + p_grandparent->m_p_left == p_parent) + splay_zig_zag_right(p_nd, p_parent, p_grandparent); + else if (p_parent->m_p_left == p_nd && + p_grandparent->m_p_left == p_parent) + splay_zig_zig_left(p_nd, p_parent, p_grandparent); + else + splay_zig_zig_right(p_nd, p_parent, p_grandparent); + _GLIBCXX_DEBUG_ASSERT(total ==this->recursive_count(p_nd)); + } - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd);) - } + PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd) + } } PB_DS_CLASS_T_DEC @@ -97,7 +97,7 @@ splay_zig_zag_left(node_pointer p_nd, node_pointer p_parent, _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);) + PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent) _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd && p_grandparent->m_p_right == p_parent); @@ -133,7 +133,7 @@ splay_zig_zag_right(node_pointer p_nd, node_pointer p_parent, _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);) + PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent) _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd && p_grandparent->m_p_left == p_parent); @@ -169,7 +169,7 @@ splay_zig_zig_left(node_pointer p_nd, node_pointer p_parent, _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);) + PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent) _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd && p_nd->m_p_parent->m_p_parent->m_p_left == p_nd->m_p_parent); @@ -204,7 +204,7 @@ splay_zig_zig_right(node_pointer p_nd, node_pointer p_parent, { _GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); _GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_grandparent);) + PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent) _GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd && p_nd->m_p_parent->m_p_parent->m_p_right == p_nd->m_p_parent); @@ -278,6 +278,6 @@ splay_zz_end(node_pointer p_nd, node_pointer p_parent, apply_update(p_parent, (node_update* )this); apply_update(p_nd, (node_update* )this); - _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(p_nd);) + PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp index 8a2eb07cf07..7c91b77f792 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -191,14 +191,14 @@ namespace __gnu_pbds operator[](const_key_reference r_key) { #ifdef PB_DS_DATA_TRUE_INDICATOR - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) std::pair ins_pair = insert_leaf_imp(value_type(r_key, mapped_type())); ins_pair.first.m_p_nd->m_special = false; - _GLIBCXX_DEBUG_ONLY(base_type::assert_valid()); + _GLIBCXX_DEBUG_ONLY(base_type::assert_valid(__FILE__, __LINE__)); splay(ins_pair.first.m_p_nd); - _GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid();) + _GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) return ins_pair.first.m_p_nd->m_value.second; #else insert(r_key); @@ -243,10 +243,10 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; void - assert_special_imp(const node_pointer) const; + assert_special_imp(const node_pointer, const char* file, int line) const; #endif void @@ -277,6 +277,23 @@ namespace __gnu_pbds erase_node(node_pointer); }; +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_ASSERT_BASE_NODE_CONSISTENT(_Node) \ + _GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, \ + __FILE__, __LINE__);) + +#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \ + _GLIBCXX_DEBUG_ONLY(base_type::check_key_does_not_exist(_Key, \ + __FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + #include #include #include @@ -285,6 +302,10 @@ namespace __gnu_pbds #include #include +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST +#undef PB_DS_ASSERT_BASE_NODE_CONSISTENT +#undef PB_DS_ASSERT_VALID #undef PB_DS_CLASS_T_DEC #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_NAME diff --git a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp index beef5bdaa22..cb04d656933 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,12 +43,12 @@ inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) if (base_type::join_prep(other) == false) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) return; } @@ -70,8 +70,8 @@ join(PB_DS_CLASS_C_DEC& other) base_type::join_finish(other); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } PB_DS_CLASS_T_DEC @@ -79,13 +79,13 @@ void PB_DS_CLASS_C_DEC:: split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid()); - _GLIBCXX_DEBUG_ONLY(other.assert_valid()); + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) if (base_type::split_prep(r_key, other) == false) { - _GLIBCXX_DEBUG_ONLY(assert_valid()); - _GLIBCXX_DEBUG_ONLY(other.assert_valid()); + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) return; } @@ -106,7 +106,7 @@ split(const_key_reference r_key, PB_DS_CLASS_C_DEC& other) apply_update(p_upper_bound, (node_update* )this); base_type::split_finish(other); - _GLIBCXX_DEBUG_ONLY(assert_valid()); - _GLIBCXX_DEBUG_ONLY(other.assert_valid()); + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) } diff --git a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp index af9b1116d5c..e6780516517 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -46,7 +46,7 @@ copy_from_range(It first_it, It last_it) { while (first_it != last_it) push(*(first_it++)); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -55,7 +55,7 @@ thin_heap_() : m_p_max(0) { initialize(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -65,7 +65,7 @@ thin_heap_(const Cmp_Fn& r_cmp_fn) : m_p_max(0) { initialize(); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -79,7 +79,7 @@ thin_heap_(const PB_DS_CLASS_C_DEC& other) : if (Cmp_Fn::operator()(m_p_max->m_value, p_nd->m_value)) m_p_max = p_nd; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC @@ -87,10 +87,10 @@ void PB_DS_CLASS_C_DEC:: swap(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) base_type::swap(other); std::swap(m_p_max, other.m_p_max); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) } PB_DS_CLASS_T_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp index 19e977b9a84..0673675a63e 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,70 +43,77 @@ PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_valid() const +assert_valid(const char* __file, int __line) const { - base_type::assert_valid(); - assert_node_consistent(base_type::m_p_root, true); - assert_max(); - assert_aux_null(); + base_type::assert_valid(__file, __line); + assert_node_consistent(base_type::m_p_root, true, __file, __line); + assert_max(__file, __line); + assert_aux_null(__file, __line); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_aux_null() const +assert_aux_null(const char* __file, int __line) const { for (size_type i = 0; i < max_rank; ++i) - _GLIBCXX_DEBUG_ASSERT(m_a_aux[i] == 0); + PB_DS_DEBUG_VERIFY(m_a_aux[i] == 0); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_max() const +assert_max(const char* __file, int __line) const { if (m_p_max == 0) { - _GLIBCXX_DEBUG_ASSERT(base_type::empty()); + PB_DS_DEBUG_VERIFY(base_type::empty()); return; } - _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); - _GLIBCXX_DEBUG_ASSERT(base_type::parent(m_p_max) == 0); - _GLIBCXX_DEBUG_ASSERT(m_p_max->m_p_prev_or_parent == 0); + PB_DS_DEBUG_VERIFY(!base_type::empty()); + PB_DS_DEBUG_VERIFY(base_type::parent(m_p_max) == 0); + PB_DS_DEBUG_VERIFY(m_p_max->m_p_prev_or_parent == 0); for (const_iterator it = base_type::begin(); it != base_type::end(); ++it) - _GLIBCXX_DEBUG_ASSERT(!Cmp_Fn::operator()(m_p_max->m_value, it.m_p_nd->m_value)); + PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(m_p_max->m_value, it.m_p_nd->m_value)); } PB_DS_CLASS_T_DEC void PB_DS_CLASS_C_DEC:: -assert_node_consistent(const_node_pointer p_nd, bool root) const +assert_node_consistent(const_node_pointer p_nd, bool root, + const char* __file, int __line) const { - base_type::assert_node_consistent(p_nd, root); + base_type::assert_node_consistent(p_nd, root, __file, __line); if (p_nd == 0) return; - assert_node_consistent(p_nd->m_p_next_sibling, root); - assert_node_consistent(p_nd->m_p_l_child, false); + assert_node_consistent(p_nd->m_p_next_sibling, root, __file, __line); + assert_node_consistent(p_nd->m_p_l_child, false, __file, __line); if (!root) { if (p_nd->m_metadata == 0) - _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling == 0); + PB_DS_DEBUG_VERIFY(p_nd->m_p_next_sibling == 0); else - _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata + 1); + PB_DS_DEBUG_VERIFY(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata + 1); } if (p_nd->m_p_l_child != 0) - _GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child->m_metadata + 1 == base_type::degree(p_nd)); + PB_DS_DEBUG_VERIFY(p_nd->m_p_l_child->m_metadata + 1 == base_type::degree(p_nd)); - const bool unmarked_valid =(p_nd->m_p_l_child == 0&& p_nd->m_metadata == 0) ||(p_nd->m_p_l_child != 0&& p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 1); + const bool unmarked_valid = + (p_nd->m_p_l_child == 0 && p_nd->m_metadata == 0) + || (p_nd->m_p_l_child != 0 + && p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 1); - const bool marked_valid =(p_nd->m_p_l_child == 0&& p_nd->m_metadata == 1) ||(p_nd->m_p_l_child != 0&& p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 2); + const bool marked_valid = + (p_nd->m_p_l_child == 0 && p_nd->m_metadata == 1) + || (p_nd->m_p_l_child != 0 + && p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 2); - _GLIBCXX_DEBUG_ASSERT(unmarked_valid || marked_valid); + PB_DS_DEBUG_VERIFY(unmarked_valid || marked_valid); if (root) - _GLIBCXX_DEBUG_ASSERT(unmarked_valid); + PB_DS_DEBUG_VERIFY(unmarked_valid); } #endif diff --git a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp index 4431a4cf496..fec0ce4762f 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,8 +43,8 @@ void PB_DS_CLASS_C_DEC:: pop() { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); + PB_DS_ASSERT_VALID((*this)) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(m_p_max != 0); @@ -54,8 +54,8 @@ pop() base_type::actual_erase_node(p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) +} PB_DS_CLASS_T_DEC inline void @@ -177,8 +177,8 @@ make_from_aux() ++i; } - _GLIBCXX_DEBUG_ONLY(assert_aux_null();) - } + PB_DS_ASSERT_AUX_NULL((*this)) +} PB_DS_CLASS_T_DEC inline void @@ -218,8 +218,8 @@ void PB_DS_CLASS_C_DEC:: erase(point_iterator it) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); + PB_DS_ASSERT_VALID((*this)) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); node_pointer p_nd = it.m_p_nd; @@ -227,8 +227,8 @@ erase(point_iterator it) base_type::actual_erase_node(p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) +} PB_DS_CLASS_T_DEC template @@ -236,14 +236,14 @@ typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: erase_if(Pred pred) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - if (base_type::empty()) - { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + if (base_type::empty()) + { + PB_DS_ASSERT_VALID((*this)) - return 0; - } + return 0; + } base_type::to_linked_list(); @@ -275,9 +275,9 @@ erase_if(Pred pred) p_cur = p_next; } - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - return ersd; + return ersd; } PB_DS_CLASS_T_DEC @@ -285,8 +285,11 @@ inline typename PB_DS_CLASS_C_DEC::size_type PB_DS_CLASS_C_DEC:: rank_bound() { - const std::size_t* const p_upper = - std::upper_bound( g_a_rank_bounds, g_a_rank_bounds + num_distinct_rank_bounds, base_type::m_size); + using namespace std; + const size_t* const p_upper = + _GLIBCXX_STD_A::upper_bound(g_a_rank_bounds, + g_a_rank_bounds + num_distinct_rank_bounds, + base_type::m_size); if (p_upper == g_a_rank_bounds + num_distinct_rank_bounds) return max_rank; diff --git a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp index ef60addf816..bbae8de91b6 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,8 +43,8 @@ inline typename PB_DS_CLASS_C_DEC::const_reference PB_DS_CLASS_C_DEC:: top() const { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); + PB_DS_ASSERT_VALID((*this)) + _GLIBCXX_DEBUG_ASSERT(!base_type::empty()); _GLIBCXX_DEBUG_ASSERT(m_p_max != 0); return m_p_max->m_value; diff --git a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp index 2f56abd21c7..f1195bdff4d 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -43,9 +43,9 @@ inline typename PB_DS_CLASS_C_DEC::point_iterator PB_DS_CLASS_C_DEC:: push(const_reference r_val) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - node_pointer p_nd = base_type::get_new_node_for_insert(r_val); + node_pointer p_nd = base_type::get_new_node_for_insert(r_val); p_nd->m_metadata = 0; @@ -57,9 +57,9 @@ push(const_reference r_val) m_p_max = base_type::m_p_root = p_nd; - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - return point_iterator(p_nd); + return point_iterator(p_nd); } p_nd->m_p_next_sibling = base_type::m_p_root; @@ -70,9 +70,9 @@ push(const_reference r_val) update_max(p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - return point_iterator(p_nd); + return point_iterator(p_nd); } PB_DS_CLASS_T_DEC @@ -81,7 +81,7 @@ PB_DS_CLASS_C_DEC:: make_root(node_pointer p_nd) { p_nd->m_metadata = - p_nd->m_p_l_child == 0? + p_nd->m_p_l_child == 0 ? 0 : 1 + p_nd->m_p_l_child->m_metadata; } @@ -170,8 +170,8 @@ fix_root(node_pointer p_y) make_root(p_y); - _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, true);) - } + PB_DS_ASSERT_NODE_CONSISTENT(p_y, true) +} PB_DS_CLASS_T_DEC inline void @@ -181,7 +181,7 @@ fix_sibling_rank_1_unmarked(node_pointer p_y) _GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0); _GLIBCXX_DEBUG_ONLY(node_pointer p_w = p_y->m_p_l_child;) - _GLIBCXX_DEBUG_ASSERT(p_w != 0); + _GLIBCXX_DEBUG_ASSERT(p_w != 0); _GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling == 0); _GLIBCXX_DEBUG_ASSERT(p_y->m_p_next_sibling == 0); @@ -191,8 +191,8 @@ fix_sibling_rank_1_unmarked(node_pointer p_y) p_y->m_p_l_child = 0; - _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);) - } + PB_DS_ASSERT_NODE_CONSISTENT(p_y, false) +} PB_DS_CLASS_T_DEC inline void @@ -204,8 +204,8 @@ fix_sibling_rank_1_marked(node_pointer p_y) p_y->m_metadata = 0; - _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);) - } + PB_DS_ASSERT_NODE_CONSISTENT(p_y, false) +} PB_DS_CLASS_T_DEC inline void @@ -228,8 +228,8 @@ fix_sibling_general_unmarked(node_pointer p_y) p_y->m_p_next_sibling = p_w; p_w->m_p_prev_or_parent = p_y; - _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);) - } + PB_DS_ASSERT_NODE_CONSISTENT(p_y, false) +} PB_DS_CLASS_T_DEC inline void @@ -240,8 +240,8 @@ fix_sibling_general_marked(node_pointer p_y) --p_y->m_metadata; - _GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_y, false);) - } + PB_DS_ASSERT_NODE_CONSISTENT(p_y, false) +} PB_DS_CLASS_T_DEC inline void @@ -266,7 +266,7 @@ void PB_DS_CLASS_C_DEC:: modify(point_iterator it, const_reference r_new_val) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) node_pointer p_nd = it.m_p_nd; _GLIBCXX_DEBUG_ASSERT(p_nd != 0); @@ -283,18 +283,18 @@ modify(point_iterator it, const_reference r_new_val) make_root_and_link(p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - return; + return; } if (p_nd->m_p_prev_or_parent == 0) { update_max(p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid();) + PB_DS_ASSERT_VALID((*this)) - return; + return; } node_pointer p_y = p_nd->m_p_prev_or_parent; @@ -312,8 +312,8 @@ modify(point_iterator it, const_reference r_new_val) make_root_and_link(p_nd); - _GLIBCXX_DEBUG_ONLY(assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) +} PB_DS_CLASS_T_DEC inline void diff --git a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp index 2adf5a5ef6a..96bb818894b 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -44,17 +44,17 @@ void PB_DS_CLASS_C_DEC:: split(Pred pred, PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) - other.clear(); + other.clear(); if (base_type::empty()) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) - return; + return; } base_type::to_linked_list(); @@ -75,9 +75,9 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) p_out = p_next; } - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID(other) - node_pointer p_cur = base_type::m_p_root; + node_pointer p_cur = base_type::m_p_root; m_p_max = 0; @@ -92,19 +92,19 @@ split(Pred pred, PB_DS_CLASS_C_DEC& other) p_cur = p_next; } - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) +} PB_DS_CLASS_T_DEC inline void PB_DS_CLASS_C_DEC:: join(PB_DS_CLASS_C_DEC& other) { - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) - node_pointer p_other = other.m_p_root; + node_pointer p_other = other.m_p_root; while (p_other != 0) { @@ -121,6 +121,6 @@ join(PB_DS_CLASS_C_DEC& other) other.m_size = 0; other.m_p_max = 0; - _GLIBCXX_DEBUG_ONLY(assert_valid();) - _GLIBCXX_DEBUG_ONLY(other.assert_valid();) - } + PB_DS_ASSERT_VALID((*this)) + PB_DS_ASSERT_VALID(other) +} diff --git a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp index 88fa04b3c23..d5fba5f5ac6 100644 --- a/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp +++ b/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc. // // 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 @@ -183,10 +183,10 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; void - assert_max() const; + assert_max(const char* file, int line) const; #endif #ifdef PB_DS_THIN_HEAP_TRACE_ @@ -261,10 +261,11 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_node_consistent(const_node_pointer p_nd, bool root) const; + assert_node_consistent(const_node_pointer p_nd, bool root, + const char* file, int line) const; void - assert_aux_null() const; + assert_aux_null(const char* file, int line) const; #endif private: @@ -333,6 +334,22 @@ namespace __gnu_pbds /* Pot's good, let's play */ }; +#define PB_DS_ASSERT_VALID(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) + +#define PB_DS_ASSERT_NODE_CONSISTENT(_Node, _Bool) \ + _GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, _Bool, \ + __FILE__, __LINE__);) + +#define PB_DS_ASSERT_AUX_NULL(X) \ + _GLIBCXX_DEBUG_ONLY(X.assert_aux_null(__FILE__, __LINE__);) + +#define PB_DS_DEBUG_VERIFY(_Cond) \ + _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \ + _M_message(#_Cond" assertion from %1;:%2;") \ + ._M_string(__FILE__)._M_integer(__LINE__) \ + ,__file,__line) + #include #include #include @@ -341,6 +358,10 @@ namespace __gnu_pbds #include #include +#undef PB_DS_DEBUG_VERIFY +#undef PB_DS_ASSERT_AUX_NULL +#undef PB_DS_ASSERT_NODE_CONSISTENT +#undef PB_DS_ASSERT_VALID #undef PB_DS_CLASS_C_DEC #undef PB_DS_CLASS_T_DEC #undef PB_DS_BASE_C_DEC diff --git a/libstdc++-v3/include/ext/pb_ds/hash_policy.hpp b/libstdc++-v3/include/ext/pb_ds/hash_policy.hpp index f3bc86e9731..cefa3a10c22 100644 --- a/libstdc++-v3/include/ext/pb_ds/hash_policy.hpp +++ b/libstdc++-v3/include/ext/pb_ds/hash_policy.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. // // 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 @@ -275,7 +275,7 @@ namespace __gnu_pbds #ifdef _GLIBCXX_DEBUG void - assert_valid() const; + assert_valid(const char* file, int line) const; #endif float m_load_min;