From ab65a4c7bdf10e5465cbf47faae88af258dc2baa Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 10 Feb 2010 19:14:33 +0000 Subject: [PATCH] hashtable.h: Fold in include/tr1_impl/hashtable.h contents. 2010-02-10 Paolo Carlini * include/tr1/hashtable.h: Fold in include/tr1_impl/hashtable.h contents. * include/tr1_impl/hashtable.h: Remove. * include/tr1_impl/hashtable_policy.h: Move and rename... * include/tr1/hashtable_policy.h: ... here. * include/tr1_impl/unordered_map: Move and rename... * include/tr1/unordered_map.h: ... here. * include/tr1_impl/unordered_set: Move and rename... * include/tr1/unordered_set.h: ... here. * include/tr1_impl/unordered_map: Move and rename... * include/tr1/unordered_map.h: ... here. * include/tr1/unordered_map: Adjust. * include/tr1/unordered_set: Likewise. * include/Makefile.am: Adjust. * include/Makefile.in: Regenerate. * include/std/c++0x_warning.h: Move... * include/bits/c++0x_warning.h: ... here. * include/debug/unordered_map: Adjust. * include/debug/unordered_set: Likewise. * include/std/tuple: Likewise. * include/std/system_error: Likewise. * include/std/forward_list: Likewise. * include/std/thread: Likewise. * include/std/type_traits: Likewise. * include/std/future: Likewise. * include/std/regex: Likewise. * include/std/atomic: Likewise. * include/std/ratio: Likewise. * include/std/random: Likewise. * include/std/unordered_map: Likewise. * include/std/chrono: Likewise.: Likewise. * include/std/condition_variable: Likewise. * include/std/mutex: Likewise. * include/std/unordered_set: Likewise. * include/std/array: Likewise. * include/profile/unordered_map: Likewise. * include/profile/unordered_set: Likewise. * include/c_global/cinttypes: Likewise. * include/c_global/ctgmath: Likewise. * include/c_global/cfenv: Likewise. * include/c_global/cstdint: Likewise. * include/c_global/cstdbool: Likewise. * include/c_global/ccomplex: Likewise. * include/bits/shared_ptr.h: Do not include at all, the file is not meant to be included by the users. * include/bits/functional_hash.h: Likewise. * include/bits/unique_ptr.h: Likewise. * include/bits/forward_list.h: Likewise. * testsuite/29_atomics/atomic/cons/assign_neg.cc: Adjust dg-* line numbers. * testsuite/29_atomics/atomic/cons/copy_neg.cc: Likewise. * testsuite/23_containers/forward_list/requirements/dr438/ assign_neg.cc: Likewise. * testsuite/23_containers/forward_list/requirements/dr438/ insert_neg.cc: Likewise. * testsuite/23_containers/forward_list/requirements/dr438/ constructor_1_neg.cc: Likewise. * testsuite/23_containers/forward_list/requirements/dr438/ constructor_2_neg.cc: Likewise. * testsuite/20_util/unique_ptr/modifiers/reset_neg.cc: Likewise. * testsuite/20_util/unique_ptr/assign/assign_neg.cc: Likewise. From-SVN: r156667 --- libstdc++-v3/ChangeLog | 67 + libstdc++-v3/include/Makefile.am | 11 +- libstdc++-v3/include/Makefile.in | 11 +- .../include/{std => bits}/c++0x_warning.h | 0 libstdc++-v3/include/bits/forward_list.h | 6 - libstdc++-v3/include/bits/functional_hash.h | 4 - libstdc++-v3/include/bits/shared_ptr.h | 6 +- libstdc++-v3/include/bits/unique_ptr.h | 6 +- libstdc++-v3/include/c_global/ccomplex | 4 +- libstdc++-v3/include/c_global/cfenv | 4 +- libstdc++-v3/include/c_global/cinttypes | 4 +- libstdc++-v3/include/c_global/cstdbool | 4 +- libstdc++-v3/include/c_global/cstdint | 4 +- libstdc++-v3/include/c_global/ctgmath | 4 +- libstdc++-v3/include/debug/unordered_map | 2 +- libstdc++-v3/include/debug/unordered_set | 2 +- libstdc++-v3/include/profile/unordered_map | 2 +- libstdc++-v3/include/profile/unordered_set | 2 +- libstdc++-v3/include/std/array | 4 +- libstdc++-v3/include/std/atomic | 5 +- libstdc++-v3/include/std/chrono | 4 +- libstdc++-v3/include/std/condition_variable | 2 +- libstdc++-v3/include/std/forward_list | 4 +- libstdc++-v3/include/std/future | 2 +- libstdc++-v3/include/std/mutex | 2 +- libstdc++-v3/include/std/random | 2 +- libstdc++-v3/include/std/ratio | 4 +- libstdc++-v3/include/std/regex | 4 +- libstdc++-v3/include/std/system_error | 4 +- libstdc++-v3/include/std/thread | 4 +- libstdc++-v3/include/std/tuple | 4 +- libstdc++-v3/include/std/type_traits | 4 +- libstdc++-v3/include/std/unordered_map | 2 +- libstdc++-v3/include/std/unordered_set | 2 +- libstdc++-v3/include/tr1/hashtable.h | 1157 +++++++++++++++- .../{tr1_impl => tr1}/hashtable_policy.h | 4 +- libstdc++-v3/include/tr1/unordered_map | 2 +- .../unordered_map => tr1/unordered_map.h} | 6 +- libstdc++-v3/include/tr1/unordered_set | 2 +- .../unordered_set => tr1/unordered_set.h} | 6 +- libstdc++-v3/include/tr1_impl/hashtable | 1187 ----------------- .../20_util/unique_ptr/assign/assign_neg.cc | 16 +- .../20_util/unique_ptr/modifiers/reset_neg.cc | 4 +- .../requirements/dr438/assign_neg.cc | 2 +- .../requirements/dr438/constructor_1_neg.cc | 2 +- .../requirements/dr438/constructor_2_neg.cc | 2 +- .../requirements/dr438/insert_neg.cc | 2 +- .../29_atomics/atomic/cons/assign_neg.cc | 32 +- .../29_atomics/atomic/cons/copy_neg.cc | 32 +- 49 files changed, 1317 insertions(+), 1335 deletions(-) rename libstdc++-v3/include/{std => bits}/c++0x_warning.h (100%) rename libstdc++-v3/include/{tr1_impl => tr1}/hashtable_policy.h (99%) rename libstdc++-v3/include/{tr1_impl/unordered_map => tr1/unordered_map.h} (98%) rename libstdc++-v3/include/{tr1_impl/unordered_set => tr1/unordered_set.h} (98%) delete mode 100644 libstdc++-v3/include/tr1_impl/hashtable diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 5b5672e243c..0420fd425f0 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,70 @@ +2010-02-10 Paolo Carlini + + * include/tr1/hashtable.h: Fold in include/tr1_impl/hashtable.h + contents. + * include/tr1_impl/hashtable.h: Remove. + * include/tr1_impl/hashtable_policy.h: Move and rename... + * include/tr1/hashtable_policy.h: ... here. + * include/tr1_impl/unordered_map: Move and rename... + * include/tr1/unordered_map.h: ... here. + * include/tr1_impl/unordered_set: Move and rename... + * include/tr1/unordered_set.h: ... here. + * include/tr1_impl/unordered_map: Move and rename... + * include/tr1/unordered_map.h: ... here. + * include/tr1/unordered_map: Adjust. + * include/tr1/unordered_set: Likewise. + * include/Makefile.am: Adjust. + * include/Makefile.in: Regenerate. + + * include/std/c++0x_warning.h: Move... + * include/bits/c++0x_warning.h: ... here. + * include/debug/unordered_map: Adjust. + * include/debug/unordered_set: Likewise. + * include/std/tuple: Likewise. + * include/std/system_error: Likewise. + * include/std/forward_list: Likewise. + * include/std/thread: Likewise. + * include/std/type_traits: Likewise. + * include/std/future: Likewise. + * include/std/regex: Likewise. + * include/std/atomic: Likewise. + * include/std/ratio: Likewise. + * include/std/random: Likewise. + * include/std/unordered_map: Likewise. + * include/std/chrono: Likewise.: Likewise. + * include/std/condition_variable: Likewise. + * include/std/mutex: Likewise. + * include/std/unordered_set: Likewise. + * include/std/array: Likewise. + * include/profile/unordered_map: Likewise. + * include/profile/unordered_set: Likewise. + * include/c_global/cinttypes: Likewise. + * include/c_global/ctgmath: Likewise. + * include/c_global/cfenv: Likewise. + * include/c_global/cstdint: Likewise. + * include/c_global/cstdbool: Likewise. + * include/c_global/ccomplex: Likewise. + + * include/bits/shared_ptr.h: Do not include + at all, the file is not meant to be included by the users. + * include/bits/functional_hash.h: Likewise. + * include/bits/unique_ptr.h: Likewise. + * include/bits/forward_list.h: Likewise. + + * testsuite/29_atomics/atomic/cons/assign_neg.cc: Adjust dg-* + line numbers. + * testsuite/29_atomics/atomic/cons/copy_neg.cc: Likewise. + * testsuite/23_containers/forward_list/requirements/dr438/ + assign_neg.cc: Likewise. + * testsuite/23_containers/forward_list/requirements/dr438/ + insert_neg.cc: Likewise. + * testsuite/23_containers/forward_list/requirements/dr438/ + constructor_1_neg.cc: Likewise. + * testsuite/23_containers/forward_list/requirements/dr438/ + constructor_2_neg.cc: Likewise. + * testsuite/20_util/unique_ptr/modifiers/reset_neg.cc: Likewise. + * testsuite/20_util/unique_ptr/assign/assign_neg.cc: Likewise. + 2010-02-10 Paolo Carlini * include/bits/hashtable.h: Fold in include/tr1_impl/hashtable.h diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 167871507dd..23aad14692c 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -31,7 +31,6 @@ std_headers = \ ${std_srcdir}/array \ ${std_srcdir}/atomic \ ${std_srcdir}/bitset \ - ${std_srcdir}/c++0x_warning.h \ ${std_srcdir}/chrono \ ${std_srcdir}/complex \ ${std_srcdir}/condition_variable \ @@ -89,6 +88,7 @@ bits_headers = \ ${bits_srcdir}/basic_string.h \ ${bits_srcdir}/basic_string.tcc \ ${bits_srcdir}/boost_concept_check.h \ + ${bits_srcdir}/c++0x_warning.h \ ${bits_srcdir}/char_traits.h \ ${bits_srcdir}/codecvt.h \ ${bits_srcdir}/concept_check.h \ @@ -569,6 +569,7 @@ tr1_headers = \ ${tr1_srcdir}/gamma.tcc \ ${tr1_srcdir}/hypergeometric.tcc \ ${tr1_srcdir}/hashtable.h \ + ${tr1_srcdir}/hashtable_policy.h \ ${tr1_srcdir}/inttypes.h \ ${tr1_srcdir}/limits.h \ ${tr1_srcdir}/math.h \ @@ -592,8 +593,10 @@ tr1_headers = \ ${tr1_srcdir}/tgmath.h \ ${tr1_srcdir}/tuple \ ${tr1_srcdir}/type_traits \ - ${tr1_srcdir}/unordered_set \ ${tr1_srcdir}/unordered_map \ + ${tr1_srcdir}/unordered_map.h \ + ${tr1_srcdir}/unordered_set \ + ${tr1_srcdir}/unordered_set.h \ ${tr1_srcdir}/utility \ ${tr1_srcdir}/wchar.h \ ${tr1_srcdir}/wctype.h @@ -614,12 +617,8 @@ tr1_impl_headers = \ ${tr1_impl_srcdir}/cstdlib \ ${tr1_impl_srcdir}/cwchar \ ${tr1_impl_srcdir}/cwctype \ - ${tr1_impl_srcdir}/hashtable \ - ${tr1_impl_srcdir}/hashtable_policy.h \ ${tr1_impl_srcdir}/regex \ ${tr1_impl_srcdir}/type_traits \ - ${tr1_impl_srcdir}/unordered_map \ - ${tr1_impl_srcdir}/unordered_set \ ${tr1_impl_srcdir}/utility decimal_srcdir = ${glibcxx_srcdir}/include/decimal diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index cd6e5c53496..d4954ae058c 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -273,7 +273,6 @@ std_headers = \ ${std_srcdir}/array \ ${std_srcdir}/atomic \ ${std_srcdir}/bitset \ - ${std_srcdir}/c++0x_warning.h \ ${std_srcdir}/chrono \ ${std_srcdir}/complex \ ${std_srcdir}/condition_variable \ @@ -331,6 +330,7 @@ bits_headers = \ ${bits_srcdir}/basic_string.h \ ${bits_srcdir}/basic_string.tcc \ ${bits_srcdir}/boost_concept_check.h \ + ${bits_srcdir}/c++0x_warning.h \ ${bits_srcdir}/char_traits.h \ ${bits_srcdir}/codecvt.h \ ${bits_srcdir}/concept_check.h \ @@ -809,6 +809,7 @@ tr1_headers = \ ${tr1_srcdir}/gamma.tcc \ ${tr1_srcdir}/hypergeometric.tcc \ ${tr1_srcdir}/hashtable.h \ + ${tr1_srcdir}/hashtable_policy.h \ ${tr1_srcdir}/inttypes.h \ ${tr1_srcdir}/limits.h \ ${tr1_srcdir}/math.h \ @@ -832,8 +833,10 @@ tr1_headers = \ ${tr1_srcdir}/tgmath.h \ ${tr1_srcdir}/tuple \ ${tr1_srcdir}/type_traits \ - ${tr1_srcdir}/unordered_set \ ${tr1_srcdir}/unordered_map \ + ${tr1_srcdir}/unordered_map.h \ + ${tr1_srcdir}/unordered_set \ + ${tr1_srcdir}/unordered_set.h \ ${tr1_srcdir}/utility \ ${tr1_srcdir}/wchar.h \ ${tr1_srcdir}/wctype.h @@ -853,12 +856,8 @@ tr1_impl_headers = \ ${tr1_impl_srcdir}/cstdlib \ ${tr1_impl_srcdir}/cwchar \ ${tr1_impl_srcdir}/cwctype \ - ${tr1_impl_srcdir}/hashtable \ - ${tr1_impl_srcdir}/hashtable_policy.h \ ${tr1_impl_srcdir}/regex \ ${tr1_impl_srcdir}/type_traits \ - ${tr1_impl_srcdir}/unordered_map \ - ${tr1_impl_srcdir}/unordered_set \ ${tr1_impl_srcdir}/utility decimal_srcdir = ${glibcxx_srcdir}/include/decimal diff --git a/libstdc++-v3/include/std/c++0x_warning.h b/libstdc++-v3/include/bits/c++0x_warning.h similarity index 100% rename from libstdc++-v3/include/std/c++0x_warning.h rename to libstdc++-v3/include/bits/c++0x_warning.h diff --git a/libstdc++-v3/include/bits/forward_list.h b/libstdc++-v3/include/bits/forward_list.h index d7005e828c5..277e3790ebc 100644 --- a/libstdc++-v3/include/bits/forward_list.h +++ b/libstdc++-v3/include/bits/forward_list.h @@ -31,10 +31,6 @@ #pragma GCC system_header -#ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include -#else - #include #include #include @@ -1282,6 +1278,4 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_END_NAMESPACE // namespace std -#endif // __GXX_EXPERIMENTAL_CXX0X__ - #endif // _FORWARD_LIST_H diff --git a/libstdc++-v3/include/bits/functional_hash.h b/libstdc++-v3/include/bits/functional_hash.h index 18c8c04ca3f..02a3feb75ea 100644 --- a/libstdc++-v3/include/bits/functional_hash.h +++ b/libstdc++-v3/include/bits/functional_hash.h @@ -32,10 +32,6 @@ #pragma GCC system_header -#ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include -#endif - #include #include diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h index 60fdf2fcbb0..8119ad3e1f0 100644 --- a/libstdc++-v3/include/bits/shared_ptr.h +++ b/libstdc++-v3/include/bits/shared_ptr.h @@ -1,6 +1,6 @@ // shared_ptr and weak_ptr implementation -*- C++ -*- -// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010 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 @@ -49,10 +49,6 @@ #ifndef _SHARED_PTR_H #define _SHARED_PTR_H 1 -#ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include -#endif - #include _GLIBCXX_BEGIN_NAMESPACE(std) diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h index 7c08c81eac7..9a34b0387cc 100644 --- a/libstdc++-v3/include/bits/unique_ptr.h +++ b/libstdc++-v3/include/bits/unique_ptr.h @@ -1,6 +1,6 @@ // unique_ptr implementation -*- C++ -*- -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010 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 @@ -30,10 +30,6 @@ #ifndef _UNIQUE_PTR_H #define _UNIQUE_PTR_H 1 -#ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include -#endif - #include #include #include diff --git a/libstdc++-v3/include/c_global/ccomplex b/libstdc++-v3/include/c_global/ccomplex index e347e17193a..b1117e8d42e 100644 --- a/libstdc++-v3/include/c_global/ccomplex +++ b/libstdc++-v3/include/c_global/ccomplex @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010 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 @@ -32,7 +32,7 @@ #define _GLIBCXX_CCOMPLEX 1 #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #endif #if defined(_GLIBCXX_INCLUDE_AS_TR1) diff --git a/libstdc++-v3/include/c_global/cfenv b/libstdc++-v3/include/c_global/cfenv index 9b02c8cb999..4e401411767 100644 --- a/libstdc++-v3/include/c_global/cfenv +++ b/libstdc++-v3/include/c_global/cfenv @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010 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 @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #endif #if defined(_GLIBCXX_INCLUDE_AS_TR1) diff --git a/libstdc++-v3/include/c_global/cinttypes b/libstdc++-v3/include/c_global/cinttypes index 5ed1a2126be..d8de5ee5c92 100644 --- a/libstdc++-v3/include/c_global/cinttypes +++ b/libstdc++-v3/include/c_global/cinttypes @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010 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 @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #endif #if defined(_GLIBCXX_INCLUDE_AS_TR1) diff --git a/libstdc++-v3/include/c_global/cstdbool b/libstdc++-v3/include/c_global/cstdbool index 3012c46b459..dd428f2d288 100644 --- a/libstdc++-v3/include/c_global/cstdbool +++ b/libstdc++-v3/include/c_global/cstdbool @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010 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 @@ -32,7 +32,7 @@ #define _GLIBCXX_CSTDBOOL 1 #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else # include # if _GLIBCXX_HAVE_STDBOOL_H diff --git a/libstdc++-v3/include/c_global/cstdint b/libstdc++-v3/include/c_global/cstdint index 0927f8aae49..28e449cff81 100644 --- a/libstdc++-v3/include/c_global/cstdint +++ b/libstdc++-v3/include/c_global/cstdint @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010 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 @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #endif #if defined(_GLIBCXX_INCLUDE_AS_TR1) diff --git a/libstdc++-v3/include/c_global/ctgmath b/libstdc++-v3/include/c_global/ctgmath index 3c6fcf73527..6b51005cc11 100644 --- a/libstdc++-v3/include/c_global/ctgmath +++ b/libstdc++-v3/include/c_global/ctgmath @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010 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 @@ -32,7 +32,7 @@ #define _GLIBCXX_CTGMATH 1 #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else # include #endif diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map index 53ce7c09619..a5e6174fe6a 100644 --- a/libstdc++-v3/include/debug/unordered_map +++ b/libstdc++-v3/include/debug/unordered_map @@ -33,7 +33,7 @@ #ifdef __GXX_EXPERIMENTAL_CXX0X__ # include #else -# include +# include #endif #include diff --git a/libstdc++-v3/include/debug/unordered_set b/libstdc++-v3/include/debug/unordered_set index 19ff42408fd..f8517184023 100644 --- a/libstdc++-v3/include/debug/unordered_set +++ b/libstdc++-v3/include/debug/unordered_set @@ -33,7 +33,7 @@ #ifdef __GXX_EXPERIMENTAL_CXX0X__ # include #else -# include +# include #endif #include diff --git a/libstdc++-v3/include/profile/unordered_map b/libstdc++-v3/include/profile/unordered_map index 61f32f3036f..b90d58b5ab6 100644 --- a/libstdc++-v3/include/profile/unordered_map +++ b/libstdc++-v3/include/profile/unordered_map @@ -39,7 +39,7 @@ #ifdef __GXX_EXPERIMENTAL_CXX0X__ # include #else -# include +# include #endif #include diff --git a/libstdc++-v3/include/profile/unordered_set b/libstdc++-v3/include/profile/unordered_set index 0c0de77a58b..128cf602b45 100644 --- a/libstdc++-v3/include/profile/unordered_set +++ b/libstdc++-v3/include/profile/unordered_set @@ -39,7 +39,7 @@ #ifdef __GXX_EXPERIMENTAL_CXX0X__ # include #else -# include +# include #endif #include diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array index 70e77564442..d374c88a2b1 100644 --- a/libstdc++-v3/include/std/array +++ b/libstdc++-v3/include/std/array @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010 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 @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else #if defined(_GLIBCXX_INCLUDE_AS_TR1) diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic index de75b433ee9..5ef52f3763f 100644 --- a/libstdc++-v3/include/std/atomic +++ b/libstdc++-v3/include/std/atomic @@ -1,7 +1,6 @@ // -*- C++ -*- header. -// Copyright (C) 2008, 2009 -// Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010 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 @@ -36,7 +35,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #endif #include diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono index e80ec13c093..230b7f4e813 100644 --- a/libstdc++-v3/include/std/chrono +++ b/libstdc++-v3/include/std/chrono @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010 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 @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else #ifdef _GLIBCXX_INCLUDE_AS_TR1 diff --git a/libstdc++-v3/include/std/condition_variable b/libstdc++-v3/include/std/condition_variable index ff5af7214ca..c5ce207a905 100644 --- a/libstdc++-v3/include/std/condition_variable +++ b/libstdc++-v3/include/std/condition_variable @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else #include diff --git a/libstdc++-v3/include/std/forward_list b/libstdc++-v3/include/std/forward_list index 40a0812c049..16fdcc283ff 100644 --- a/libstdc++-v3/include/std/forward_list +++ b/libstdc++-v3/include/std/forward_list @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010 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 @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else #include diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future index 2f1eedc91ee..1ef03643d04 100644 --- a/libstdc++-v3/include/std/future +++ b/libstdc++-v3/include/std/future @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else #include diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex index 9b009ecb12b..7a1e259fc79 100644 --- a/libstdc++-v3/include/std/mutex +++ b/libstdc++-v3/include/std/mutex @@ -33,7 +33,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else #include diff --git a/libstdc++-v3/include/std/random b/libstdc++-v3/include/std/random index c1c7cdfda45..4d330eedd92 100644 --- a/libstdc++-v3/include/std/random +++ b/libstdc++-v3/include/std/random @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else #include diff --git a/libstdc++-v3/include/std/ratio b/libstdc++-v3/include/std/ratio index 4524f092328..e169d79e8a5 100644 --- a/libstdc++-v3/include/std/ratio +++ b/libstdc++-v3/include/std/ratio @@ -1,6 +1,6 @@ // ratio -*- C++ -*- -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010 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 @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else #include diff --git a/libstdc++-v3/include/std/regex b/libstdc++-v3/include/std/regex index 3b25044e56e..e8238299b22 100644 --- a/libstdc++-v3/include/std/regex +++ b/libstdc++-v3/include/std/regex @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010 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 @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else #if defined(_GLIBCXX_INCLUDE_AS_TR1) diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error index 864741129a9..0e8c69744e5 100644 --- a/libstdc++-v3/include/std/system_error +++ b/libstdc++-v3/include/std/system_error @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010 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 @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else #include diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread index 83b259d7949..2d7a7513834 100644 --- a/libstdc++-v3/include/std/thread +++ b/libstdc++-v3/include/std/thread @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010 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 @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else #include diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 1c46852a8fa..bba7ba7bd08 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010 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 @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else #include diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 37f66351c54..c8166198805 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1,6 +1,6 @@ // C++0x type_traits -*- C++ -*- -// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010 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 @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else #if defined(_GLIBCXX_INCLUDE_AS_TR1) diff --git a/libstdc++-v3/include/std/unordered_map b/libstdc++-v3/include/std/unordered_map index 2fe36660543..d8b94e2698c 100644 --- a/libstdc++-v3/include/std/unordered_map +++ b/libstdc++-v3/include/std/unordered_map @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else #include diff --git a/libstdc++-v3/include/std/unordered_set b/libstdc++-v3/include/std/unordered_set index 9eaa22f8a53..630ea9e9906 100644 --- a/libstdc++-v3/include/std/unordered_set +++ b/libstdc++-v3/include/std/unordered_set @@ -32,7 +32,7 @@ #pragma GCC system_header #ifndef __GXX_EXPERIMENTAL_CXX0X__ -# include +# include #else #include diff --git a/libstdc++-v3/include/tr1/hashtable.h b/libstdc++-v3/include/tr1/hashtable.h index 22fdbff6f6f..5064b1fdddb 100644 --- a/libstdc++-v3/include/tr1/hashtable.h +++ b/libstdc++-v3/include/tr1/hashtable.h @@ -1,6 +1,6 @@ // TR1 hashtable.h header -*- C++ -*- -// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2009, 2010 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 @@ -32,22 +32,1145 @@ #pragma GCC system_header -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# error TR1 header cannot be included from C++0x header -#endif +#include -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 -#endif +namespace std +{ +namespace tr1 +{ + // Class template _Hashtable, class definition. + + // Meaning of class template _Hashtable's template parameters + + // _Key and _Value: arbitrary CopyConstructible types. + + // _Allocator: an allocator type ([lib.allocator.requirements]) whose + // value type is Value. As a conforming extension, we allow for + // value type != Value. + + // _ExtractKey: function object that takes a object of type Value + // and returns a value of type _Key. + + // _Equal: function object that takes two objects of type k and returns + // a bool-like value that is true if the two objects are considered equal. + + // _H1: the hash function. A unary function object with argument type + // Key and result type size_t. Return values should be distributed + // over the entire range [0, numeric_limits:::max()]. + + // _H2: the range-hashing function (in the terminology of Tavori and + // Dreizin). A binary function object whose argument types and result + // type are all size_t. Given arguments r and N, the return value is + // in the range [0, N). + + // _Hash: the ranged hash function (Tavori and Dreizin). A binary function + // whose argument types are _Key and size_t and whose result type is + // size_t. Given arguments k and N, the return value is in the range + // [0, N). Default: hash(k, N) = h2(h1(k), N). If _Hash is anything other + // than the default, _H1 and _H2 are ignored. + + // _RehashPolicy: Policy class with three members, all of which govern + // the bucket count. _M_next_bkt(n) returns a bucket count no smaller + // than n. _M_bkt_for_elements(n) returns a bucket count appropriate + // for an element count of n. _M_need_rehash(n_bkt, n_elt, n_ins) + // determines whether, if the current bucket count is n_bkt and the + // current element count is n_elt, we need to increase the bucket + // count. If so, returns make_pair(true, n), where n is the new + // bucket count. If not, returns make_pair(false, ). + + // ??? Right now it is hard-wired that the number of buckets never + // shrinks. Should we allow _RehashPolicy to change that? + + // __cache_hash_code: bool. true if we store the value of the hash + // function along with the value. This is a time-space tradeoff. + // Storing it may improve lookup speed by reducing the number of times + // we need to call the Equal function. + + // __constant_iterators: bool. true if iterator and const_iterator are + // both constant iterator types. This is true for unordered_set and + // unordered_multiset, false for unordered_map and unordered_multimap. + + // __unique_keys: bool. true if the return value of _Hashtable::count(k) + // is always at most one, false if it may be an arbitrary number. This + // true for unordered_set and unordered_map, false for unordered_multiset + // and unordered_multimap. + + template + class _Hashtable + : public __detail::_Rehash_base<_RehashPolicy, + _Hashtable<_Key, _Value, _Allocator, + _ExtractKey, + _Equal, _H1, _H2, _Hash, + _RehashPolicy, + __cache_hash_code, + __constant_iterators, + __unique_keys> >, + public __detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Equal, + _H1, _H2, _Hash, __cache_hash_code>, + public __detail::_Map_base<_Key, _Value, _ExtractKey, __unique_keys, + _Hashtable<_Key, _Value, _Allocator, + _ExtractKey, + _Equal, _H1, _H2, _Hash, + _RehashPolicy, + __cache_hash_code, + __constant_iterators, + __unique_keys> > + { + public: + typedef _Allocator allocator_type; + typedef _Value value_type; + typedef _Key key_type; + typedef _Equal key_equal; + // mapped_type, if present, comes from _Map_base. + // hasher, if present, comes from _Hash_code_base. + typedef typename _Allocator::difference_type difference_type; + typedef typename _Allocator::size_type size_type; + typedef typename _Allocator::pointer pointer; + typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Allocator::reference reference; + typedef typename _Allocator::const_reference const_reference; + + typedef __detail::_Node_iterator + local_iterator; + typedef __detail::_Node_const_iterator + const_local_iterator; + + typedef __detail::_Hashtable_iterator + iterator; + typedef __detail::_Hashtable_const_iterator + const_iterator; + + template + friend struct __detail::_Map_base; + + private: + typedef __detail::_Hash_node<_Value, __cache_hash_code> _Node; + typedef typename _Allocator::template rebind<_Node>::other + _Node_allocator_type; + typedef typename _Allocator::template rebind<_Node*>::other + _Bucket_allocator_type; + + typedef typename _Allocator::template rebind<_Value>::other + _Value_allocator_type; + + _Node_allocator_type _M_node_allocator; + _Node** _M_buckets; + size_type _M_bucket_count; + size_type _M_element_count; + _RehashPolicy _M_rehash_policy; + + _Node* + _M_allocate_node(const value_type& __v); + + void + _M_deallocate_node(_Node* __n); + + void + _M_deallocate_nodes(_Node**, size_type); + + _Node** + _M_allocate_buckets(size_type __n); + + void + _M_deallocate_buckets(_Node**, size_type __n); + + public: + // Constructor, destructor, assignment, swap + _Hashtable(size_type __bucket_hint, + const _H1&, const _H2&, const _Hash&, + const _Equal&, const _ExtractKey&, + const allocator_type&); + + template + _Hashtable(_InputIterator __first, _InputIterator __last, + size_type __bucket_hint, + const _H1&, const _H2&, const _Hash&, + const _Equal&, const _ExtractKey&, + const allocator_type&); + + _Hashtable(const _Hashtable&); + + _Hashtable& + operator=(const _Hashtable&); + + ~_Hashtable(); + + void swap(_Hashtable&); + + // Basic container operations + iterator + begin() + { + iterator __i(_M_buckets); + if (!__i._M_cur_node) + __i._M_incr_bucket(); + return __i; + } + + const_iterator + begin() const + { + const_iterator __i(_M_buckets); + if (!__i._M_cur_node) + __i._M_incr_bucket(); + return __i; + } + + iterator + end() + { return iterator(_M_buckets + _M_bucket_count); } + + const_iterator + end() const + { return const_iterator(_M_buckets + _M_bucket_count); } + + size_type + size() const + { return _M_element_count; } + + bool + empty() const + { return size() == 0; } + + allocator_type + get_allocator() const + { return allocator_type(_M_node_allocator); } + + _Value_allocator_type + _M_get_Value_allocator() const + { return _Value_allocator_type(_M_node_allocator); } + + size_type + max_size() const + { return _M_node_allocator.max_size(); } + + // Observers + key_equal + key_eq() const + { return this->_M_eq; } + + // hash_function, if present, comes from _Hash_code_base. + + // Bucket operations + size_type + bucket_count() const + { return _M_bucket_count; } + + size_type + max_bucket_count() const + { return max_size(); } + + size_type + bucket_size(size_type __n) const + { return std::distance(begin(__n), end(__n)); } + + size_type + bucket(const key_type& __k) const + { + return this->_M_bucket_index(__k, this->_M_hash_code(__k), + bucket_count()); + } + + local_iterator + begin(size_type __n) + { return local_iterator(_M_buckets[__n]); } + + local_iterator + end(size_type) + { return local_iterator(0); } + + const_local_iterator + begin(size_type __n) const + { return const_local_iterator(_M_buckets[__n]); } + + const_local_iterator + end(size_type) const + { return const_local_iterator(0); } + + float + load_factor() const + { + return static_cast(size()) / static_cast(bucket_count()); + } + + // max_load_factor, if present, comes from _Rehash_base. + + // Generalization of max_load_factor. Extension, not found in TR1. Only + // useful if _RehashPolicy is something other than the default. + const _RehashPolicy& + __rehash_policy() const + { return _M_rehash_policy; } + + void + __rehash_policy(const _RehashPolicy&); + + // Lookup. + iterator + find(const key_type& __k); + + const_iterator + find(const key_type& __k) const; + + size_type + count(const key_type& __k) const; + + std::pair + equal_range(const key_type& __k); + + std::pair + equal_range(const key_type& __k) const; + + private: // Find, insert and erase helper functions + // ??? This dispatching is a workaround for the fact that we don't + // have partial specialization of member templates; it would be + // better to just specialize insert on __unique_keys. There may be a + // cleaner workaround. + typedef typename __gnu_cxx::__conditional_type<__unique_keys, + std::pair, iterator>::__type + _Insert_Return_Type; + + typedef typename __gnu_cxx::__conditional_type<__unique_keys, + std::_Select1st<_Insert_Return_Type>, + std::_Identity<_Insert_Return_Type> + >::__type + _Insert_Conv_Type; + + _Node* + _M_find_node(_Node*, const key_type&, + typename _Hashtable::_Hash_code_type) const; + + iterator + _M_insert_bucket(const value_type&, size_type, + typename _Hashtable::_Hash_code_type); + + std::pair + _M_insert(const value_type&, std::tr1::true_type); + + iterator + _M_insert(const value_type&, std::tr1::false_type); + + void + _M_erase_node(_Node*, _Node**); + + public: + // Insert and erase + _Insert_Return_Type + insert(const value_type& __v) + { return _M_insert(__v, std::tr1::integral_constant()); } + + iterator + insert(iterator, const value_type& __v) + { return iterator(_Insert_Conv_Type()(this->insert(__v))); } + + const_iterator + insert(const_iterator, const value_type& __v) + { return const_iterator(_Insert_Conv_Type()(this->insert(__v))); } + + template + void + insert(_InputIterator __first, _InputIterator __last); + + iterator + erase(iterator); + + const_iterator + erase(const_iterator); + + size_type + erase(const key_type&); + + iterator + erase(iterator, iterator); + + const_iterator + erase(const_iterator, const_iterator); + + void + clear(); + + // Set number of buckets to be appropriate for container of n element. + void rehash(size_type __n); + + private: + // Unconditionally change size of bucket array to n. + void _M_rehash(size_type __n); + }; + + + // Definitions of class template _Hashtable's out-of-line member functions. + template + typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, + __chc, __cit, __uk>::_Node* + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + _M_allocate_node(const value_type& __v) + { + _Node* __n = _M_node_allocator.allocate(1); + __try + { + _M_get_Value_allocator().construct(&__n->_M_v, __v); + __n->_M_next = 0; + return __n; + } + __catch(...) + { + _M_node_allocator.deallocate(__n, 1); + __throw_exception_again; + } + } + + template + void + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + _M_deallocate_node(_Node* __n) + { + _M_get_Value_allocator().destroy(&__n->_M_v); + _M_node_allocator.deallocate(__n, 1); + } + + template + void + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + _M_deallocate_nodes(_Node** __array, size_type __n) + { + for (size_type __i = 0; __i < __n; ++__i) + { + _Node* __p = __array[__i]; + while (__p) + { + _Node* __tmp = __p; + __p = __p->_M_next; + _M_deallocate_node(__tmp); + } + __array[__i] = 0; + } + } + + template + typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, + __chc, __cit, __uk>::_Node** + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + _M_allocate_buckets(size_type __n) + { + _Bucket_allocator_type __alloc(_M_node_allocator); + + // We allocate one extra bucket to hold a sentinel, an arbitrary + // non-null pointer. Iterator increment relies on this. + _Node** __p = __alloc.allocate(__n + 1); + std::fill(__p, __p + __n, (_Node*) 0); + __p[__n] = reinterpret_cast<_Node*>(0x1000); + return __p; + } + + template + void + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + _M_deallocate_buckets(_Node** __p, size_type __n) + { + _Bucket_allocator_type __alloc(_M_node_allocator); + __alloc.deallocate(__p, __n + 1); + } + + template + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + _Hashtable(size_type __bucket_hint, + const _H1& __h1, const _H2& __h2, const _Hash& __h, + const _Equal& __eq, const _ExtractKey& __exk, + const allocator_type& __a) + : __detail::_Rehash_base<_RehashPolicy, _Hashtable>(), + __detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Equal, + _H1, _H2, _Hash, __chc>(__exk, __eq, + __h1, __h2, __h), + __detail::_Map_base<_Key, _Value, _ExtractKey, __uk, _Hashtable>(), + _M_node_allocator(__a), + _M_bucket_count(0), + _M_element_count(0), + _M_rehash_policy() + { + _M_bucket_count = _M_rehash_policy._M_next_bkt(__bucket_hint); + _M_buckets = _M_allocate_buckets(_M_bucket_count); + } + + template + template + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + _Hashtable(_InputIterator __f, _InputIterator __l, + size_type __bucket_hint, + const _H1& __h1, const _H2& __h2, const _Hash& __h, + const _Equal& __eq, const _ExtractKey& __exk, + const allocator_type& __a) + : __detail::_Rehash_base<_RehashPolicy, _Hashtable>(), + __detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Equal, + _H1, _H2, _Hash, __chc>(__exk, __eq, + __h1, __h2, __h), + __detail::_Map_base<_Key, _Value, _ExtractKey, __uk, _Hashtable>(), + _M_node_allocator(__a), + _M_bucket_count(0), + _M_element_count(0), + _M_rehash_policy() + { + _M_bucket_count = std::max(_M_rehash_policy._M_next_bkt(__bucket_hint), + _M_rehash_policy. + _M_bkt_for_elements(__detail:: + __distance_fw(__f, + __l))); + _M_buckets = _M_allocate_buckets(_M_bucket_count); + __try + { + for (; __f != __l; ++__f) + this->insert(*__f); + } + __catch(...) + { + clear(); + _M_deallocate_buckets(_M_buckets, _M_bucket_count); + __throw_exception_again; + } + } + + template + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + _Hashtable(const _Hashtable& __ht) + : __detail::_Rehash_base<_RehashPolicy, _Hashtable>(__ht), + __detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Equal, + _H1, _H2, _Hash, __chc>(__ht), + __detail::_Map_base<_Key, _Value, _ExtractKey, __uk, _Hashtable>(__ht), + _M_node_allocator(__ht._M_node_allocator), + _M_bucket_count(__ht._M_bucket_count), + _M_element_count(__ht._M_element_count), + _M_rehash_policy(__ht._M_rehash_policy) + { + _M_buckets = _M_allocate_buckets(_M_bucket_count); + __try + { + for (size_type __i = 0; __i < __ht._M_bucket_count; ++__i) + { + _Node* __n = __ht._M_buckets[__i]; + _Node** __tail = _M_buckets + __i; + while (__n) + { + *__tail = _M_allocate_node(__n->_M_v); + this->_M_copy_code(*__tail, __n); + __tail = &((*__tail)->_M_next); + __n = __n->_M_next; + } + } + } + __catch(...) + { + clear(); + _M_deallocate_buckets(_M_buckets, _M_bucket_count); + __throw_exception_again; + } + } + + template + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>& + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + operator=(const _Hashtable& __ht) + { + _Hashtable __tmp(__ht); + this->swap(__tmp); + return *this; + } + + template + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + ~_Hashtable() + { + clear(); + _M_deallocate_buckets(_M_buckets, _M_bucket_count); + } + + template + void + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + swap(_Hashtable& __x) + { + // The only base class with member variables is hash_code_base. We + // define _Hash_code_base::_M_swap because different specializations + // have different members. + __detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Equal, + _H1, _H2, _Hash, __chc>::_M_swap(__x); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 431. Swapping containers with unequal allocators. + std::__alloc_swap<_Node_allocator_type>::_S_do_it(_M_node_allocator, + __x._M_node_allocator); + + std::swap(_M_rehash_policy, __x._M_rehash_policy); + std::swap(_M_buckets, __x._M_buckets); + std::swap(_M_bucket_count, __x._M_bucket_count); + std::swap(_M_element_count, __x._M_element_count); + } + + template + void + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + __rehash_policy(const _RehashPolicy& __pol) + { + _M_rehash_policy = __pol; + size_type __n_bkt = __pol._M_bkt_for_elements(_M_element_count); + if (__n_bkt > _M_bucket_count) + _M_rehash(__n_bkt); + } + + template + typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, + __chc, __cit, __uk>::iterator + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + find(const key_type& __k) + { + typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); + std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); + _Node* __p = _M_find_node(_M_buckets[__n], __k, __code); + return __p ? iterator(__p, _M_buckets + __n) : this->end(); + } + + template + typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, + __chc, __cit, __uk>::const_iterator + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + find(const key_type& __k) const + { + typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); + std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); + _Node* __p = _M_find_node(_M_buckets[__n], __k, __code); + return __p ? const_iterator(__p, _M_buckets + __n) : this->end(); + } + + template + typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, + __chc, __cit, __uk>::size_type + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + count(const key_type& __k) const + { + typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); + std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); + std::size_t __result = 0; + for (_Node* __p = _M_buckets[__n]; __p; __p = __p->_M_next) + if (this->_M_compare(__k, __code, __p)) + ++__result; + return __result; + } + + template + std::pair::iterator, + typename _Hashtable<_Key, _Value, _Allocator, + _ExtractKey, _Equal, _H1, + _H2, _Hash, _RehashPolicy, + __chc, __cit, __uk>::iterator> + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + equal_range(const key_type& __k) + { + typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); + std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); + _Node** __head = _M_buckets + __n; + _Node* __p = _M_find_node(*__head, __k, __code); + + if (__p) + { + _Node* __p1 = __p->_M_next; + for (; __p1; __p1 = __p1->_M_next) + if (!this->_M_compare(__k, __code, __p1)) + break; + + iterator __first(__p, __head); + iterator __last(__p1, __head); + if (!__p1) + __last._M_incr_bucket(); + return std::make_pair(__first, __last); + } + else + return std::make_pair(this->end(), this->end()); + } + + template + std::pair::const_iterator, + typename _Hashtable<_Key, _Value, _Allocator, + _ExtractKey, _Equal, _H1, + _H2, _Hash, _RehashPolicy, + __chc, __cit, __uk>::const_iterator> + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + equal_range(const key_type& __k) const + { + typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); + std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); + _Node** __head = _M_buckets + __n; + _Node* __p = _M_find_node(*__head, __k, __code); + + if (__p) + { + _Node* __p1 = __p->_M_next; + for (; __p1; __p1 = __p1->_M_next) + if (!this->_M_compare(__k, __code, __p1)) + break; + + const_iterator __first(__p, __head); + const_iterator __last(__p1, __head); + if (!__p1) + __last._M_incr_bucket(); + return std::make_pair(__first, __last); + } + else + return std::make_pair(this->end(), this->end()); + } + + // Find the node whose key compares equal to k, beginning the search + // at p (usually the head of a bucket). Return nil if no node is found. + template + typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, + _Equal, _H1, _H2, _Hash, _RehashPolicy, + __chc, __cit, __uk>::_Node* + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + _M_find_node(_Node* __p, const key_type& __k, + typename _Hashtable::_Hash_code_type __code) const + { + for (; __p; __p = __p->_M_next) + if (this->_M_compare(__k, __code, __p)) + return __p; + return false; + } + + // Insert v in bucket n (assumes no element with its key already present). + template + typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, + __chc, __cit, __uk>::iterator + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + _M_insert_bucket(const value_type& __v, size_type __n, + typename _Hashtable::_Hash_code_type __code) + { + std::pair __do_rehash + = _M_rehash_policy._M_need_rehash(_M_bucket_count, + _M_element_count, 1); + + // Allocate the new node before doing the rehash so that we don't + // do a rehash if the allocation throws. + _Node* __new_node = _M_allocate_node(__v); + + __try + { + if (__do_rehash.first) + { + const key_type& __k = this->_M_extract(__v); + __n = this->_M_bucket_index(__k, __code, __do_rehash.second); + _M_rehash(__do_rehash.second); + } + + __new_node->_M_next = _M_buckets[__n]; + this->_M_store_code(__new_node, __code); + _M_buckets[__n] = __new_node; + ++_M_element_count; + return iterator(__new_node, _M_buckets + __n); + } + __catch(...) + { + _M_deallocate_node(__new_node); + __throw_exception_again; + } + } + + // Insert v if no element with its key is already present. + template + std::pair::iterator, bool> + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + _M_insert(const value_type& __v, std::tr1::true_type) + { + const key_type& __k = this->_M_extract(__v); + typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); + size_type __n = this->_M_bucket_index(__k, __code, _M_bucket_count); + + if (_Node* __p = _M_find_node(_M_buckets[__n], __k, __code)) + return std::make_pair(iterator(__p, _M_buckets + __n), false); + return std::make_pair(_M_insert_bucket(__v, __n, __code), true); + } + + // Insert v unconditionally. + template + typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, + __chc, __cit, __uk>::iterator + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + _M_insert(const value_type& __v, std::tr1::false_type) + { + std::pair __do_rehash + = _M_rehash_policy._M_need_rehash(_M_bucket_count, + _M_element_count, 1); + if (__do_rehash.first) + _M_rehash(__do_rehash.second); + + const key_type& __k = this->_M_extract(__v); + typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); + size_type __n = this->_M_bucket_index(__k, __code, _M_bucket_count); + + // First find the node, avoid leaking new_node if compare throws. + _Node* __prev = _M_find_node(_M_buckets[__n], __k, __code); + _Node* __new_node = _M_allocate_node(__v); + + if (__prev) + { + __new_node->_M_next = __prev->_M_next; + __prev->_M_next = __new_node; + } + else + { + __new_node->_M_next = _M_buckets[__n]; + _M_buckets[__n] = __new_node; + } + this->_M_store_code(__new_node, __code); + + ++_M_element_count; + return iterator(__new_node, _M_buckets + __n); + } + + // For erase(iterator) and erase(const_iterator). + template + void + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + _M_erase_node(_Node* __p, _Node** __b) + { + _Node* __cur = *__b; + if (__cur == __p) + *__b = __cur->_M_next; + else + { + _Node* __next = __cur->_M_next; + while (__next != __p) + { + __cur = __next; + __next = __cur->_M_next; + } + __cur->_M_next = __next->_M_next; + } + + _M_deallocate_node(__p); + --_M_element_count; + } + + template + template + void + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + insert(_InputIterator __first, _InputIterator __last) + { + size_type __n_elt = __detail::__distance_fw(__first, __last); + std::pair __do_rehash + = _M_rehash_policy._M_need_rehash(_M_bucket_count, + _M_element_count, __n_elt); + if (__do_rehash.first) + _M_rehash(__do_rehash.second); + + for (; __first != __last; ++__first) + this->insert(*__first); + } + + template + typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, + __chc, __cit, __uk>::iterator + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + erase(iterator __it) + { + iterator __result = __it; + ++__result; + _M_erase_node(__it._M_cur_node, __it._M_cur_bucket); + return __result; + } + + template + typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, + __chc, __cit, __uk>::const_iterator + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + erase(const_iterator __it) + { + const_iterator __result = __it; + ++__result; + _M_erase_node(__it._M_cur_node, __it._M_cur_bucket); + return __result; + } + + template + typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, + __chc, __cit, __uk>::size_type + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + erase(const key_type& __k) + { + typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); + std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); + size_type __result = 0; + + _Node** __slot = _M_buckets + __n; + while (*__slot && !this->_M_compare(__k, __code, *__slot)) + __slot = &((*__slot)->_M_next); + + _Node** __saved_slot = 0; + while (*__slot && this->_M_compare(__k, __code, *__slot)) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 526. Is it undefined if a function in the standard changes + // in parameters? + if (&this->_M_extract((*__slot)->_M_v) != &__k) + { + _Node* __p = *__slot; + *__slot = __p->_M_next; + _M_deallocate_node(__p); + --_M_element_count; + ++__result; + } + else + { + __saved_slot = __slot; + __slot = &((*__slot)->_M_next); + } + } + + if (__saved_slot) + { + _Node* __p = *__saved_slot; + *__saved_slot = __p->_M_next; + _M_deallocate_node(__p); + --_M_element_count; + ++__result; + } + + return __result; + } + + // ??? This could be optimized by taking advantage of the bucket + // structure, but it's not clear that it's worth doing. It probably + // wouldn't even be an optimization unless the load factor is large. + template + typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, + __chc, __cit, __uk>::iterator + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + erase(iterator __first, iterator __last) + { + while (__first != __last) + __first = this->erase(__first); + return __last; + } + + template + typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, + __chc, __cit, __uk>::const_iterator + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + erase(const_iterator __first, const_iterator __last) + { + while (__first != __last) + __first = this->erase(__first); + return __last; + } + + template + void + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + clear() + { + _M_deallocate_nodes(_M_buckets, _M_bucket_count); + _M_element_count = 0; + } + + template + void + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + rehash(size_type __n) + { + _M_rehash(std::max(_M_rehash_policy._M_next_bkt(__n), + _M_rehash_policy._M_bkt_for_elements(_M_element_count + + 1))); + } + + template + void + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + _M_rehash(size_type __n) + { + _Node** __new_array = _M_allocate_buckets(__n); + __try + { + for (size_type __i = 0; __i < _M_bucket_count; ++__i) + while (_Node* __p = _M_buckets[__i]) + { + std::size_t __new_index = this->_M_bucket_index(__p, __n); + _M_buckets[__i] = __p->_M_next; + __p->_M_next = __new_array[__new_index]; + __new_array[__new_index] = __p; + } + _M_deallocate_buckets(_M_buckets, _M_bucket_count); + _M_bucket_count = __n; + _M_buckets = __new_array; + } + __catch(...) + { + // A failure here means that a hash function threw an exception. + // We can't restore the previous state without calling the hash + // function again, so the only sensible recovery is to delete + // everything. + _M_deallocate_nodes(__new_array, __n); + _M_deallocate_buckets(__new_array, __n); + _M_deallocate_nodes(_M_buckets, _M_bucket_count); + _M_element_count = 0; + __throw_exception_again; + } + } +} +} #endif // _GLIBCXX_TR1_HASHTABLE_H diff --git a/libstdc++-v3/include/tr1_impl/hashtable_policy.h b/libstdc++-v3/include/tr1/hashtable_policy.h similarity index 99% rename from libstdc++-v3/include/tr1_impl/hashtable_policy.h rename to libstdc++-v3/include/tr1/hashtable_policy.h index 6b2dd342c17..60a4e644999 100644 --- a/libstdc++-v3/include/tr1_impl/hashtable_policy.h +++ b/libstdc++-v3/include/tr1/hashtable_policy.h @@ -1,6 +1,6 @@ // Internal policy header for TR1 unordered_set and unordered_map -*- C++ -*- -// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2010 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 @@ -22,7 +22,7 @@ // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . -/** @file tr1_impl/hashtable_policy.h +/** @file tr1/hashtable_policy.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ diff --git a/libstdc++-v3/include/tr1/unordered_map b/libstdc++-v3/include/tr1/unordered_map index 4ac2d58aefb..50bab9e4aef 100644 --- a/libstdc++-v3/include/tr1/unordered_map +++ b/libstdc++-v3/include/tr1/unordered_map @@ -39,6 +39,6 @@ #include #include #include -#include +#include #endif // _GLIBCXX_TR1_UNORDERED_MAP diff --git a/libstdc++-v3/include/tr1_impl/unordered_map b/libstdc++-v3/include/tr1/unordered_map.h similarity index 98% rename from libstdc++-v3/include/tr1_impl/unordered_map rename to libstdc++-v3/include/tr1/unordered_map.h index 54b1e562954..9aa20a7266c 100644 --- a/libstdc++-v3/include/tr1_impl/unordered_map +++ b/libstdc++-v3/include/tr1/unordered_map.h @@ -1,6 +1,6 @@ -// TR1 unordered_map -*- C++ -*- +// TR1 unordered_map implementation -*- C++ -*- -// Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2010 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 @@ -22,7 +22,7 @@ // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . -/** @file tr1_impl/unordered_map +/** @file tr1/unordered_map.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ diff --git a/libstdc++-v3/include/tr1/unordered_set b/libstdc++-v3/include/tr1/unordered_set index 73e3adb34e6..3e2cbb039dc 100644 --- a/libstdc++-v3/include/tr1/unordered_set +++ b/libstdc++-v3/include/tr1/unordered_set @@ -39,6 +39,6 @@ #include #include #include -#include +#include #endif // _GLIBCXX_TR1_UNORDERED_SET diff --git a/libstdc++-v3/include/tr1_impl/unordered_set b/libstdc++-v3/include/tr1/unordered_set.h similarity index 98% rename from libstdc++-v3/include/tr1_impl/unordered_set rename to libstdc++-v3/include/tr1/unordered_set.h index 6967ae5c343..e072035ded4 100644 --- a/libstdc++-v3/include/tr1_impl/unordered_set +++ b/libstdc++-v3/include/tr1/unordered_set.h @@ -1,6 +1,6 @@ -// TR1 unordered_set -*- C++ -*- +// TR1 unordered_set implementation -*- C++ -*- -// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2010 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 @@ -22,7 +22,7 @@ // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . -/** @file tr1_impl/unordered_set +/** @file tr1/unordered_set.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ diff --git a/libstdc++-v3/include/tr1_impl/hashtable b/libstdc++-v3/include/tr1_impl/hashtable deleted file mode 100644 index 5be91b01068..00000000000 --- a/libstdc++-v3/include/tr1_impl/hashtable +++ /dev/null @@ -1,1187 +0,0 @@ -// Internal header for TR1 unordered_set and unordered_map -*- C++ -*- - -// Copyright (C) 2007, 2008, 2009, 2010 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 of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// . - -/** @file tr1_impl/hashtable - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - -// This header file defines std::tr1::hashtable, which is used to -// implement std::tr1::unordered_set, std::tr1::unordered_map, -// std::tr1::unordered_multiset, and std::tr1::unordered_multimap. -// hashtable has many template parameters, partly to accommodate -// the differences between those four classes and partly to -// accommodate policy choices that go beyond TR1 specifications. - -// Class template hashtable attempts to encapsulate all reasonable -// variation among hash tables that use chaining. It does not handle -// open addressing. - -// References: -// M. Austern, "A Proposal to Add Hash Tables to the Standard -// Library (revision 4)," WG21 Document N1456=03-0039, 2003. -// D. E. Knuth, The Art of Computer Programming, v. 3, Sorting and Searching. -// A. Tavori and V. Dreizin, "Policy-Based Data Structures", 2004. -// http://gcc.gnu.org/onlinedocs/libstdc++/ext/pb_ds/index.html - -#include - -namespace std -{ -namespace tr1 -{ - // Class template _Hashtable, class definition. - - // Meaning of class template _Hashtable's template parameters - - // _Key and _Value: arbitrary CopyConstructible types. - - // _Allocator: an allocator type ([lib.allocator.requirements]) whose - // value type is Value. As a conforming extension, we allow for - // value type != Value. - - // _ExtractKey: function object that takes a object of type Value - // and returns a value of type _Key. - - // _Equal: function object that takes two objects of type k and returns - // a bool-like value that is true if the two objects are considered equal. - - // _H1: the hash function. A unary function object with argument type - // Key and result type size_t. Return values should be distributed - // over the entire range [0, numeric_limits:::max()]. - - // _H2: the range-hashing function (in the terminology of Tavori and - // Dreizin). A binary function object whose argument types and result - // type are all size_t. Given arguments r and N, the return value is - // in the range [0, N). - - // _Hash: the ranged hash function (Tavori and Dreizin). A binary function - // whose argument types are _Key and size_t and whose result type is - // size_t. Given arguments k and N, the return value is in the range - // [0, N). Default: hash(k, N) = h2(h1(k), N). If _Hash is anything other - // than the default, _H1 and _H2 are ignored. - - // _RehashPolicy: Policy class with three members, all of which govern - // the bucket count. _M_next_bkt(n) returns a bucket count no smaller - // than n. _M_bkt_for_elements(n) returns a bucket count appropriate - // for an element count of n. _M_need_rehash(n_bkt, n_elt, n_ins) - // determines whether, if the current bucket count is n_bkt and the - // current element count is n_elt, we need to increase the bucket - // count. If so, returns make_pair(true, n), where n is the new - // bucket count. If not, returns make_pair(false, ). - - // ??? Right now it is hard-wired that the number of buckets never - // shrinks. Should we allow _RehashPolicy to change that? - - // __cache_hash_code: bool. true if we store the value of the hash - // function along with the value. This is a time-space tradeoff. - // Storing it may improve lookup speed by reducing the number of times - // we need to call the Equal function. - - // __constant_iterators: bool. true if iterator and const_iterator are - // both constant iterator types. This is true for unordered_set and - // unordered_multiset, false for unordered_map and unordered_multimap. - - // __unique_keys: bool. true if the return value of _Hashtable::count(k) - // is always at most one, false if it may be an arbitrary number. This - // true for unordered_set and unordered_map, false for unordered_multiset - // and unordered_multimap. - - template - class _Hashtable - : public __detail::_Rehash_base<_RehashPolicy, - _Hashtable<_Key, _Value, _Allocator, - _ExtractKey, - _Equal, _H1, _H2, _Hash, - _RehashPolicy, - __cache_hash_code, - __constant_iterators, - __unique_keys> >, - public __detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Equal, - _H1, _H2, _Hash, __cache_hash_code>, - public __detail::_Map_base<_Key, _Value, _ExtractKey, __unique_keys, - _Hashtable<_Key, _Value, _Allocator, - _ExtractKey, - _Equal, _H1, _H2, _Hash, - _RehashPolicy, - __cache_hash_code, - __constant_iterators, - __unique_keys> > - { - public: - typedef _Allocator allocator_type; - typedef _Value value_type; - typedef _Key key_type; - typedef _Equal key_equal; - // mapped_type, if present, comes from _Map_base. - // hasher, if present, comes from _Hash_code_base. - typedef typename _Allocator::difference_type difference_type; - typedef typename _Allocator::size_type size_type; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; - typedef typename _Allocator::reference reference; - typedef typename _Allocator::const_reference const_reference; - - typedef __detail::_Node_iterator - local_iterator; - typedef __detail::_Node_const_iterator - const_local_iterator; - - typedef __detail::_Hashtable_iterator - iterator; - typedef __detail::_Hashtable_const_iterator - const_iterator; - - template - friend struct __detail::_Map_base; - - private: - typedef __detail::_Hash_node<_Value, __cache_hash_code> _Node; - typedef typename _Allocator::template rebind<_Node>::other - _Node_allocator_type; - typedef typename _Allocator::template rebind<_Node*>::other - _Bucket_allocator_type; - - typedef typename _Allocator::template rebind<_Value>::other - _Value_allocator_type; - - _Node_allocator_type _M_node_allocator; - _Node** _M_buckets; - size_type _M_bucket_count; - size_type _M_element_count; - _RehashPolicy _M_rehash_policy; - - _Node* - _M_allocate_node(const value_type& __v); - - void - _M_deallocate_node(_Node* __n); - - void - _M_deallocate_nodes(_Node**, size_type); - - _Node** - _M_allocate_buckets(size_type __n); - - void - _M_deallocate_buckets(_Node**, size_type __n); - - public: - // Constructor, destructor, assignment, swap - _Hashtable(size_type __bucket_hint, - const _H1&, const _H2&, const _Hash&, - const _Equal&, const _ExtractKey&, - const allocator_type&); - - template - _Hashtable(_InputIterator __first, _InputIterator __last, - size_type __bucket_hint, - const _H1&, const _H2&, const _Hash&, - const _Equal&, const _ExtractKey&, - const allocator_type&); - - _Hashtable(const _Hashtable&); - - _Hashtable& - operator=(const _Hashtable&); - - ~_Hashtable(); - - void swap(_Hashtable&); - - // Basic container operations - iterator - begin() - { - iterator __i(_M_buckets); - if (!__i._M_cur_node) - __i._M_incr_bucket(); - return __i; - } - - const_iterator - begin() const - { - const_iterator __i(_M_buckets); - if (!__i._M_cur_node) - __i._M_incr_bucket(); - return __i; - } - - iterator - end() - { return iterator(_M_buckets + _M_bucket_count); } - - const_iterator - end() const - { return const_iterator(_M_buckets + _M_bucket_count); } - - size_type - size() const - { return _M_element_count; } - - bool - empty() const - { return size() == 0; } - - allocator_type - get_allocator() const - { return allocator_type(_M_node_allocator); } - - _Value_allocator_type - _M_get_Value_allocator() const - { return _Value_allocator_type(_M_node_allocator); } - - size_type - max_size() const - { return _M_node_allocator.max_size(); } - - // Observers - key_equal - key_eq() const - { return this->_M_eq; } - - // hash_function, if present, comes from _Hash_code_base. - - // Bucket operations - size_type - bucket_count() const - { return _M_bucket_count; } - - size_type - max_bucket_count() const - { return max_size(); } - - size_type - bucket_size(size_type __n) const - { return std::distance(begin(__n), end(__n)); } - - size_type - bucket(const key_type& __k) const - { - return this->_M_bucket_index(__k, this->_M_hash_code(__k), - bucket_count()); - } - - local_iterator - begin(size_type __n) - { return local_iterator(_M_buckets[__n]); } - - local_iterator - end(size_type) - { return local_iterator(0); } - - const_local_iterator - begin(size_type __n) const - { return const_local_iterator(_M_buckets[__n]); } - - const_local_iterator - end(size_type) const - { return const_local_iterator(0); } - - float - load_factor() const - { - return static_cast(size()) / static_cast(bucket_count()); - } - - // max_load_factor, if present, comes from _Rehash_base. - - // Generalization of max_load_factor. Extension, not found in TR1. Only - // useful if _RehashPolicy is something other than the default. - const _RehashPolicy& - __rehash_policy() const - { return _M_rehash_policy; } - - void - __rehash_policy(const _RehashPolicy&); - - // Lookup. - iterator - find(const key_type& __k); - - const_iterator - find(const key_type& __k) const; - - size_type - count(const key_type& __k) const; - - std::pair - equal_range(const key_type& __k); - - std::pair - equal_range(const key_type& __k) const; - - private: // Find, insert and erase helper functions - // ??? This dispatching is a workaround for the fact that we don't - // have partial specialization of member templates; it would be - // better to just specialize insert on __unique_keys. There may be a - // cleaner workaround. - typedef typename __gnu_cxx::__conditional_type<__unique_keys, - std::pair, iterator>::__type - _Insert_Return_Type; - - typedef typename __gnu_cxx::__conditional_type<__unique_keys, - std::_Select1st<_Insert_Return_Type>, - std::_Identity<_Insert_Return_Type> - >::__type - _Insert_Conv_Type; - - _Node* - _M_find_node(_Node*, const key_type&, - typename _Hashtable::_Hash_code_type) const; - - iterator - _M_insert_bucket(const value_type&, size_type, - typename _Hashtable::_Hash_code_type); - - std::pair - _M_insert(const value_type&, std::tr1::true_type); - - iterator - _M_insert(const value_type&, std::tr1::false_type); - - void - _M_erase_node(_Node*, _Node**); - - public: - // Insert and erase - _Insert_Return_Type - insert(const value_type& __v) - { return _M_insert(__v, std::tr1::integral_constant()); } - - iterator - insert(iterator, const value_type& __v) - { return iterator(_Insert_Conv_Type()(this->insert(__v))); } - - const_iterator - insert(const_iterator, const value_type& __v) - { return const_iterator(_Insert_Conv_Type()(this->insert(__v))); } - - template - void - insert(_InputIterator __first, _InputIterator __last); - - iterator - erase(iterator); - - const_iterator - erase(const_iterator); - - size_type - erase(const key_type&); - - iterator - erase(iterator, iterator); - - const_iterator - erase(const_iterator, const_iterator); - - void - clear(); - - // Set number of buckets to be appropriate for container of n element. - void rehash(size_type __n); - - private: - // Unconditionally change size of bucket array to n. - void _M_rehash(size_type __n); - }; - - - // Definitions of class template _Hashtable's out-of-line member functions. - template - typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, - __chc, __cit, __uk>::_Node* - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - _M_allocate_node(const value_type& __v) - { - _Node* __n = _M_node_allocator.allocate(1); - __try - { - _M_get_Value_allocator().construct(&__n->_M_v, __v); - __n->_M_next = 0; - return __n; - } - __catch(...) - { - _M_node_allocator.deallocate(__n, 1); - __throw_exception_again; - } - } - - template - void - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - _M_deallocate_node(_Node* __n) - { - _M_get_Value_allocator().destroy(&__n->_M_v); - _M_node_allocator.deallocate(__n, 1); - } - - template - void - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - _M_deallocate_nodes(_Node** __array, size_type __n) - { - for (size_type __i = 0; __i < __n; ++__i) - { - _Node* __p = __array[__i]; - while (__p) - { - _Node* __tmp = __p; - __p = __p->_M_next; - _M_deallocate_node(__tmp); - } - __array[__i] = 0; - } - } - - template - typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, - __chc, __cit, __uk>::_Node** - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - _M_allocate_buckets(size_type __n) - { - _Bucket_allocator_type __alloc(_M_node_allocator); - - // We allocate one extra bucket to hold a sentinel, an arbitrary - // non-null pointer. Iterator increment relies on this. - _Node** __p = __alloc.allocate(__n + 1); - std::fill(__p, __p + __n, (_Node*) 0); - __p[__n] = reinterpret_cast<_Node*>(0x1000); - return __p; - } - - template - void - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - _M_deallocate_buckets(_Node** __p, size_type __n) - { - _Bucket_allocator_type __alloc(_M_node_allocator); - __alloc.deallocate(__p, __n + 1); - } - - template - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - _Hashtable(size_type __bucket_hint, - const _H1& __h1, const _H2& __h2, const _Hash& __h, - const _Equal& __eq, const _ExtractKey& __exk, - const allocator_type& __a) - : __detail::_Rehash_base<_RehashPolicy, _Hashtable>(), - __detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Equal, - _H1, _H2, _Hash, __chc>(__exk, __eq, - __h1, __h2, __h), - __detail::_Map_base<_Key, _Value, _ExtractKey, __uk, _Hashtable>(), - _M_node_allocator(__a), - _M_bucket_count(0), - _M_element_count(0), - _M_rehash_policy() - { - _M_bucket_count = _M_rehash_policy._M_next_bkt(__bucket_hint); - _M_buckets = _M_allocate_buckets(_M_bucket_count); - } - - template - template - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - _Hashtable(_InputIterator __f, _InputIterator __l, - size_type __bucket_hint, - const _H1& __h1, const _H2& __h2, const _Hash& __h, - const _Equal& __eq, const _ExtractKey& __exk, - const allocator_type& __a) - : __detail::_Rehash_base<_RehashPolicy, _Hashtable>(), - __detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Equal, - _H1, _H2, _Hash, __chc>(__exk, __eq, - __h1, __h2, __h), - __detail::_Map_base<_Key, _Value, _ExtractKey, __uk, _Hashtable>(), - _M_node_allocator(__a), - _M_bucket_count(0), - _M_element_count(0), - _M_rehash_policy() - { - _M_bucket_count = std::max(_M_rehash_policy._M_next_bkt(__bucket_hint), - _M_rehash_policy. - _M_bkt_for_elements(__detail:: - __distance_fw(__f, - __l))); - _M_buckets = _M_allocate_buckets(_M_bucket_count); - __try - { - for (; __f != __l; ++__f) - this->insert(*__f); - } - __catch(...) - { - clear(); - _M_deallocate_buckets(_M_buckets, _M_bucket_count); - __throw_exception_again; - } - } - - template - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - _Hashtable(const _Hashtable& __ht) - : __detail::_Rehash_base<_RehashPolicy, _Hashtable>(__ht), - __detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Equal, - _H1, _H2, _Hash, __chc>(__ht), - __detail::_Map_base<_Key, _Value, _ExtractKey, __uk, _Hashtable>(__ht), - _M_node_allocator(__ht._M_node_allocator), - _M_bucket_count(__ht._M_bucket_count), - _M_element_count(__ht._M_element_count), - _M_rehash_policy(__ht._M_rehash_policy) - { - _M_buckets = _M_allocate_buckets(_M_bucket_count); - __try - { - for (size_type __i = 0; __i < __ht._M_bucket_count; ++__i) - { - _Node* __n = __ht._M_buckets[__i]; - _Node** __tail = _M_buckets + __i; - while (__n) - { - *__tail = _M_allocate_node(__n->_M_v); - this->_M_copy_code(*__tail, __n); - __tail = &((*__tail)->_M_next); - __n = __n->_M_next; - } - } - } - __catch(...) - { - clear(); - _M_deallocate_buckets(_M_buckets, _M_bucket_count); - __throw_exception_again; - } - } - - template - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>& - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - operator=(const _Hashtable& __ht) - { - _Hashtable __tmp(__ht); - this->swap(__tmp); - return *this; - } - - template - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - ~_Hashtable() - { - clear(); - _M_deallocate_buckets(_M_buckets, _M_bucket_count); - } - - template - void - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - swap(_Hashtable& __x) - { - // The only base class with member variables is hash_code_base. We - // define _Hash_code_base::_M_swap because different specializations - // have different members. - __detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Equal, - _H1, _H2, _Hash, __chc>::_M_swap(__x); - - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 431. Swapping containers with unequal allocators. - std::__alloc_swap<_Node_allocator_type>::_S_do_it(_M_node_allocator, - __x._M_node_allocator); - - std::swap(_M_rehash_policy, __x._M_rehash_policy); - std::swap(_M_buckets, __x._M_buckets); - std::swap(_M_bucket_count, __x._M_bucket_count); - std::swap(_M_element_count, __x._M_element_count); - } - - template - void - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - __rehash_policy(const _RehashPolicy& __pol) - { - _M_rehash_policy = __pol; - size_type __n_bkt = __pol._M_bkt_for_elements(_M_element_count); - if (__n_bkt > _M_bucket_count) - _M_rehash(__n_bkt); - } - - template - typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, - __chc, __cit, __uk>::iterator - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - find(const key_type& __k) - { - typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); - std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); - _Node* __p = _M_find_node(_M_buckets[__n], __k, __code); - return __p ? iterator(__p, _M_buckets + __n) : this->end(); - } - - template - typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, - __chc, __cit, __uk>::const_iterator - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - find(const key_type& __k) const - { - typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); - std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); - _Node* __p = _M_find_node(_M_buckets[__n], __k, __code); - return __p ? const_iterator(__p, _M_buckets + __n) : this->end(); - } - - template - typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, - __chc, __cit, __uk>::size_type - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - count(const key_type& __k) const - { - typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); - std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); - std::size_t __result = 0; - for (_Node* __p = _M_buckets[__n]; __p; __p = __p->_M_next) - if (this->_M_compare(__k, __code, __p)) - ++__result; - return __result; - } - - template - std::pair::iterator, - typename _Hashtable<_Key, _Value, _Allocator, - _ExtractKey, _Equal, _H1, - _H2, _Hash, _RehashPolicy, - __chc, __cit, __uk>::iterator> - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - equal_range(const key_type& __k) - { - typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); - std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); - _Node** __head = _M_buckets + __n; - _Node* __p = _M_find_node(*__head, __k, __code); - - if (__p) - { - _Node* __p1 = __p->_M_next; - for (; __p1; __p1 = __p1->_M_next) - if (!this->_M_compare(__k, __code, __p1)) - break; - - iterator __first(__p, __head); - iterator __last(__p1, __head); - if (!__p1) - __last._M_incr_bucket(); - return std::make_pair(__first, __last); - } - else - return std::make_pair(this->end(), this->end()); - } - - template - std::pair::const_iterator, - typename _Hashtable<_Key, _Value, _Allocator, - _ExtractKey, _Equal, _H1, - _H2, _Hash, _RehashPolicy, - __chc, __cit, __uk>::const_iterator> - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - equal_range(const key_type& __k) const - { - typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); - std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); - _Node** __head = _M_buckets + __n; - _Node* __p = _M_find_node(*__head, __k, __code); - - if (__p) - { - _Node* __p1 = __p->_M_next; - for (; __p1; __p1 = __p1->_M_next) - if (!this->_M_compare(__k, __code, __p1)) - break; - - const_iterator __first(__p, __head); - const_iterator __last(__p1, __head); - if (!__p1) - __last._M_incr_bucket(); - return std::make_pair(__first, __last); - } - else - return std::make_pair(this->end(), this->end()); - } - - // Find the node whose key compares equal to k, beginning the search - // at p (usually the head of a bucket). Return nil if no node is found. - template - typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, - _Equal, _H1, _H2, _Hash, _RehashPolicy, - __chc, __cit, __uk>::_Node* - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - _M_find_node(_Node* __p, const key_type& __k, - typename _Hashtable::_Hash_code_type __code) const - { - for (; __p; __p = __p->_M_next) - if (this->_M_compare(__k, __code, __p)) - return __p; - return false; - } - - // Insert v in bucket n (assumes no element with its key already present). - template - typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, - __chc, __cit, __uk>::iterator - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - _M_insert_bucket(const value_type& __v, size_type __n, - typename _Hashtable::_Hash_code_type __code) - { - std::pair __do_rehash - = _M_rehash_policy._M_need_rehash(_M_bucket_count, - _M_element_count, 1); - - // Allocate the new node before doing the rehash so that we don't - // do a rehash if the allocation throws. - _Node* __new_node = _M_allocate_node(__v); - - __try - { - if (__do_rehash.first) - { - const key_type& __k = this->_M_extract(__v); - __n = this->_M_bucket_index(__k, __code, __do_rehash.second); - _M_rehash(__do_rehash.second); - } - - __new_node->_M_next = _M_buckets[__n]; - this->_M_store_code(__new_node, __code); - _M_buckets[__n] = __new_node; - ++_M_element_count; - return iterator(__new_node, _M_buckets + __n); - } - __catch(...) - { - _M_deallocate_node(__new_node); - __throw_exception_again; - } - } - - // Insert v if no element with its key is already present. - template - std::pair::iterator, bool> - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - _M_insert(const value_type& __v, std::tr1::true_type) - { - const key_type& __k = this->_M_extract(__v); - typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); - size_type __n = this->_M_bucket_index(__k, __code, _M_bucket_count); - - if (_Node* __p = _M_find_node(_M_buckets[__n], __k, __code)) - return std::make_pair(iterator(__p, _M_buckets + __n), false); - return std::make_pair(_M_insert_bucket(__v, __n, __code), true); - } - - // Insert v unconditionally. - template - typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, - __chc, __cit, __uk>::iterator - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - _M_insert(const value_type& __v, std::tr1::false_type) - { - std::pair __do_rehash - = _M_rehash_policy._M_need_rehash(_M_bucket_count, - _M_element_count, 1); - if (__do_rehash.first) - _M_rehash(__do_rehash.second); - - const key_type& __k = this->_M_extract(__v); - typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); - size_type __n = this->_M_bucket_index(__k, __code, _M_bucket_count); - - // First find the node, avoid leaking new_node if compare throws. - _Node* __prev = _M_find_node(_M_buckets[__n], __k, __code); - _Node* __new_node = _M_allocate_node(__v); - - if (__prev) - { - __new_node->_M_next = __prev->_M_next; - __prev->_M_next = __new_node; - } - else - { - __new_node->_M_next = _M_buckets[__n]; - _M_buckets[__n] = __new_node; - } - this->_M_store_code(__new_node, __code); - - ++_M_element_count; - return iterator(__new_node, _M_buckets + __n); - } - - // For erase(iterator) and erase(const_iterator). - template - void - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - _M_erase_node(_Node* __p, _Node** __b) - { - _Node* __cur = *__b; - if (__cur == __p) - *__b = __cur->_M_next; - else - { - _Node* __next = __cur->_M_next; - while (__next != __p) - { - __cur = __next; - __next = __cur->_M_next; - } - __cur->_M_next = __next->_M_next; - } - - _M_deallocate_node(__p); - --_M_element_count; - } - - template - template - void - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - insert(_InputIterator __first, _InputIterator __last) - { - size_type __n_elt = __detail::__distance_fw(__first, __last); - std::pair __do_rehash - = _M_rehash_policy._M_need_rehash(_M_bucket_count, - _M_element_count, __n_elt); - if (__do_rehash.first) - _M_rehash(__do_rehash.second); - - for (; __first != __last; ++__first) - this->insert(*__first); - } - - template - typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, - __chc, __cit, __uk>::iterator - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - erase(iterator __it) - { - iterator __result = __it; - ++__result; - _M_erase_node(__it._M_cur_node, __it._M_cur_bucket); - return __result; - } - - template - typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, - __chc, __cit, __uk>::const_iterator - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - erase(const_iterator __it) - { - const_iterator __result = __it; - ++__result; - _M_erase_node(__it._M_cur_node, __it._M_cur_bucket); - return __result; - } - - template - typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, - __chc, __cit, __uk>::size_type - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - erase(const key_type& __k) - { - typename _Hashtable::_Hash_code_type __code = this->_M_hash_code(__k); - std::size_t __n = this->_M_bucket_index(__k, __code, _M_bucket_count); - size_type __result = 0; - - _Node** __slot = _M_buckets + __n; - while (*__slot && !this->_M_compare(__k, __code, *__slot)) - __slot = &((*__slot)->_M_next); - - _Node** __saved_slot = 0; - while (*__slot && this->_M_compare(__k, __code, *__slot)) - { - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 526. Is it undefined if a function in the standard changes - // in parameters? - if (&this->_M_extract((*__slot)->_M_v) != &__k) - { - _Node* __p = *__slot; - *__slot = __p->_M_next; - _M_deallocate_node(__p); - --_M_element_count; - ++__result; - } - else - { - __saved_slot = __slot; - __slot = &((*__slot)->_M_next); - } - } - - if (__saved_slot) - { - _Node* __p = *__saved_slot; - *__saved_slot = __p->_M_next; - _M_deallocate_node(__p); - --_M_element_count; - ++__result; - } - - return __result; - } - - // ??? This could be optimized by taking advantage of the bucket - // structure, but it's not clear that it's worth doing. It probably - // wouldn't even be an optimization unless the load factor is large. - template - typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, - __chc, __cit, __uk>::iterator - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - erase(iterator __first, iterator __last) - { - while (__first != __last) - __first = this->erase(__first); - return __last; - } - - template - typename _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, - __chc, __cit, __uk>::const_iterator - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - erase(const_iterator __first, const_iterator __last) - { - while (__first != __last) - __first = this->erase(__first); - return __last; - } - - template - void - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - clear() - { - _M_deallocate_nodes(_M_buckets, _M_bucket_count); - _M_element_count = 0; - } - - template - void - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - rehash(size_type __n) - { - _M_rehash(std::max(_M_rehash_policy._M_next_bkt(__n), - _M_rehash_policy._M_bkt_for_elements(_M_element_count - + 1))); - } - - template - void - _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, - _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: - _M_rehash(size_type __n) - { - _Node** __new_array = _M_allocate_buckets(__n); - __try - { - for (size_type __i = 0; __i < _M_bucket_count; ++__i) - while (_Node* __p = _M_buckets[__i]) - { - std::size_t __new_index = this->_M_bucket_index(__p, __n); - _M_buckets[__i] = __p->_M_next; - __p->_M_next = __new_array[__new_index]; - __new_array[__new_index] = __p; - } - _M_deallocate_buckets(_M_buckets, _M_bucket_count); - _M_bucket_count = __n; - _M_buckets = __new_array; - } - __catch(...) - { - // A failure here means that a hash function threw an exception. - // We can't restore the previous state without calling the hash - // function again, so the only sensible recovery is to delete - // everything. - _M_deallocate_nodes(__new_array, __n); - _M_deallocate_buckets(__new_array, __n); - _M_deallocate_nodes(_M_buckets, _M_bucket_count); - _M_element_count = 0; - __throw_exception_again; - } - } -} -} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc index bf49aa6b080..e5a10738e95 100644 --- a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc @@ -1,7 +1,7 @@ // { dg-do compile } // { dg-options "-std=gnu++0x" } -// Copyright (C) 2008, 2009 Free Software Foundation +// Copyright (C) 2008, 2009, 2010 Free Software Foundation // // 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 @@ -49,13 +49,13 @@ test03() std::unique_ptr p2 = p1; } -// { dg-error "deleted function" "" { target *-*-* } 358 } +// { dg-error "deleted function" "" { target *-*-* } 354 } // { dg-error "used here" "" { target *-*-* } 42 } // { dg-error "no matching" "" { target *-*-* } 48 } -// { dg-warning "candidates are" "" { target *-*-* } 119 } -// { dg-warning "note" "" { target *-*-* } 112 } -// { dg-warning "note" "" { target *-*-* } 107 } -// { dg-warning "note" "" { target *-*-* } 102 } -// { dg-warning "note" "" { target *-*-* } 96 } -// { dg-error "deleted function" "" { target *-*-* } 213 } +// { dg-warning "candidates are" "" { target *-*-* } 115 } +// { dg-warning "note" "" { target *-*-* } 108 } +// { dg-warning "note" "" { target *-*-* } 103 } +// { dg-warning "note" "" { target *-*-* } 98 } +// { dg-warning "note" "" { target *-*-* } 92 } +// { dg-error "deleted function" "" { target *-*-* } 209 } // { dg-error "used here" "" { target *-*-* } 49 } diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc index ae3d3946338..d4c2b3a6d8a 100644 --- a/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc @@ -1,7 +1,7 @@ // { dg-do compile } // { dg-options "-std=gnu++0x" } -// Copyright (C) 2008, 2009 Free Software Foundation +// Copyright (C) 2008, 2009, 2010 Free Software Foundation // // 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 @@ -36,4 +36,4 @@ void test01() } // { dg-error "used here" "" { target *-*-* } 35 } -// { dg-error "deleted function" "" { target *-*-* } 348 } +// { dg-error "deleted function" "" { target *-*-* } 344 } diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc index 5351a5b0788..f4bc4cbc9e8 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc @@ -1,6 +1,6 @@ // { dg-do compile } // { dg-options "-std=gnu++0x" } -// { dg-error "no matching" "" { target *-*-* } 1201 } +// { dg-error "no matching" "" { target *-*-* } 1197 } // { dg-excess-errors "" } // Copyright (C) 2009, 2010 Free Software Foundation diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc index b624ab2356f..8a591dbbb17 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc @@ -1,6 +1,6 @@ // { dg-do compile } // { dg-options "-std=gnu++0x" } -// { dg-error "no matching" "" { target *-*-* } 1201 } +// { dg-error "no matching" "" { target *-*-* } 1197 } // { dg-excess-errors "" } // Copyright (C) 2009, 2010 Free Software Foundation diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc index 0a593c83a91..9db92f2c64b 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc @@ -1,6 +1,6 @@ // { dg-do compile } // { dg-options "-std=gnu++0x" } -// { dg-error "no matching" "" { target *-*-* } 1201 } +// { dg-error "no matching" "" { target *-*-* } 1197 } // { dg-excess-errors "" } // Copyright (C) 2009, 2010 Free Software Foundation diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc index 4739ce77f75..804f10b5c60 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc @@ -1,6 +1,6 @@ // { dg-do compile } // { dg-options "-std=gnu++0x" } -// { dg-error "no matching" "" { target *-*-* } 1201 } +// { dg-error "no matching" "" { target *-*-* } 1197 } // { dg-excess-errors "" } // Copyright (C) 2009, 2010 Free Software Foundation diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc index 8769fa6ee9f..380540a20a7 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc @@ -1,7 +1,7 @@ // { dg-options "-std=gnu++0x" } // { dg-do compile } -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010 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 @@ -29,19 +29,19 @@ int main() } // { dg-error "used here" "" { target *-*-* } 521 } -// { dg-error "deleted function" "" { target *-*-* } 231 } -// { dg-error "deleted function" "" { target *-*-* } 249 } -// { dg-error "deleted function" "" { target *-*-* } 267 } -// { dg-error "deleted function" "" { target *-*-* } 285 } -// { dg-error "deleted function" "" { target *-*-* } 303 } -// { dg-error "deleted function" "" { target *-*-* } 321 } -// { dg-error "deleted function" "" { target *-*-* } 339 } -// { dg-error "deleted function" "" { target *-*-* } 357 } -// { dg-error "deleted function" "" { target *-*-* } 375 } -// { dg-error "deleted function" "" { target *-*-* } 393 } -// { dg-error "deleted function" "" { target *-*-* } 411 } -// { dg-error "deleted function" "" { target *-*-* } 429 } -// { dg-error "deleted function" "" { target *-*-* } 447 } -// { dg-error "deleted function" "" { target *-*-* } 465 } -// { dg-error "deleted function" "" { target *-*-* } 483 } +// { dg-error "deleted function" "" { target *-*-* } 230 } +// { dg-error "deleted function" "" { target *-*-* } 248 } +// { dg-error "deleted function" "" { target *-*-* } 266 } +// { dg-error "deleted function" "" { target *-*-* } 284 } +// { dg-error "deleted function" "" { target *-*-* } 302 } +// { dg-error "deleted function" "" { target *-*-* } 320 } +// { dg-error "deleted function" "" { target *-*-* } 338 } +// { dg-error "deleted function" "" { target *-*-* } 356 } +// { dg-error "deleted function" "" { target *-*-* } 374 } +// { dg-error "deleted function" "" { target *-*-* } 392 } +// { dg-error "deleted function" "" { target *-*-* } 410 } +// { dg-error "deleted function" "" { target *-*-* } 428 } +// { dg-error "deleted function" "" { target *-*-* } 446 } +// { dg-error "deleted function" "" { target *-*-* } 464 } +// { dg-error "deleted function" "" { target *-*-* } 482 } // { dg-excess-errors "In member function" } diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc index 7f7cfd0e65b..21f77f4c21b 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc @@ -1,7 +1,7 @@ // { dg-options "-std=gnu++0x" } // { dg-do compile } -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010 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 @@ -29,19 +29,19 @@ int main() } // { dg-error "used here" "" { target *-*-* } 560 } -// { dg-error "deleted function" "" { target *-*-* } 248 } -// { dg-error "deleted function" "" { target *-*-* } 266 } -// { dg-error "deleted function" "" { target *-*-* } 284 } -// { dg-error "deleted function" "" { target *-*-* } 302 } -// { dg-error "deleted function" "" { target *-*-* } 320 } -// { dg-error "deleted function" "" { target *-*-* } 338 } -// { dg-error "deleted function" "" { target *-*-* } 356 } -// { dg-error "deleted function" "" { target *-*-* } 374 } -// { dg-error "deleted function" "" { target *-*-* } 230 } -// { dg-error "deleted function" "" { target *-*-* } 410 } -// { dg-error "deleted function" "" { target *-*-* } 428 } -// { dg-error "deleted function" "" { target *-*-* } 446 } -// { dg-error "deleted function" "" { target *-*-* } 464 } -// { dg-error "deleted function" "" { target *-*-* } 482 } -// { dg-error "deleted function" "" { target *-*-* } 392 } +// { dg-error "deleted function" "" { target *-*-* } 229 } +// { dg-error "deleted function" "" { target *-*-* } 247 } +// { dg-error "deleted function" "" { target *-*-* } 265 } +// { dg-error "deleted function" "" { target *-*-* } 283 } +// { dg-error "deleted function" "" { target *-*-* } 301 } +// { dg-error "deleted function" "" { target *-*-* } 319 } +// { dg-error "deleted function" "" { target *-*-* } 337 } +// { dg-error "deleted function" "" { target *-*-* } 355 } +// { dg-error "deleted function" "" { target *-*-* } 373 } +// { dg-error "deleted function" "" { target *-*-* } 391 } +// { dg-error "deleted function" "" { target *-*-* } 409 } +// { dg-error "deleted function" "" { target *-*-* } 427 } +// { dg-error "deleted function" "" { target *-*-* } 445 } +// { dg-error "deleted function" "" { target *-*-* } 463 } +// { dg-error "deleted function" "" { target *-*-* } 481 } // { dg-excess-errors "In member function" }