diff options
Diffstat (limited to 'libstdc++-v3')
95 files changed, 4353 insertions, 354 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 2d969f12795..4230bc6a129 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,298 @@ +2008-10-27 Paolo Carlini <paolo.carlini@oracle.com> + + PR libstdc++/37919 + Revert: + 2008-10-18 Douglas Gregor <doug.gregor@gmail.com> + + * include/bits/stl_pair.h (__may_be_null_pointer_init): New. + (pair::pair): Eliminate the redundant pair(U1&&, U2&&) constructor. + Add lvalue pair<U1, U2> constructor to handle non-const pair lvalues. + Remove the old variadic constructor, and instead provide several + variadic constructors that avoid failing when attempting to + initialize a pointer from a null pointer constant. + * testsuite/20_util/pair/moveable.cc (test3): Add new tests with + initialization of pointers from the null pointer constant. + +2008-10-27 Paolo Carlini <paolo.carlini@oracle.com> + + PR libstdc++/37522 + * config/os/mingw32/os_defines.h: Define _GLIBCXX_HAVE_BROKEN_VSWPRINTF + * include/bits/basic_string.h: Guard string conversions with + !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF) too. + * testsuite/lib/libstdc++.exp (check_v3_target_string_conversions): + New. + * testsuite/lib/dg-options.exp (dg-require-string-conversions): New. + * testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc: + Use the latter. + * testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc: + Likewise. + * testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc: + Likewise. + * testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc: + Likewise. + * testsuite/21_strings/basic_string/numeric_conversions/char/ + stoull.cc: Likewise. + * testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc: + Likewise. + * testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc: + Likewise. + * testsuite/21_strings/basic_string/numeric_conversions/char/ + to_string.cc: Likewise. + * testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc: + Likewise. + +2008-10-24 Paolo Carlini <paolo.carlini@oracle.com> + + * config/os/generic/error_constants.h (enum errc): Remove + no_posix_equivalent. + * config/os/mingw32/error_constants.h (enum errc): Likewise. + * testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc: + Adjust. + +2008-10-24 Jakub Jelinek <jakub@redhat.com> + + * testsuite/Makefile.am (AUTOMAKE_OPTIONS): Remove dejagnu. + (RUNTESTDEFAULTFLAGS, EXPECT, check_DEJAGNU_normal_targets): New + variables. + (%/site.exp, check-DEJAGNU%): New targets. + (check-am): Run $(MAKE) check-DEJAGNU. + * testsuite/Makefile.in: Regenerated. + +2008-10-23 Chris Fairles <cfairles@gcc.gnu.org> + + * config/os/generic/error_constants.h (errc): Use long type. + * config/os/mingw32/error_constants.h (errc): Likewise. + +2008-10-22 Chris Fairles <cfairles@gcc.gnu.org> + + * include/std/system_error (is_error_code_enum): Specialize for errc. + (error_category::error_category): Defaulted and protected. + (error_category::~error_category): New, virtual. + (error_category::error_category(const error_category&), + error_category::operator=(const error_category&)): Deleted. + (get_system_category, get_posix_category): Remove (DR 890). + (system_category): External linkage (DR 890). + (posix_category): Remove. + (generic_category): Add. External linkage (DR 890). + (error_code::error_code<>(_ErrorCodeEnum)): Use generic_category. + (error_code::clear, error_code::operator=<>(_ErrorCodeEnum)): Forward to + error_code::assign, use generic_category. + (error_condition::error_condition, + error_condition::error_condition<>(_ErrorConditionEnum)): Use + generic_category. + (error_condition::clear, + error_condition::operator=<>(_ErrorConditionEnum)): Forward to + error_code::assign, use generic_category. + (make_error_code, make_error_condition): Define in namespace std. + * include/std/mutex (unique_lock<>::lock, unique_lock<>::try_lock, + unique_lock<>::try_lock_until<>(duration), + unique_lock<>::try_lock_for<>(duration)): Replace posix_error with errc. + * src/system_error.cc (system_error_category, generic_error_category): + New. + (gnu_error_category): Remove. + (get_system_category, get_posix_category): Remove (DR 890). + (system_category, generic_category): Define. + * src/functexcept.cc (__throw_system_error): Use generic_category. + * config/abi/pre/gnu.ver: Export system_category and generic_category, + remove get_system_category and get_generic_category (DR 890). + * config/os/generic/error_constants.h (posix_errno): Rename to errc, use + enum class type. Fix spelling. + * config/os/mingw32/error_constants.h (posix_errno): Likewise. + * testsuite/19_diagnostics/error_code/cons/1.cc: Use errc and + generic_category. + * testsuite/19_diagnostics/error_code/operators/bool.cc: Use errc. + * testsuite/19_diagnostics/error_code/operators/equal.cc: Likewise. + * testsuite/19_diagnostics/error_code/operators/not_equal.cc: Likewise. + * testsuite/19_diagnostics/error_category/cons/copy_neg.cc: Update + dg-error line numbers. + * testsuite/19_diagnostics/error_condition/cons/1.cc: Use + generic_category. + * testsuite/19_diagnostics/error_condition/operators/bool.cc: Use errc. + * testsuite/19_diagnostics/error_condition/operators/equal.cc: Likewise. + * testsuite/19_diagnostics/error_condition/operators/not_equal.cc: + Likewise. + * testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc: New. + * testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc: + Remove using tests since errc is not a namespace. + * testsuite/19_diagnostics/system_error/cons-1.cc: Use errc. + * testsuite/19_diagnostics/system_error/what-4.cc: Likewise. + * testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc: + Likewise. + * testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc: + Likewise. + * testsuite/30_threads/unique_lock/locking/2.cc: Likewise. + +2008-10-20 Paolo Carlini <paolo.carlini@oracle.com> + + * include/tr1_impl/hashtable_policy.h (_Hash_node<>::_Hash_node<> + (_Args&&...)): Add in C++0x mode. + * include/tr1_impl/hashtable (_Hashtable<>::_M_allocate_node, + _Hashtable<>::_M_deallocate_node): Use _M_get_Node_allocator in + C++0x mode. + + * include/tr1_impl/hashtable (_Hashtable<>::max_size): Use + Node_allocator for improved accuracy. + * testsuite/tr1/6_containers/unordered_multimap/capacity/ + 29134-multimap.cc: Adjust. + * testsuite/tr1/6_containers/unordered_multimap/capacity/ + 29134-map.cc: Likewise. + * testsuite/tr1/6_containers/unordered_multimap/capacity/ + 29134-multiset.cc: Adjust. + * testsuite/tr1/6_containers/unordered_multimap/capacity/ + 29134-set.cc: Likewise. + +2008-10-19 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/stl_tree.h (_Rb_tree_node<>::_Rb_tree_node<> + (_Args&&...)): Add in C++0x mode. + (_Rb_tree<>::_M_create_node<>(_Args&&...)): Add in C++0x mode, + use _M_get_Node_allocator. + (_Rb_tree<>::_M_destroy_node(_Link_type): Use _M_get_Node_allocator + in C++0x mode. + * testsuite/23_containers/set/operators/1_neg.cc: Adjust dg-error + line numbers. + * testsuite/23_containers/map/operators/1_neg.cc: Likewise. + +2008-10-18 Douglas Gregor <doug.gregor@gmail.com> + + * include/bits/stl_pair.h (__may_be_null_pointer_init): New. + (pair::pair): Eliminate the redundant pair(U1&&, U2&&) constructor. + Add lvalue pair<U1, U2> constructor to handle non-const pair lvalues. + Remove the old variadic constructor, and instead provide several + variadic constructors that avoid failing when attempting to + initialize a pointer from a null pointer constant. + * testsuite/20_util/pair/moveable.cc (test3): Add new tests with + initialization of pointers from the null pointer constant. + +2008-10-17 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/forward_list.tcc (forward_list<>:: + _M_initialize_dispatch(_InputIterator, _InputIterator, __false_type)): + Simplify. + +2008-10-17 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/forward_list.h (forward_list<>:: + forward_list(size_type)): Tweak, use _Base default constructor. + +2008-10-17 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/forward_list.h (forward_list<>::insert_after): Minor + cosmetic changes. + +2008-10-16 Edward Smith-Rowland <3dw4rd@verizon.net> + + * include/bits/forward_list.h: Factor list construction to dispatch + routines. + * include/bits/forward_list.tcc: Likewise. + * testsuite/23_containers/forward_list/modifiers/2.cc: + +2008-10-16 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/forward_list.tcc (operator==): Use auto. + +2008-10-16 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/forward_list.h (_Fwd_list_base<>::_M_insert_after): + Move out of line, tweak to return _Fwd_list_node_base*. + (forward_list<>::insert_after(const_iterator, const _Tp&), + forward_list<>::insert_after(const_iterator, _Tp&&)): Use it. + * include/bits/forward_list.tcc (_Fwd_list_base<>::_M_insert_after): + Define. + + * include/bits/forward_list.h (forward_list<>): Consistently qualify + calls of base class functions with this->. + * include/bits/forward_list.tcc (forward_list<>): Likewise. + + * include/bits/forward_list.h: Move some functions out of line... + * include/bits/forward_list.tcc: ... here. + + * include/bits/forward_list.h (forward_list<>::resize(size_type)): Fix. + +2008-10-15 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/forward_list.h: Remove pointless const qualifiers in + const_casts. + * include/bits/forward_list.tcc: Likewise. + + * include/bits/forward_list.h (forward_list<>::pointer, + const_pointer, reference, const_reference): Fix, use _Tp_alloc_type. + * testsuite/23_containers/forward_list/requirements/ + explicit_instantiation/1.cc: New. + * testsuite/23_containers/forward_list/requirements/ + explicit_instantiation/1.cc: Likewise. + +2008-10-15 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/forward_list.h (forward_list<>::max_size): Use + Node_allocator; minor cosmetic changes. + * testsuite/23_containers/forward_list/capacity/1.cc: Adjust. + +2008-10-15 Edward Smith-Rowland <3dw4rd@verizon.net> + + * include/std/forward_list: New. + * include/bits/forward_list.h: Likewise. + * include/bits/forward_list.tcc: Likewise. + * include/precompiled/stdc++.h: Modified to include forward_list. + * include/Makefile.am: Add forward_list, forward_list.h, and + forward_list.tcc. + * include/Makefile.in: Regenerate. + * testsuite/23_containers/forward_list/modifiers/1.cc: New. + * testsuite/23_containers/forward_list/modifiers/2.cc: Likewise. + * testsuite/23_containers/forward_list/modifiers/3.cc: Likewise. + * testsuite/23_containers/forward_list/modifiers/4.cc: Likewise. + * testsuite/23_containers/forward_list/modifiers/5.cc: Likewise. + * testsuite/23_containers/forward_list/cons/1.cc: Likewise. + * testsuite/23_containers/forward_list/cons/2.cc: Likewise. + * testsuite/23_containers/forward_list/cons/3.cc: Likewise. + * testsuite/23_containers/forward_list/cons/4.cc: Likewise. + * testsuite/23_containers/forward_list/cons/5.cc: Likewise. + * testsuite/23_containers/forward_list/cons/6.cc: Likewise. + * testsuite/23_containers/forward_list/cons/7.cc: Likewise. + * testsuite/23_containers/forward_list/cons/8.cc: Likewise. + * testsuite/23_containers/forward_list/cons/9.cc: Likewise. + * testsuite/23_containers/forward_list/requirements/1.cc: Likewise. + * testsuite/23_containers/forward_list/operations/1.cc: Likewise. + * testsuite/23_containers/forward_list/operations/2.cc: Likewise. + * testsuite/23_containers/forward_list/operations/3.cc: Likewise. + * testsuite/23_containers/forward_list/operations/4.cc: Likewise. + * testsuite/23_containers/forward_list/operations/5.cc: Likewise. + * testsuite/23_containers/forward_list/operations/6.cc: Likewise. + * testsuite/23_containers/forward_list/operations/7.cc: Likewise. + * testsuite/23_containers/forward_list/capacity/1.cc: Likewise. + * testsuite/23_containers/forward_list/comparable.cc: Likewise. + * testsuite/23_containers/forward_list/moveable.cc: Likewise. + * testsuite/23_containers/headers/forward_list/synopsis.cc: Likewise. + * testsuite/17_intro/headers/c++200x/all_multiple_inclusion.cc: Update. + * testsuite/17_intro/headers/c++200x/all: Likewise. + +2008-10-14 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/stl_list.h (_List_node<>::_List_node<>(_Args&&...)): + Add in C++0x mode. + (list<>::_M_create_node<>(_Args&&...)): Use _M_get_Node_allocator. + (list<>::_M_erase(iterator): Likewise, in C++0x mode. + * include/bits/list.tcc (_List_base<>::_M_clear): Likewise. + * testsuite/23_containers/list/requirements/dr438/assign_neg.cc: + Adjust dg-error line number. + * testsuite/23_containers/list/requirements/dr438/insert_neg.cc: + Likewise. + * testsuite/23_containers/list/requirements/dr438/ + constructor_1_neg.cc: Likewise. + * testsuite/23_containers/list/requirements/dr438/ + constructor_2_neg.cc: Likewise. + +2008-10-14 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/stl_tree.h (_Rb_tree<>::max_size): Use Node_allocator + for improved accuracy. + * include/bits/stl_list.h (list<>::max_size): Likewise. + * testsuite/23_containers/multimap/capacity/29134.cc: Adjust. + * testsuite/23_containers/set/capacity/29134.cc: Likewise. + * testsuite/23_containers/multiset/capacity/29134.cc: Likewise. + * testsuite/23_containers/list/capacity/29134.cc: Likewise. + * testsuite/23_containers/map/capacity/29134.cc: Likewise. + 2008-10-10 Paolo Carlini <paolo.carlini@oracle.com> * testsuite/20_util/reference_wrapper/24803.cc: Avoid uninitialized diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index 024fcfd4086..04262bae32c 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -922,8 +922,8 @@ GLIBCXX_3.4.11 { _ZNSt6threadD2Ev; # system_error - _ZSt18get_posix_categoryv; - _ZSt19get_system_categoryv; + _ZSt15system_category; + _ZSt16generic_category; _ZNKSt10error_code23default_error_conditionEv; _ZNKSt14error_category23default_error_conditionEi; diff --git a/libstdc++-v3/config/os/generic/error_constants.h b/libstdc++-v3/config/os/generic/error_constants.h index 644d111b70b..73918e5543e 100644 --- a/libstdc++-v3/config/os/generic/error_constants.h +++ b/libstdc++-v3/config/os/generic/error_constants.h @@ -40,9 +40,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) -namespace posix_error -{ - enum posix_errno + enum class errc { address_family_not_supported = EAFNOSUPPORT, address_in_use = EADDRINUSE, @@ -168,16 +166,14 @@ namespace posix_error too_many_files_open_in_system = ENFILE, too_many_files_open = EMFILE, too_many_links = EMLINK, - too_many_synbolic_link_levels = ELOOP, + too_many_symbolic_link_levels = ELOOP, #ifdef _GLIBCXX_HAVE_EOVERFLOW value_too_large = EOVERFLOW, #endif - wrong_protocol_type = EPROTOTYPE, - no_posix_equivalent = 1L << 16 + wrong_protocol_type = EPROTOTYPE }; -} _GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/config/os/mingw32/error_constants.h b/libstdc++-v3/config/os/mingw32/error_constants.h index 27af22225d5..ce34bdeebd8 100644 --- a/libstdc++-v3/config/os/mingw32/error_constants.h +++ b/libstdc++-v3/config/os/mingw32/error_constants.h @@ -1,6 +1,6 @@ // Specific definitions for mingw32 platform -*- C++ -*- -// Copyright (C) 2007 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008 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 @@ -41,10 +41,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std) -namespace posix_error { // Most of the commented-out error codes are socket-related and could be // replaced by Winsock WSA-prefixed equivalents. - enum posix_errno + enum class errc { // address_family_not_supported = EAFNOSUPPORT, // address_in_use = EADDRINUSE, @@ -120,13 +119,11 @@ namespace posix_error { // timed_out = ETIMEDOUT, too_many_files_open_in_system = ENFILE, too_many_files_open = EMFILE, - too_many_links = EMLINK, - // too_many_synbolic_link_levels = ELOOP, + too_many_links = EMLINK + // too_many_symbolic_link_levels = ELOOP, // value_too_large = EOVERFLOW, - // wrong_protocol_type = EPROTOTYPE, - no_posix_equivalent = 1L << 16 + // wrong_protocol_type = EPROTOTYPE }; -} _GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/config/os/mingw32/os_defines.h b/libstdc++-v3/config/os/mingw32/os_defines.h index 3ac8fff5252..017fd8759bd 100644 --- a/libstdc++-v3/config/os/mingw32/os_defines.h +++ b/libstdc++-v3/config/os/mingw32/os_defines.h @@ -1,6 +1,7 @@ // Specific definitions for generic platforms -*- C++ -*- -// Copyright (C) 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +// 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 @@ -52,4 +53,7 @@ // See libstdc++/20806. #define _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM 1 +// See libstdc++/37522. +#define _GLIBCXX_HAVE_BROKEN_VSWPRINTF 1 + #endif diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 82fbe09a561..0d19a45576c 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -36,6 +36,7 @@ std_headers = \ ${std_srcdir}/complex \ ${std_srcdir}/condition_variable \ ${std_srcdir}/deque \ + ${std_srcdir}/forward_list \ ${std_srcdir}/fstream \ ${std_srcdir}/functional \ ${std_srcdir}/iomanip \ @@ -87,6 +88,8 @@ bits_headers = \ ${bits_srcdir}/concept_check.h \ ${bits_srcdir}/cpp_type_traits.h \ ${bits_srcdir}/deque.tcc \ + ${bits_srcdir}/forward_list.h \ + ${bits_srcdir}/forward_list.tcc \ ${bits_srcdir}/fstream.tcc \ ${bits_srcdir}/functexcept.h \ ${bits_srcdir}/functional_hash.h \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index b26375817f0..e17ec3a508f 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -302,6 +302,7 @@ std_headers = \ ${std_srcdir}/complex \ ${std_srcdir}/condition_variable \ ${std_srcdir}/deque \ + ${std_srcdir}/forward_list \ ${std_srcdir}/fstream \ ${std_srcdir}/functional \ ${std_srcdir}/iomanip \ @@ -353,6 +354,8 @@ bits_headers = \ ${bits_srcdir}/concept_check.h \ ${bits_srcdir}/cpp_type_traits.h \ ${bits_srcdir}/deque.tcc \ + ${bits_srcdir}/forward_list.h \ + ${bits_srcdir}/forward_list.tcc \ ${bits_srcdir}/fstream.tcc \ ${bits_srcdir}/functexcept.h \ ${bits_srcdir}/functional_hash.h \ diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index de4cf80234d..595a1560fa6 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -2562,7 +2562,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_END_NAMESPACE -#if (defined(__GXX_EXPERIMENTAL_CXX0X__) && defined(_GLIBCXX_USE_C99)) +#if (defined(__GXX_EXPERIMENTAL_CXX0X__) && defined(_GLIBCXX_USE_C99) \ + && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) #include <ext/string_conversions.h> diff --git a/libstdc++-v3/include/bits/forward_list.h b/libstdc++-v3/include/bits/forward_list.h new file mode 100644 index 00000000000..60b187fb483 --- /dev/null +++ b/libstdc++-v3/include/bits/forward_list.h @@ -0,0 +1,1321 @@ +// <forward_list.h> -*- C++ -*- + +// Copyright (C) 2008 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 2, 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. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02110-1301, USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file forward_list.h + * This is a Standard C++ Library header. + */ + +#ifndef _FORWARD_LIST_H +#define _FORWARD_LIST_H 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#include <memory> +#include <initializer_list> + +_GLIBCXX_BEGIN_NAMESPACE(std) + + /** + * @brief A helper basic node class for @forward_list. + * This is just a linked list with nothing inside it. + * There are purely list shuffling utility methods here. + */ + struct _Fwd_list_node_base + { + _Fwd_list_node_base() : _M_next(0) { } + + _Fwd_list_node_base* _M_next; + + static void + swap(_Fwd_list_node_base& __x, _Fwd_list_node_base& __y) + { std::swap(__x._M_next, __y._M_next); } + + void + _M_transfer_after(_Fwd_list_node_base* __bbegin, + _Fwd_list_node_base* __bend) + { + _Fwd_list_node_base* __keep = __bbegin->_M_next; + if (__bend) + { + __bbegin->_M_next = __bend->_M_next; + __bend->_M_next = this->_M_next; + } + else + __bbegin->_M_next = 0; + this->_M_next = __keep; + } + + void + _M_transfer_after(_Fwd_list_node_base* __bbegin) + { + _Fwd_list_node_base* __bend = __bbegin; + while (__bend && __bend->_M_next) + __bend = __bend->_M_next; + _M_transfer_after(__bbegin, __bend); + } + + void + _M_reverse_after() + { + _Fwd_list_node_base* __tail = this->_M_next; + if (!__tail) + return; + while (_Fwd_list_node_base* __temp = __tail->_M_next) + { + _Fwd_list_node_base* __keep = this->_M_next; + this->_M_next = __temp; + __tail->_M_next = __temp->_M_next; + this->_M_next->_M_next = __keep; + } + } + }; + + /** + * @brief A helper node class for @forward_list. + * This is just a linked list with a data value in each node. + * There is a sorting utility method. + */ + template<typename _Tp> + struct _Fwd_list_node : public _Fwd_list_node_base + { + template<typename... _Args> + _Fwd_list_node(_Args&&... __args) + : _Fwd_list_node_base(), _M_value(std::forward<_Args>(__args)...) { } + + template<typename _Comp> + void + _M_sort_after(_Comp __comp); + + _Tp _M_value; + }; + + /** + * @brief A forward_list::iterator. + * + * All the functions are op overloads. + */ + template<typename _Tp> + struct _Fwd_list_iterator + { + typedef _Fwd_list_iterator<_Tp> _Self; + typedef _Fwd_list_node<_Tp> _Node; + + typedef _Tp value_type; + typedef _Tp* pointer; + typedef _Tp& reference; + typedef ptrdiff_t difference_type; + typedef std::forward_iterator_tag iterator_category; + + _Fwd_list_iterator() : _M_node() { } + + explicit + _Fwd_list_iterator(_Fwd_list_node_base* __n) : _M_node(__n) { } + + reference + operator*() const + { return static_cast<_Node*>(this->_M_node)->_M_value; } + + pointer + operator->() const + { return &static_cast<_Node*>(this->_M_node)->_M_value; } + + _Self& + operator++() + { + this->_M_node = this->_M_node->_M_next; + return *this; + } + + _Self + operator++(int) + { + _Self __tmp(*this); + this->_M_node = this->_M_node->_M_next; + return __tmp; + } + + bool + operator==(const _Self& __x) const + { return this->_M_node == __x._M_node; } + + bool + operator!=(const _Self& __x) const + { return this->_M_node != __x._M_node; } + + const _Self& + _M_next() const + { + if (_M_node) + return _Fwd_list_iterator(this->_M_node->_M_next); + else + return _Fwd_list_iterator(0); + } + + _Fwd_list_node_base* _M_node; + }; + + /** + * @brief A forward_list::const_iterator. + * + * All the functions are op overloads. + */ + template<typename _Tp> + struct _Fwd_list_const_iterator + { + typedef _Fwd_list_const_iterator<_Tp> _Self; + typedef const _Fwd_list_node<_Tp> _Node; + typedef _Fwd_list_iterator<_Tp> iterator; + + typedef _Tp value_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; + typedef ptrdiff_t difference_type; + typedef std::forward_iterator_tag iterator_category; + + _Fwd_list_const_iterator() : _M_node() { } + + explicit + _Fwd_list_const_iterator(const _Fwd_list_node_base* __n) + : _M_node(__n) { } + + _Fwd_list_const_iterator(const iterator& __iter) + : _M_node(__iter._M_node) { } + + reference + operator*() const + { return static_cast<_Node*>(this->_M_node)->_M_value; } + + pointer + operator->() const + { return &static_cast<_Node*>(this->_M_node)->_M_value; } + + _Self& + operator++() + { + this->_M_node = this->_M_node->_M_next; + return *this; + } + + _Self + operator++(int) + { + _Self __tmp(*this); + this->_M_node = this->_M_node->_M_next; + return __tmp; + } + + bool + operator==(const _Self& __x) const + { return this->_M_node == __x._M_node; } + + bool + operator!=(const _Self& __x) const + { return this->_M_node != __x._M_node; } + + const _Self& + _M_next() const + { + if (this->_M_node) + return _Fwd_list_const_iterator(this->_M_node->_M_next); + else + return _Fwd_list_const_iterator(0); + } + + const _Fwd_list_node_base* _M_node; + }; + + /** + * @brief Forward list iterator equality comparison. + */ + template<typename _Tp> + inline bool + operator==(const _Fwd_list_iterator<_Tp>& __x, + const _Fwd_list_const_iterator<_Tp>& __y) + { return __x._M_node == __y._M_node; } + + /** + * @brief Forward list iterator inequality comparison. + */ + template<typename _Tp> + inline bool + operator!=(const _Fwd_list_iterator<_Tp>& __x, + const _Fwd_list_const_iterator<_Tp>& __y) + { return __x._M_node != __y._M_node; } + + /** + * @brief Base class for @forward_list. + */ + template<typename _Tp, typename _Alloc> + struct _Fwd_list_base + { + protected: + typedef typename _Alloc::template rebind<_Fwd_list_node<_Tp>>::other + _Node_alloc_type; + + typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type; + + struct _Fwd_list_impl + : public _Node_alloc_type + { + _Fwd_list_node_base _M_head; + + _Fwd_list_impl() + : _Node_alloc_type(), _M_head() + { } + + _Fwd_list_impl(const _Node_alloc_type& __a) + : _Node_alloc_type(__a), _M_head() + { } + }; + + _Fwd_list_impl _M_impl; + + public: + typedef _Fwd_list_iterator<_Tp> iterator; + typedef _Fwd_list_const_iterator<_Tp> const_iterator; + + typedef _Fwd_list_node<_Tp> _Node; + + _Node_alloc_type& + _M_get_Node_allocator() + { return *static_cast<_Node_alloc_type*>(&this->_M_impl); } + + const _Node_alloc_type& + _M_get_Node_allocator() const + { return *static_cast<const _Node_alloc_type*>(&this->_M_impl); } + + _Fwd_list_base() + : _M_impl() + { this->_M_impl._M_head._M_next = 0; } + + _Fwd_list_base(const _Alloc& __a) + : _M_impl(__a) + { this->_M_impl._M_head._M_next = 0; } + + _Fwd_list_base(const _Fwd_list_base& __lst, const _Alloc& __a); + + _Fwd_list_base(_Fwd_list_base&& __lst, const _Alloc& __a) + : _M_impl(__a) + { _Fwd_list_node_base::swap(this->_M_impl._M_head, + __lst._M_impl._M_head); } + + _Fwd_list_base(_Fwd_list_base&& __lst) + : _M_impl(__lst._M_get_Node_allocator()) + { _Fwd_list_node_base::swap(this->_M_impl._M_head, + __lst._M_impl._M_head); } + + ~_Fwd_list_base() + { _M_erase_after(&_M_impl._M_head, 0); } + + protected: + + _Node* + _M_get_node() + { return _M_get_Node_allocator().allocate(1); } + + template<typename... _Args> + _Node* + _M_create_node(_Args&&... __args) + { + _Node* __node = this->_M_get_node(); + try + { + _M_get_Node_allocator().construct(__node, + std::forward<_Args>(__args)...); + __node->_M_next = 0; + } + catch(...) + { + this->_M_put_node(__node); + __throw_exception_again; + } + return __node; + } + + template<typename... _Args> + _Fwd_list_node_base* + _M_insert_after(const_iterator __pos, _Args&&... __args); + + void + _M_put_node(_Node* __p) + { _M_get_Node_allocator().deallocate(__p, 1); } + + _Fwd_list_node_base* + _M_erase_after(_Fwd_list_node_base* __pos); + + _Fwd_list_node_base* + _M_erase_after(_Fwd_list_node_base* __pos, + _Fwd_list_node_base* __last); + }; + + /** + * @brief A standard container with linear time access to elements, + * and fixed time insertion/deletion at any point in the sequence. + * + * @ingroup Containers + * @ingroup Sequences + * + * Meets the requirements of a <a href="tables.html#65">container</a>, a + * <a href="tables.html#67">sequence</a>, including the + * <a href="tables.html#68">optional sequence requirements</a> with the + * %exception of @c at and @c operator[]. + * + * This is a @e singly @e linked %list. Traversal up the + * %list requires linear time, but adding and removing elements (or + * @e nodes) is done in constant time, regardless of where the + * change takes place. Unlike std::vector and std::deque, + * random-access iterators are not provided, so subscripting ( @c + * [] ) access is not allowed. For algorithms which only need + * sequential access, this lack makes no difference. + * + * Also unlike the other standard containers, std::forward_list provides + * specialized algorithms %unique to linked lists, such as + * splicing, sorting, and in-place reversal. + * + * A couple points on memory allocation for forward_list<Tp>: + * + * First, we never actually allocate a Tp, we allocate + * Fwd_list_node<Tp>'s and trust [20.1.5]/4 to DTRT. This is to ensure + * that after elements from %forward_list<X,Alloc1> are spliced into + * %forward_list<X,Alloc2>, destroying the memory of the second %list is a + * valid operation, i.e., Alloc1 giveth and Alloc2 taketh away. + */ + template<typename _Tp, typename _Alloc = allocator<_Tp> > + class forward_list : private _Fwd_list_base<_Tp, _Alloc> + { + private: + typedef _Fwd_list_base<_Tp, _Alloc> _Base; + typedef _Fwd_list_node<_Tp> _Node; + typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; + + public: + // types: + typedef _Tp value_type; + typedef typename _Tp_alloc_type::pointer pointer; + typedef typename _Tp_alloc_type::const_pointer const_pointer; + typedef typename _Tp_alloc_type::reference reference; + typedef typename _Tp_alloc_type::const_reference const_reference; + typedef _Fwd_list_iterator<_Tp> iterator; + typedef _Fwd_list_const_iterator<_Tp> const_iterator; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef _Alloc allocator_type; + + // 23.2.3.1 construct/copy/destroy: + + /** + * @brief Creates a %forward_list with no elements. + * @param al An allocator object. + */ + explicit + forward_list(const _Alloc& __al = _Alloc()) + : _Base(__al) + { } + + /** + * @brief Copy constructor with allocator argument. + * @param list Input list to copy. + * @param al An allocator object. + */ + forward_list(const forward_list& __list, const _Alloc& __al) + : _Base(__list, __al) + { } + + /** + * @brief Move constructor with allocator argument. + * @param list Input list to move. + * @param al An allocator object. + */ + forward_list(forward_list&& __list, const _Alloc& __al) + : _Base(std::forward<_Base>(__list), __al) + { } + + /** + * @brief Creates a %forward_list with copies of the default element + * type. + * @param n The number of elements to initially create. + * + * This constructor fills the %forward_list with @a n copies of + * the default value. + */ + explicit + forward_list(size_type __n) + : _Base() + { _M_fill_initialize(__n, value_type()); } + + /** + * @brief Creates a %forward_list with copies of an exemplar element. + * @param n The number of elements to initially create. + * @param value An element to copy. + * @param al An allocator object. + * + * This constructor fills the %forward_list with @a n copies of @a + * value. + */ + forward_list(size_type __n, const _Tp& __value, + const _Alloc& __al = _Alloc()) + : _Base(__al) + { _M_fill_initialize(__n, __value); } + + /** + * @brief Builds a %forward_list from a range. + * @param first An input iterator. + * @param last An input iterator. + * @param al An allocator object. + * + * Create a %forward_list consisting of copies of the elements from + * [@a first,@a last). This is linear in N (where N is + * distance(@a first,@a last)). + */ + template<typename _InputIterator> + forward_list(_InputIterator __first, _InputIterator __last, + const _Alloc& __al = _Alloc()) + : _Base(__al) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } + + /** + * @brief The %forward_list copy constructor. + * @param list A %forward_list of identical element and allocator + * types. + * + * The newly-created %forward_list uses a copy of the allocation + * object used by @a list. + */ + forward_list(const forward_list& __list) + : _Base(__list.get_allocator()) + { _M_initialize_dispatch(__list.begin(), __list.end(), __false_type()); } + + /** + * @brief The %forward_list move constructor. + * @param list A %forward_list of identical element and allocator + * types. + * + * The newly-created %forward_list contains the exact contents of @a + * forward_list. The contents of @a list are a valid, but unspecified + * %forward_list. + */ + forward_list(forward_list&& __list) + : _Base(std::forward<_Base>(__list)) { } + + /** + * @brief Builds a %forward_list from an initializer_list + * @param il An initializer_list of value_type. + * @param al An allocator object. + * + * Create a %forward_list consisting of copies of the elements + * in the initializer_list @a il. This is linear in il.size(). + */ + forward_list(std::initializer_list<_Tp> __il, + const _Alloc& __al = _Alloc()) + : _Base(__al) + { _M_initialize_dispatch(__il.begin(), __il.end(), __false_type()); } + + /** + * @brief The forward_list dtor. + */ + ~forward_list() + { _M_erase_after(&this->_M_impl._M_head, 0); } + + /** + * @brief The %forward_list assignment operator. + * @param list A %forward_list of identical element and allocator + * types. + * + * All the elements of @a list are copied, but unlike the copy + * constructor, the allocator object is not copied. + */ + forward_list& + operator=(const forward_list& __list); + + /** + * @brief The %forward_list move assignment operator. + * @param list A %forward_list of identical element and allocator + * types. + * + * The contents of @a list are moved into this %forward_list + * (without copying). @a list is a valid, but unspecified + * %forward_list + */ + forward_list& + operator=(forward_list&& __list) + { + if (&__list != this) + { + this->clear(); + this->swap(__list); + } + return *this; + } + + /** + * @brief The %forward_list initializer list assignment operator. + * @param il An initializer_list of value_type. + * + * Replace the contents of the %forward_list with copies of the + * elements in the initializer_list @a il. This is linear in + * il.size(). + */ + forward_list& + operator=(std::initializer_list<_Tp> __il) + { + assign(__il); + return *this; + } + + /** + * @brief Assigns a range to a %forward_list. + * @param first An input iterator. + * @param last An input iterator. + * + * This function fills a %forward_list with copies of the elements + * in the range [@a first,@a last). + * + * Note that the assignment completely changes the %forward_list and + * that the resulting %forward_list's size is the same as the number + * of elements assigned. Old data may be lost. + */ + template<typename _InputIterator> + void + assign(_InputIterator __first, _InputIterator __last) + { + clear(); + insert_after(cbefore_begin(), __first, __last); + } + + /** + * @brief Assigns a given value to a %forward_list. + * @param n Number of elements to be assigned. + * @param val Value to be assigned. + * + * This function fills a %forward_list with @a n copies of the given + * value. Note that the assignment completely changes the + * %forward_list and that the resulting %forward_list's size is the + * same as the number of elements assigned. Old data may be lost. + */ + void + assign(size_type __n, const _Tp& __val) + { + clear(); + insert_after(cbefore_begin(), __n, __val); + } + + /** + * @brief Assigns an initializer_list to a %forward_list. + * @param il An initializer_list of value_type. + * + * Replace the contents of the %forward_list with copies of the + * elements in the initializer_list @a il. This is linear in + * il.size(). + */ + void + assign(std::initializer_list<_Tp> __il) + { + clear(); + insert_after(cbefore_begin(), __il); + } + + /// Get a copy of the memory allocation object. + allocator_type + get_allocator() const + { return this->_M_get_Node_allocator(); } + + // 23.2.3.2 iterators: + + /** + * Returns a read/write iterator that points before the first element + * in the %forward_list. Iteration is done in ordinary element order. + */ + iterator + before_begin() + { return iterator(&this->_M_impl._M_head); } + + /** + * Returns a read-only (constant) iterator that points before the + * first element in the %forward_list. Iteration is done in ordinary + * element order. + */ + const_iterator + before_begin() const + { return const_iterator(&this->_M_impl._M_head); } + + /** + * Returns a read/write iterator that points to the first element + * in the %forward_list. Iteration is done in ordinary element order. + */ + iterator + begin() + { return iterator(this->_M_impl._M_head._M_next); } + + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %forward_list. Iteration is done in ordinary + * element order. + */ + const_iterator + begin() const + { return const_iterator(this->_M_impl._M_head._M_next); } + + /** + * Returns a read/write iterator that points one past the last + * element in the %forward_list. Iteration is done in ordinary + * element order. + */ + iterator + end() + { return iterator(0); } + + /** + * Returns a read-only iterator that points one past the last + * element in the %forward_list. Iteration is done in ordinary + * element order. + */ + const_iterator + end() const + { return const_iterator(0); } + + /** + * Returns a read-only (constant) iterator that points to the + * first element in the %forward_list. Iteration is done in ordinary + * element order. + */ + const_iterator + cbegin() const + { return const_iterator(this->_M_impl._M_head._M_next); } + + /** + * Returns a read-only (constant) iterator that points before the + * first element in the %forward_list. Iteration is done in ordinary + * element order. + */ + const_iterator + cbefore_begin() const + { return const_iterator(&this->_M_impl._M_head); } + + /** + * Returns a read-only (constant) iterator that points one past + * the last element in the %forward_list. Iteration is done in + * ordinary element order. + */ + const_iterator + cend() const + { return const_iterator(0); } + + /** + * Returns true if the %forward_list is empty. (Thus begin() would + * equal end().) + */ + bool + empty() const + { return this->_M_impl._M_head._M_next == 0; } + + /** + * Returns the largest possible size of %forward_list. + */ + size_type + max_size() const + { return this->_M_get_Node_allocator().max_size(); } + + // 23.2.3.3 element access: + + /** + * Returns a read/write reference to the data at the first + * element of the %forward_list. + */ + reference + front() + { + _Node* __front = static_cast<_Node*>(this->_M_impl._M_head._M_next); + return __front->_M_value; + } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %forward_list. + */ + const_reference + front() const + { + _Node* __front = static_cast<_Node*>(this->_M_impl._M_head._M_next); + return __front->_M_value; + } + + // 23.2.3.4 modifiers: + + /** + * @brief Constructs object in %forward_list at the front of the + * list. + * @param args Arguments. + * + * This function will insert an object of type Tp constructed + * with Tp(std::forward<Args>(args)...) at the front of the list + * Due to the nature of a %forward_list this operation can + * be done in constant time, and does not invalidate iterators + * and references. + */ + template<typename... _Args> + void + emplace_front(_Args&&... __args) + { this->_M_insert_after(cbefore_begin(), + std::forward<_Args>(__args)...); } + + /** + * @brief Add data to the front of the %forward_list. + * @param val Data to be added. + * + * This is a typical stack operation. The function creates an + * element at the front of the %forward_list and assigns the given + * data to it. Due to the nature of a %forward_list this operation + * can be done in constant time, and does not invalidate iterators + * and references. + */ + void + push_front(const _Tp& __val) + { this->_M_insert_after(cbefore_begin(), __val); } + + /** + * + */ + void + push_front(_Tp&& __val) + { this->_M_insert_after(cbefore_begin(), std::move(__val)); } + + /** + * @brief Removes first element. + * + * This is a typical stack operation. It shrinks the %forward_list + * by one. Due to the nature of a %forward_list this operation can + * be done in constant time, and only invalidates iterators/references + * to the element being removed. + * + * Note that no data is returned, and if the first element's data + * is needed, it should be retrieved before pop_front() is + * called. + */ + void + pop_front() + { this->_M_erase_after(&this->_M_impl._M_head); } + + /** + * @brief Constructs object in %forward_list after the specified + * iterator. + * @param pos A const_iterator into the %forward_list. + * @param args Arguments. + * @return An iterator that points to the inserted data. + * + * This function will insert an object of type T constructed + * with T(std::forward<Args>(args)...) after the specified + * location. Due to the nature of a %forward_list this operation can + * be done in constant time, and does not invalidate iterators + * and references. + */ + template<typename... _Args> + iterator + emplace_after(const_iterator __pos, _Args&&... __args) + { return iterator(this->_M_insert_after(__pos, + std::forward<_Args>(__args)...)); } + + /** + * @brief Inserts given value into %forward_list after specified + * iterator. + * @param pos An iterator into the %forward_list. + * @param val Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given value after + * the specified location. Due to the nature of a %forward_list this + * operation can be done in constant time, and does not + * invalidate iterators and references. + */ + iterator + insert_after(const_iterator __pos, const _Tp& __val) + { return iterator(this->_M_insert_after(__pos, __val)); } + + /** + * + */ + iterator + insert_after(const_iterator __pos, _Tp&& __val) + { return iterator(this->_M_insert_after(__pos, std::move(__val))); } + + /** + * @brief Inserts a number of copies of given data into the + * %forward_list. + * @param pos An iterator into the %forward_list. + * @param n Number of elements to be inserted. + * @param val Data to be inserted. + * + * This function will insert a specified number of copies of the + * given data after the location specified by @a pos. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + void + insert_after(const_iterator __pos, size_type __n, const _Tp& __val) + { + forward_list __tmp(__n, __val, this->get_allocator()); + this->splice_after(__pos, std::move(__tmp)); + } + + /** + * @brief Inserts a range into the %forward_list. + * @param position An iterator into the %forward_list. + * @param first An input iterator. + * @param last An input iterator. + * + * This function will insert copies of the data in the range [@a + * first,@a last) into the %forward_list after the location specified + * by @a pos. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + template<typename _InputIterator> + void + insert_after(const_iterator __pos, + _InputIterator __first, _InputIterator __last) + { + forward_list __tmp(__first, __last, this->get_allocator()); + this->splice_after(__pos, std::move(__tmp)); + } + + /** + * @brief Inserts the contents of an initializer_list into + * %forward_list after the specified iterator. + * @param pos An iterator into the %forward_list. + * @param il An initializer_list of value_type. + * + * This function will insert copies of the data in the + * initializer_list @a il into the %forward_list before the location + * specified by @a pos. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + void + insert_after(const_iterator __pos, std::initializer_list<_Tp> __il) + { + forward_list __tmp(__il, this->get_allocator()); + this->splice_after(__pos, std::move(__tmp)); + } + + /** + * @brief Removes the element pointed to by the iterator following + * @c pos. + * @param pos Iterator pointing to element to be erased. + * @return An iterator pointing to the next element (or end()). + * + * This function will erase the element at the given position and + * thus shorten the %forward_list by one. + * + * Due to the nature of a %forward_list this operation can be done + * in constant time, and only invalidates iterators/references to + * the element being removed. The user is also cautioned that + * this function only erases the element, and that if the element + * is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + iterator + erase_after(const_iterator __pos) + { + _Fwd_list_node_base* __tmp + = const_cast<_Fwd_list_node_base*>(__pos._M_node); + if (__tmp) + return iterator(this->_M_erase_after(__tmp)); + else + return end(); + } + + /** + * @brief Remove a range of elements. + * @param pos Iterator pointing before the first element to be + * erased. + * @param last Iterator pointing to one past the last element to be + * erased. + * @return An iterator pointing to the element pointed to by @a last + * prior to erasing (or end()). + * + * This function will erase the elements in the range @a + * (pos,last) and shorten the %forward_list accordingly. + * + * This operation is linear time in the size of the range and only + * invalidates iterators/references to the element being removed. + * The user is also cautioned that this function only erases the + * elements, and that if the elements themselves are pointers, the + * pointed-to memory is not touched in any way. Managing the pointer + * is the user's responsibility. + */ + iterator + erase_after(const_iterator __pos, iterator __last) + { + _Fwd_list_node_base* __tmp + = const_cast<_Fwd_list_node_base*>(__pos._M_node); + return iterator(this->_M_erase_after(__tmp, __last._M_node)); + } + + /** + * @brief Swaps data with another %forward_list. + * @param list A %forward_list of the same element and allocator + * types. + * + * This exchanges the elements between two lists in constant + * time. Note that the global std::swap() function is + * specialized such that std::swap(l1,l2) will feed to this + * function. + */ + void + swap(forward_list&& __list) + { _Fwd_list_node_base::swap(this->_M_impl._M_head, + __list._M_impl._M_head); } + + /** + * @brief Resizes the %forward_list to the specified number of + * elements. + * @param sz Number of elements the %forward_list should contain. + * + * This function will %resize the %forward_list to the specified + * number of elements. If the number is smaller than the + * %forward_list's current size the %forward_list is truncated, + * otherwise the %forward_list is extended and new elements are + * populated with given data. + */ + void + resize(size_type __sz) + { resize(__sz, _Tp()); } + + /** + * @brief Resizes the %forward_list to the specified number of + * elements. + * @param sz Number of elements the %forward_list should contain. + * @param val Data with which new elements should be populated. + * + * This function will %resize the %forward_list to the specified + * number of elements. If the number is smaller than the + * %forward_list's current size the %forward_list is truncated, + * otherwise the %forward_list is extended and new elements are + * populated with given data. + */ + void + resize(size_type __sz, value_type __val); + + /** + * @brief Erases all the elements. + * + * Note that this function only erases + * the elements, and that if the elements themselves are + * pointers, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + void + clear() + { this->_M_erase_after(&this->_M_impl._M_head, 0); } + + // 23.2.3.5 forward_list operations: + + /** + * @brief Insert contents of another %forward_list. + * @param pos Iterator referencing the element to insert after. + * @param list Source list. + * + * The elements of @a list are inserted in constant time after + * the element referenced by @a pos. @a list becomes an empty + * list. + * + * Requires this != @a x. + */ + void + splice_after(const_iterator __pos, forward_list&& __list); + + /** + * @brief Insert element from another %forward_list. + * @param pos Iterator referencing the element to insert after. + * @param list Source list. + * @param it Iterator referencing the element before the element + * to move. + * + * Removes the element in list @a list referenced by @a i and + * inserts it into the current list after @a pos. + */ + void + splice_after(const_iterator __pos, forward_list&& __list, + const_iterator __it) + { this->splice_after(__pos, __list, __it, __it._M_next()); } + + /** + * @brief Insert range from another %forward_list. + * @param pos Iterator referencing the element to insert after. + * @param list Source list. + * @param before Iterator referencing before the start of range + * in list. + * @param last Iterator referencing the end of range in list. + * + * Removes elements in the range (before,last) and inserts them + * after @a pos in constant time. + * + * Undefined if @a pos is in (before,last). + */ + void + splice_after(const_iterator __pos, forward_list&& __list, + const_iterator __before, const_iterator __last); + + /** + * @brief Remove all elements equal to value. + * @param val The value to remove. + * + * Removes every element in the list equal to @a value. + * Remaining elements stay in list order. Note that this + * function only erases the elements, and that if the elements + * themselves are pointers, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + void + remove(const _Tp& __val); + + /** + * @brief Remove all elements satisfying a predicate. + * @param pred Unary predicate function or object. + * + * Removes every element in the list for which the predicate + * returns true. Remaining elements stay in list order. Note + * that this function only erases the elements, and that if the + * elements themselves are pointers, the pointed-to memory is + * not touched in any way. Managing the pointer is the user's + * responsibility. + */ + template<typename _Pred> + void + remove_if(_Pred __pred); + + /** + * @brief Remove consecutive duplicate elements. + * + * For each consecutive set of elements with the same value, + * remove all but the first one. Remaining elements stay in + * list order. Note that this function only erases the + * elements, and that if the elements themselves are pointers, + * the pointed-to memory is not touched in any way. Managing + * the pointer is the user's responsibility. + */ + void + unique() + { this->unique(std::equal_to<_Tp>()); } + + /** + * @brief Remove consecutive elements satisfying a predicate. + * @param binary_pred Binary predicate function or object. + * + * For each consecutive set of elements [first,last) that + * satisfy predicate(first,i) where i is an iterator in + * [first,last), remove all but the first one. Remaining + * elements stay in list order. Note that this function only + * erases the elements, and that if the elements themselves are + * pointers, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + template<typename _BinPred> + void + unique(_BinPred __binary_pred); + + /** + * @brief Merge sorted lists. + * @param list Sorted list to merge. + * + * Assumes that both @a list and this list are sorted according to + * operator<(). Merges elements of @a list into this list in + * sorted order, leaving @a list empty when complete. Elements in + * this list precede elements in @a list that are equal. + */ + void + merge(forward_list&& __list) + { this->merge(__list, std::less<_Tp>()); } + + /** + * @brief Merge sorted lists according to comparison function. + * @param list Sorted list to merge. + * @param comp Comparison function defining sort order. + * + * Assumes that both @a list and this list are sorted according to + * comp. Merges elements of @a list into this list + * in sorted order, leaving @a list empty when complete. Elements + * in this list precede elements in @a list that are equivalent + * according to comp(). + */ + template<typename _Comp> + void + merge(forward_list&& __list, _Comp __comp); + + /** + * @brief Sort the elements of the list. + * + * Sorts the elements of this list in NlogN time. Equivalent + * elements remain in list order. + */ + void + sort() + { + _Node* __tmp = static_cast<_Node*>(&this->_M_impl._M_head); + __tmp->_M_sort_after(std::less<_Tp>()); + } + + /** + * @brief Sort the forward_list using a comparison function. + * + * Sorts the elements of this list in NlogN time. Equivalent + * elements remain in list order. + */ + template<typename _Comp> + void + sort(_Comp __comp) + { + _Node* __tmp = static_cast<_Node*>(&this->_M_impl._M_head); + __tmp->_M_sort_after(__comp); + } + + /** + * @brief Reverse the elements in list. + * + * Reverse the order of elements in the list in linear time. + */ + void + reverse(); + + private: + template<typename _Integer> + void + _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) + { _M_fill_initialize(static_cast<size_type>(__n), __x); } + + // Called by the range constructor to implement [23.1.1]/9 + template<typename _InputIterator> + void + _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + __false_type); + + // Called by forward_list(n,v,a), and the range constructor when it + // turns out to be the same thing. + void + _M_fill_initialize(size_type __n, const value_type& __value); + }; + + /** + * @brief Forward list equality comparison. + * @param lx A %forward_list + * @param ly A %forward_list of the same type as @a lx. + * @return True iff the size and elements of the forward lists are equal. + * + * This is an equivalence relation. It is linear in the size of the + * forward lists. Deques are considered equivalent if corresponding + * elements compare equal. + */ + template<typename _Tp, typename _Alloc> + bool + operator==(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly); + + /** + * @brief Forward list ordering relation. + * @param lx A %forward_list. + * @param ly A %forward_list of the same type as @a lx. + * @return True iff @a lx is lexicographically less than @a ly. + * + * This is a total ordering relation. It is linear in the size of the + * forward lists. The elements must be comparable with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template<typename _Tp, typename _Alloc> + inline bool + operator<(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return std::lexicographical_compare(__lx.cbegin(), __lx.cend(), + __ly.cbegin(), __ly.cend()); } + + /// Based on operator== + template<typename _Tp, typename _Alloc> + inline bool + operator!=(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return !(__lx == __ly); } + + /// Based on operator< + template<typename _Tp, typename _Alloc> + inline bool + operator>(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return (__ly < __lx); } + + /// Based on operator< + template<typename _Tp, typename _Alloc> + inline bool + operator>=(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return !(__lx < __ly); } + + /// Based on operator< + template<typename _Tp, typename _Alloc> + inline bool + operator<=(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return !(__ly < __lx); } + + /// See std::forward_list::forward_swap(). + template<typename _Tp, typename _Alloc> + inline void + swap(forward_list<_Tp, _Alloc>& __lx, + forward_list<_Tp, _Alloc>& __ly) + { __lx.swap(__ly); } + + /// See std::forward_list::forward_swap(). + template<typename _Tp, typename _Alloc> + inline void + swap(forward_list<_Tp, _Alloc>&& __lx, + forward_list<_Tp, _Alloc>& __ly) + { __lx.swap(__ly); } + + /// See std::forward_list::forward_swap(). + template<typename _Tp, typename _Alloc> + inline void + swap(forward_list<_Tp, _Alloc>& __lx, + forward_list<_Tp, _Alloc>&& __ly) + { __lx.swap(__ly); } + +_GLIBCXX_END_NAMESPACE // namespace std + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _FORWARD_LIST_H diff --git a/libstdc++-v3/include/bits/forward_list.tcc b/libstdc++-v3/include/bits/forward_list.tcc new file mode 100644 index 00000000000..02b1a0d1d42 --- /dev/null +++ b/libstdc++-v3/include/bits/forward_list.tcc @@ -0,0 +1,422 @@ +// <forward_list.tcc> -*- C++ -*- + +// Copyright (C) 2008 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 2, 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. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02110-1301, USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file forward_list.tcc + * This is a Standard C++ Library header. + */ + +#ifndef _FORWARD_LIST_TCC +#define _FORWARD_LIST_TCC 1 + +_GLIBCXX_BEGIN_NAMESPACE(std) + + /** + * @brief Sort the singly linked list starting after this node. + * This node is assumed to be an empty head node (of type + * _Fwd_list_node_base). + */ + template<typename _Tp> + template<typename _Comp> + void + _Fwd_list_node<_Tp>:: + _M_sort_after(_Comp __comp) + { + // If `next' is 0, return immediately. + _Fwd_list_node* __list = static_cast<_Fwd_list_node*>(this->_M_next); + if (!__list) + return; + + unsigned long __insize = 1; + + while (1) + { + _Fwd_list_node* __p = __list; + __list = 0; + _Fwd_list_node* __tail = 0; + + // Count number of merges we do in this pass. + unsigned long __nmerges = 0; + + while (__p) + { + ++__nmerges; + // There exists a merge to be done. + // Step `insize' places along from p. + _Fwd_list_node* __q = __p; + unsigned long __psize = 0; + for (unsigned long __i = 0; __i < __insize; ++__i) + { + ++__psize; + __q = static_cast<_Fwd_list_node*>(__q->_M_next); + if (!__q) + break; + } + + // If q hasn't fallen off end, we have two lists to merge. + unsigned long __qsize = __insize; + + // Now we have two lists; merge them. + while (__psize > 0 || (__qsize > 0 && __q)) + { + // Decide whether next node of merge comes from p or q. + _Fwd_list_node<_Tp>* __e; + if (__psize == 0) + { + // p is empty; e must come from q. + __e = __q; + __q = static_cast<_Fwd_list_node*>(__q->_M_next); + --__qsize; + } + else if (__qsize == 0 || !__q) + { + // q is empty; e must come from p. + __e = __p; + __p = static_cast<_Fwd_list_node*>(__p->_M_next); + --__psize; + } + else if (__comp(__p->_M_value, __q->_M_value)) + { + // First node of p is lower; e must come from p. + __e = __p; + __p = static_cast<_Fwd_list_node*>(__p->_M_next); + --__psize; + } + else + { + // First node of q is lower; e must come from q. + __e = __q; + __q = static_cast<_Fwd_list_node*>(__q->_M_next); + --__qsize; + } + + // Add the next node to the merged list. + if (__tail) + __tail->_M_next = __e; + else + __list = __e; + __tail = __e; + } + + // Now p has stepped `insize' places along, and q has too. + __p = __q; + } + __tail->_M_next = 0; + + // If we have done only one merge, we're finished. + // Allow for nmerges == 0, the empty list case. + if (__nmerges <= 1) + { + this->_M_next = __list; + return; + } + + // Otherwise repeat, merging lists twice the size. + __insize *= 2; + } + } + + template<typename _Tp, typename _Alloc> + _Fwd_list_base<_Tp, _Alloc>:: + _Fwd_list_base(const _Fwd_list_base& __lst, const _Alloc& __a) + : _M_impl(__a) + { + this->_M_impl._M_head._M_next = 0; + _Fwd_list_node_base* __to = &this->_M_impl._M_head; + _Node* __curr = static_cast<_Node*>(__lst._M_impl._M_head._M_next); + while (__curr) + { + __to->_M_next = _M_create_node(__curr->_M_value); + __to = __to->_M_next; + __curr = static_cast<_Node*>(__curr->_M_next); + } + } + + template<typename _Tp, typename _Alloc> + template<typename... _Args> + _Fwd_list_node_base* + _Fwd_list_base<_Tp, _Alloc>:: + _M_insert_after(const_iterator __pos, _Args&&... __args) + { + _Fwd_list_node_base* __to + = const_cast<_Fwd_list_node_base*>(__pos._M_node); + _Node* __thing = _M_create_node(std::forward<_Args>(__args)...); + __thing->_M_next = __to->_M_next; + __to->_M_next = __thing; + return __to->_M_next; + } + + template<typename _Tp, typename _Alloc> + _Fwd_list_node_base* + _Fwd_list_base<_Tp, _Alloc>:: + _M_erase_after(_Fwd_list_node_base* __pos) + { + _Node* __curr = static_cast<_Node*>(__pos->_M_next); + if (__curr) + { + _Fwd_list_node_base* __next = __curr->_M_next; + __pos->_M_next = __next; + _M_get_Node_allocator().destroy(__curr); + _M_put_node(__curr); + } + return __pos; + } + + template<typename _Tp, typename _Alloc> + _Fwd_list_node_base* + _Fwd_list_base<_Tp, _Alloc>:: + _M_erase_after(_Fwd_list_node_base* __pos, _Fwd_list_node_base* __last) + { + _Node* __curr = static_cast<_Node*>(__pos->_M_next); + while (__curr) + { + _Node* __temp = __curr; + __curr = static_cast<_Node*>(__curr->_M_next); + _M_get_Node_allocator().destroy(__temp); + _M_put_node(__temp); + __pos->_M_next = __curr; + if (__temp == __last) + break; + } + return __pos; + } + + // Called by the range constructor to implement [23.1.1]/9 + template<typename _Tp, typename _Alloc> + template<typename _InputIterator> + void + forward_list<_Tp, _Alloc>:: + _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { + _Fwd_list_node_base* __to = &this->_M_impl._M_head; + for (; __first != __last; ++__first) + { + __to->_M_next = this->_M_create_node(*__first); + __to = __to->_M_next; + } + } + + // Called by forward_list(n,v,a), and the range constructor + // when it turns out to be the same thing. + template<typename _Tp, typename _Alloc> + void + forward_list<_Tp, _Alloc>:: + _M_fill_initialize(size_type __n, const value_type& __value) + { + _Fwd_list_node_base* __to = &this->_M_impl._M_head; + for (; __n > 0; --__n) + { + __to->_M_next = this->_M_create_node(__value); + __to = __to->_M_next; + } + } + + template<typename _Tp, typename _Alloc> + forward_list<_Tp, _Alloc>& + forward_list<_Tp, _Alloc>:: + operator=(const forward_list& __list) + { + if (&__list != this) + { + iterator __prev1 = before_begin(); + iterator __curr1 = begin(); + iterator __last1 = end(); + const_iterator __first2 = __list.cbegin(); + const_iterator __last2 = __list.cend(); + while (__curr1 != __last1 && __first2 != __last2) + { + *__curr1 = *__first2; + ++__prev1; + ++__curr1; + ++__first2; + } + if (__first2 == __last2) + erase_after(__prev1, __last1); + else + insert_after(__prev1, __first2, __last2); + } + return *this; + } + + template<typename _Tp, typename _Alloc> + void + forward_list<_Tp, _Alloc>:: + resize(size_type __sz, value_type __val) + { + iterator __k = before_begin(); + + size_type __len = 0; + while (__k._M_next() != end() && __len < __sz) + { + ++__k; + ++__len; + } + if (__len == __sz) + erase_after(__k, end()); + else + insert_after(__k, __sz - __len, __val); + } + + template<typename _Tp, typename _Alloc> + void + forward_list<_Tp, _Alloc>:: + splice_after(const_iterator __pos, forward_list&& __list) + { + if (!__list.empty() && &__list != this) + { + _Fwd_list_node_base* __tmp + = const_cast<_Fwd_list_node_base*>(__pos._M_node); + const_iterator __before = __list.cbefore_begin(); + __tmp->_M_transfer_after(const_cast<_Fwd_list_node_base*> + (__before._M_node)); + } + } + + template<typename _Tp, typename _Alloc> + void + forward_list<_Tp, _Alloc>:: + splice_after(const_iterator __pos, forward_list&& __list, + const_iterator __before, const_iterator __last) + { + _Fwd_list_node_base* __tmp + = const_cast<_Fwd_list_node_base*>(__pos._M_node); + __tmp->_M_transfer_after(const_cast<_Fwd_list_node_base*> + (__before._M_node), + const_cast<_Fwd_list_node_base*> + (__last._M_node)); + } + + template<typename _Tp, typename _Alloc> + void + forward_list<_Tp, _Alloc>:: + remove(const _Tp& __val) + { + _Node* __curr = static_cast<_Node*>(&this->_M_impl._M_head); + while (_Node* __temp = static_cast<_Node*>(__curr->_M_next)) + { + if (__temp->_M_value == __val) + this->_M_erase_after(__curr); + else + __curr = static_cast<_Node*>(__curr->_M_next); + } + } + + template<typename _Tp, typename _Alloc> + template<typename _Pred> + void + forward_list<_Tp, _Alloc>:: + remove_if(_Pred __pred) + { + _Node* __curr = static_cast<_Node*>(&this->_M_impl._M_head); + while (_Node* __temp = static_cast<_Node*>(__curr->_M_next)) + { + if (__pred(__temp->_M_value)) + this->_M_erase_after(__curr); + else + __curr = static_cast<_Node*>(__curr->_M_next); + } + } + + template<typename _Tp, typename _Alloc> + template<typename _BinPred> + void + forward_list<_Tp, _Alloc>:: + unique(_BinPred __binary_pred) + { + iterator __first = begin(); + iterator __last = end(); + if (__first == __last) + return; + iterator __next = __first; + while (++__next != __last) + { + if (__binary_pred(*__first, *__next)) + erase_after(__first); + else + __first = __next; + __next = __first; + } + } + + template<typename _Tp, typename _Alloc> + template<typename _Comp> + void + forward_list<_Tp, _Alloc>:: + merge(forward_list&& __list, _Comp __comp) + { + _Fwd_list_node_base* __node = &this->_M_impl._M_head; + while (__node->_M_next && __list._M_impl._M_head._M_next) + { + if (__comp(static_cast<_Node*> + (__list._M_impl._M_head._M_next)->_M_value, + static_cast<_Node*> + (__node->_M_next)->_M_value)) + __node->_M_transfer_after(&__list._M_impl._M_head, + __list._M_impl._M_head._M_next); + __node = __node->_M_next; + } + if (__list._M_impl._M_head._M_next) + { + __node->_M_next = __list._M_impl._M_head._M_next; + __list._M_impl._M_head._M_next = 0; + } + } + + template<typename _Tp, typename _Alloc> + void + forward_list<_Tp, _Alloc>:: + reverse() + { this->_M_impl._M_head._M_reverse_after(); } + + template<typename _Tp, typename _Alloc> + bool + operator==(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { + // We don't have size() so we need to walk through both lists + // making sure both iterators are valid. + auto __ix = __lx.cbegin(); + auto __iy = __ly.cbegin(); + while (__ix != __lx.cend() && __iy != __ly.cend()) + { + if (*__ix != *__iy) + return false; + ++__ix; + ++__iy; + } + if (__ix == __lx.cend() && __iy == __ly.cend()) + return true; + else + return false; + } + +_GLIBCXX_END_NAMESPACE // namespace std + +#endif /* _FORWARD_LIST_TCC */ + diff --git a/libstdc++-v3/include/bits/list.tcc b/libstdc++-v3/include/bits/list.tcc index 57ee10c4c6e..fc4f6ab0e99 100644 --- a/libstdc++-v3/include/bits/list.tcc +++ b/libstdc++-v3/include/bits/list.tcc @@ -1,6 +1,6 @@ // List implementation (out of line) -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -75,7 +75,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) { _Node* __tmp = __cur; __cur = static_cast<_Node*>(__cur->_M_next); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + _M_get_Node_allocator().destroy(__tmp); +#else _M_get_Tp_allocator().destroy(&__tmp->_M_data); +#endif _M_put_node(__tmp); } } diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index 91c339c1746..18f6f027681 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -101,6 +101,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) { ///< User's data. _Tp _M_data; + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename... _Args> + _List_node(_Args&&... __args) + : _List_node_base(), _M_data(std::forward<_Args>(__args)...) { } +#endif }; /** @@ -478,8 +484,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _Node* __p = this->_M_get_node(); try { - _M_get_Tp_allocator().construct(&__p->_M_data, - std::forward<_Args>(__args)...); + _M_get_Node_allocator().construct(__p, + std::forward<_Args>(__args)...); } catch(...) { @@ -807,7 +813,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) /** Returns the size() of the largest possible %list. */ size_type max_size() const - { return _M_get_Tp_allocator().max_size(); } + { return _M_get_Node_allocator().max_size(); } /** * @brief Resizes the %list to the specified number of elements. @@ -1423,7 +1429,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) { __position._M_node->unhook(); _Node* __n = static_cast<_Node*>(__position._M_node); - _M_get_Tp_allocator().destroy(&__n->_M_data); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + _M_get_Node_allocator().destroy(__n); +#else + _M_get_Tp_allocator().destroy(&__n->_M_data); +#endif _M_put_node(__n); } diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index d922a6db4dd..c80dbefc318 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -1,6 +1,6 @@ // RB tree implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -133,6 +133,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { typedef _Rb_tree_node<_Val>* _Link_type; _Val _M_value_field; + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename... _Args> + _Rb_tree_node(_Args&&... __args) + : _Rb_tree_node_base(), + _M_value_field(std::forward<_Args>(__args)...) { } +#endif }; _Rb_tree_node_base* @@ -360,6 +367,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _M_put_node(_Link_type __p) { _M_impl._Node_allocator::deallocate(__p, 1); } +#ifndef __GXX_EXPERIMENTAL_CXX0X__ _Link_type _M_create_node(const value_type& __x) { @@ -374,6 +382,39 @@ _GLIBCXX_BEGIN_NAMESPACE(std) return __tmp; } + void + _M_destroy_node(_Link_type __p) + { + get_allocator().destroy(&__p->_M_value_field); + _M_put_node(__p); + } +#else + template<typename... _Args> + _Link_type + _M_create_node(_Args&&... __args) + { + _Link_type __tmp = _M_get_node(); + try + { + _M_get_Node_allocator().construct(__tmp, + std::forward<_Args>(__args)...); + } + catch(...) + { + _M_put_node(__tmp); + __throw_exception_again; + } + return __tmp; + } + + void + _M_destroy_node(_Link_type __p) + { + _M_get_Node_allocator().destroy(__p); + _M_put_node(__p); + } +#endif + _Link_type _M_clone_node(_Const_Link_type __x) { @@ -384,13 +425,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) return __tmp; } - void - _M_destroy_node(_Link_type __p) - { - get_allocator().destroy(&__p->_M_value_field); - _M_put_node(__p); - } - protected: template<typename _Key_compare, bool _Is_pod_comparator = __is_pod(_Key_compare)> @@ -643,7 +677,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) size_type max_size() const - { return get_allocator().max_size(); } + { return _M_get_Node_allocator().max_size(); } void #ifdef __GXX_EXPERIMENTAL_CXX0X__ diff --git a/libstdc++-v3/include/precompiled/stdc++.h b/libstdc++-v3/include/precompiled/stdc++.h index b9249353678..33037300fd3 100644 --- a/libstdc++-v3/include/precompiled/stdc++.h +++ b/libstdc++-v3/include/precompiled/stdc++.h @@ -1,6 +1,7 @@ // C++ includes used for precompiling -*- C++ -*- -// Copyright (C) 2003, 2007 Free Software Foundation, Inc. +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 +// 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 @@ -99,6 +100,7 @@ #ifdef __GXX_EXPERIMENTAL_CXX0X__ #include <array> #include <chrono> +#include <forward_list> #include <random> #include <ratio> #include <regex> diff --git a/libstdc++-v3/include/std/forward_list b/libstdc++-v3/include/std/forward_list new file mode 100644 index 00000000000..7905007d481 --- /dev/null +++ b/libstdc++-v3/include/std/forward_list @@ -0,0 +1,51 @@ +// <forward_list> -*- C++ -*- + +// Copyright (C) 2008 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 2, 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. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02110-1301, USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file forward_list + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_FORWARD_LIST +#define _GLIBCXX_FORWARD_LIST 1 + +#pragma GCC system_header + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +# include <c++0x_warning.h> +#else + +#include <bits/forward_list.h> + +#ifndef _GLIBCXX_EXPORT_TEMPLATE +# include <bits/forward_list.tcc> +#endif + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _GLIBCXX_FORWARD_LIST diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex index f3848d09c02..e3922360b3d 100644 --- a/libstdc++-v3/include/std/mutex +++ b/libstdc++-v3/include/std/mutex @@ -489,9 +489,9 @@ namespace std lock() { if (!_M_device) - __throw_system_error(posix_error::operation_not_permitted); + __throw_system_error((int)errc::operation_not_permitted); else if (_M_owns) - __throw_system_error(posix_error::resource_deadlock_would_occur); + __throw_system_error((int)errc::resource_deadlock_would_occur); else { _M_device->lock(); @@ -503,9 +503,9 @@ namespace std try_lock() { if (!_M_device) - __throw_system_error(posix_error::operation_not_permitted); + __throw_system_error((int)errc::operation_not_permitted); else if (_M_owns) - __throw_system_error(posix_error::resource_deadlock_would_occur); + __throw_system_error((int)errc::resource_deadlock_would_occur); else { _M_owns = _M_device->try_lock(); @@ -518,9 +518,9 @@ namespace std try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) { if (!_M_device) - __throw_system_error(posix_error::operation_not_permitted); + __throw_system_error((int)errc::operation_not_permitted); else if (_M_owns) - __throw_system_error(posix_error::resource_deadlock_would_occur); + __throw_system_error((int)errc::resource_deadlock_would_occur); else { _M_owns = _M_device->try_lock_until(__atime); @@ -533,9 +533,9 @@ namespace std try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) { if (!_M_device) - __throw_system_error(posix_error::operation_not_permitted); + __throw_system_error((int)errc::operation_not_permitted); else if (_M_owns) - __throw_system_error(posix_error::resource_deadlock_would_occur); + __throw_system_error((int)errc::resource_deadlock_would_occur); else { _M_owns = _M_device->try_lock_for(__rtime); @@ -547,7 +547,7 @@ namespace std unlock() { if (!_M_owns) - __throw_system_error(posix_error::operation_not_permitted); + __throw_system_error((int)errc::operation_not_permitted); else if (_M_device) { _M_device->unlock(); diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error index 6a09ebf5272..4a93e5fbbc7 100644 --- a/libstdc++-v3/include/std/system_error +++ b/libstdc++-v3/include/std/system_error @@ -57,7 +57,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) struct is_error_code_enum : public false_type { }; template<> - struct is_error_code_enum<posix_error::posix_errno> + struct is_error_code_enum<errc> : public true_type { }; /// is_error_condition_enum @@ -65,14 +65,21 @@ _GLIBCXX_BEGIN_NAMESPACE(std) struct is_error_condition_enum : public false_type { }; template<> - struct is_error_condition_enum<posix_error::posix_errno> + struct is_error_condition_enum<errc> : public true_type { }; /// error_category - struct error_category + class error_category { - error_category() { } + protected: + error_category() = default; + + public: + virtual ~error_category() { } + + error_category(const error_category&) = delete; + error_category& operator=(const error_category&) = delete; virtual const char* name() const = 0; @@ -100,19 +107,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) bool operator!=(const error_category& __other) const { return this != &__other; } - - private: - error_category(const error_category&); - - error_category& - operator=(const error_category&); }; - const error_category& get_posix_category(); - const error_category& get_system_category(); - - static const error_category& posix_category = get_posix_category(); - static const error_category& system_category = get_system_category(); + // DR 890. + extern const error_category& system_category; + extern const error_category& generic_category; /// error_code // Implementation-specific error identification @@ -127,7 +126,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template<typename _ErrorCodeEnum> error_code(_ErrorCodeEnum __e, typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type* = 0) - : _M_value(__e), _M_cat(&posix_category) + : _M_value(static_cast<int>(__e)), _M_cat(&generic_category) { } void @@ -139,10 +138,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) void clear() - { - _M_value = 0; - _M_cat = &system_category; - } + { assign(0, system_category); } // DR 804. template<typename _ErrorCodeEnum> @@ -150,8 +146,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) error_code&>::type operator=(_ErrorCodeEnum __e) { - _M_value = __e; - _M_cat = &posix_category; + assign(static_cast<int>(__e), generic_category); return *this; } @@ -184,7 +179,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const error_category* _M_cat; }; - // 19.4.2.5 non-member functions + // 19.4.2.6 non-member functions + inline error_code + make_error_code(errc __e) + { return error_code(static_cast<int>(__e), generic_category); } + inline bool operator<(const error_code& __lhs, const error_code& __rhs) { @@ -203,7 +202,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // Portable error identification struct error_condition { - error_condition() : _M_value(0), _M_cat(&posix_category) { } + error_condition() : _M_value(0), _M_cat(&generic_category) { } error_condition(int __v, const error_category& __cat) : _M_value(__v), _M_cat(&__cat) { } @@ -212,7 +211,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) error_condition(_ErrorConditionEnum __e, typename enable_if<is_error_condition_enum <_ErrorConditionEnum>::value>::type* = 0) - : _M_value(__e), _M_cat(&posix_category) { } + : _M_value(static_cast<int>(__e)), _M_cat(&generic_category) { } void assign(int __v, const error_category& __cat) @@ -227,17 +226,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std) <_ErrorConditionEnum>::value, error_condition&>::type operator=(_ErrorConditionEnum __e) { - _M_value = __e; - _M_cat = &posix_category; + assign(static_cast<int>(__e), generic_category); return *this; } void clear() - { - _M_value = 0; - _M_cat = &posix_category; - } + { assign(0, generic_category); } // 19.4.3.4 observers int @@ -266,7 +261,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const error_category* _M_cat; }; - // 19.4.3.5 non-member functions + // 19.4.3.6 non-member functions + inline error_condition + make_error_condition(errc __e) + { return error_condition(static_cast<int>(__e), generic_category); } + inline bool operator<(const error_condition& __lhs, const error_condition& __rhs) { @@ -275,17 +274,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) && __lhs.value() < __rhs.value())); } - namespace posix_error - { - inline error_code - make_error_code(posix_errno __e) - { return error_code(__e, posix_category); } - - inline error_condition - make_error_condition(posix_errno __e) - { return error_condition(__e, posix_category); } - } - // 19.4.4 Comparison operators inline bool operator==(const error_code& __lhs, const error_code& __rhs) @@ -342,6 +330,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) system_error(error_code __ec, const string& __what) : runtime_error(__what), _M_code(__ec) { } + + /* + * TODO: Add const char* ctors to all exceptions. + * + * system_error(error_code __ec, const char* __what) + * : runtime_error(__what), _M_code(__ec) { } + * + * system_error(int __v, const error_category& __ecat, const char* __what) + * : runtime_error(__what), _M_code(error_code(__v, __ecat)) { } + */ system_error(int __v, const error_category& __ecat) : runtime_error(""), _M_code(error_code(__v, __ecat)) { } diff --git a/libstdc++-v3/include/tr1_impl/hashtable b/libstdc++-v3/include/tr1_impl/hashtable index c76deb06ca7..c6f1ac7aff6 100644 --- a/libstdc++-v3/include/tr1_impl/hashtable +++ b/libstdc++-v3/include/tr1_impl/hashtable @@ -296,7 +296,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 size_type max_size() const - { return _M_get_Value_allocator().max_size(); } + { return _M_node_allocator.max_size(); } // Observers key_equal @@ -484,7 +484,11 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 _Node* __n = _M_node_allocator.allocate(1); try { +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + _M_node_allocator.construct(__n, __v); +#else _M_get_Value_allocator().construct(&__n->_M_v, __v); +#endif __n->_M_next = 0; return __n; } @@ -504,7 +508,11 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: _M_deallocate_node(_Node* __n) { +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + _M_node_allocator.destroy(__n); +#else _M_get_Value_allocator().destroy(&__n->_M_v); +#endif _M_node_allocator.deallocate(__n, 1); } diff --git a/libstdc++-v3/include/tr1_impl/hashtable_policy.h b/libstdc++-v3/include/tr1_impl/hashtable_policy.h index 6677a72d8d2..1468ee8e989 100644 --- a/libstdc++-v3/include/tr1_impl/hashtable_policy.h +++ b/libstdc++-v3/include/tr1_impl/hashtable_policy.h @@ -99,6 +99,13 @@ namespace __detail _Value _M_v; std::size_t _M_hash_code; _Hash_node* _M_next; + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + template<typename... _Args> + _Hash_node(_Args&&... __args) + : _M_v(std::forward<_Args>(__args)...), + _M_hash_code(), _M_next() { } +#endif }; template<typename _Value> @@ -106,6 +113,13 @@ namespace __detail { _Value _M_v; _Hash_node* _M_next; + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + template<typename... _Args> + _Hash_node(_Args&&... __args) + : _M_v(std::forward<_Args>(__args)...), + _M_next() { } +#endif }; // Local iterators, used to iterate within a bucket but not between diff --git a/libstdc++-v3/src/functexcept.cc b/libstdc++-v3/src/functexcept.cc index 95b65bb326b..266e035662a 100644 --- a/libstdc++-v3/src/functexcept.cc +++ b/libstdc++-v3/src/functexcept.cc @@ -102,7 +102,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) void __throw_system_error(int __i) - { throw system_error(error_code(__i, system_category)); } + { throw system_error(error_code(__i, generic_category)); } void __throw_ios_failure(const char* __s) diff --git a/libstdc++-v3/src/system_error.cc b/libstdc++-v3/src/system_error.cc index 6724ef75a1f..dd950eba150 100644 --- a/libstdc++-v3/src/system_error.cc +++ b/libstdc++-v3/src/system_error.cc @@ -36,15 +36,12 @@ namespace { using std::string; - - struct gnu_error_category : public std::error_category + + struct generic_error_category : public std::error_category { virtual const char* name() const - { - const char* s = "GNU"; - return s; - } + { return "generic"; } virtual string message(int i) const @@ -55,17 +52,30 @@ namespace } }; - const gnu_error_category gnu_category; -} + struct system_error_category : public std::error_category + { + virtual const char* + name() const + { return "system"; } -_GLIBCXX_BEGIN_NAMESPACE(std) + virtual string + message(int i) const + { + // XXX locale issues: how does one get or set loc. + // _GLIBCXX_HAVE_STRERROR_L, strerror_l(i, cloc) + return string(strerror(i)); + } + }; - const error_category& - get_posix_category() { return gnu_category; } + const generic_error_category generic_category_instance; + const system_error_category system_category_instance; +} - const error_category& - get_system_category() { return gnu_category; } +_GLIBCXX_BEGIN_NAMESPACE(std) + const error_category& system_category = system_category_instance; + const error_category& generic_category = generic_category_instance; + system_error::~system_error() throw() { } error_condition diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++200x/all.cc b/libstdc++-v3/testsuite/17_intro/headers/c++200x/all.cc index 9a4ff726231..1ad6d360f32 100644 --- a/libstdc++-v3/testsuite/17_intro/headers/c++200x/all.cc +++ b/libstdc++-v3/testsuite/17_intro/headers/c++200x/all.cc @@ -100,6 +100,7 @@ #include <condition_variable> #include <deque> #include <exception> +#include <forward_list> #include <fstream> #include <functional> #include <iomanip> diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++200x/all_multiple_inclusion.cc b/libstdc++-v3/testsuite/17_intro/headers/c++200x/all_multiple_inclusion.cc index 7402cf747fb..8008f8867bd 100644 --- a/libstdc++-v3/testsuite/17_intro/headers/c++200x/all_multiple_inclusion.cc +++ b/libstdc++-v3/testsuite/17_intro/headers/c++200x/all_multiple_inclusion.cc @@ -98,6 +98,7 @@ #include <condition_variable> #include <deque> #include <exception> +#include <forward_list> #include <fstream> #include <functional> #include <iomanip> @@ -213,6 +214,7 @@ #include <condition_variable> #include <deque> #include <exception> +#include <forward_list> #include <fstream> #include <functional> #include <iomanip> diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_category/cons/copy_neg.cc b/libstdc++-v3/testsuite/19_diagnostics/error_category/cons/copy_neg.cc index e73884cc35f..8adf3fefa6a 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_category/cons/copy_neg.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_category/cons/copy_neg.cc @@ -33,7 +33,7 @@ int main() return 0; } -// { dg-error "is private" "" { target *-*-* } 105 } -// { dg-error "within this context" "" { target *-*-* } 40 } +// { dg-error "deleted function" "" { target *-*-* } 81 } +// { dg-error "used here" "" { target *-*-* } 40 } // { dg-error "first required here" "" { target *-*-* } 31 } // { dg-excess-errors "copy constructor" } diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc index 9dc11b70a08..742eb409925 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc @@ -38,9 +38,9 @@ int main() VERIFY( e2.category() == cat ); // 3 - std::error_code e3(std::posix_error::operation_not_supported); - VERIFY( e3.value() == int(std::posix_error::operation_not_supported) ); - VERIFY( e3.category() == std::posix_category ); + std::error_code e3(std::errc::operation_not_supported); + VERIFY( e3.value() == int(std::errc::operation_not_supported) ); + VERIFY( e3.category() == std::generic_category ); return 0; } diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc index 04fd44fb677..385960ce0c1 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc @@ -35,7 +35,7 @@ int main() } // 2 - std::error_code e2(std::posix_error::operation_not_supported); + std::error_code e2(std::errc::operation_not_supported); if (e2) { VERIFY( true ); diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/equal.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/equal.cc index a8fc65c4c31..8fcf1e59440 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/equal.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/equal.cc @@ -28,7 +28,7 @@ int main() bool test __attribute__((unused)) = true; std::error_code e1; - std::error_code e2(std::posix_error::operation_not_supported); + std::error_code e2(std::errc::operation_not_supported); VERIFY( e1 == e1 ); VERIFY( !(e1 == e2) ); diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/not_equal.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/not_equal.cc index d5d75553bf5..aca79ada6b6 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/not_equal.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/not_equal.cc @@ -28,7 +28,7 @@ int main() bool test __attribute__((unused)) = true; std::error_code e1; - std::error_code e2(std::posix_error::operation_not_supported); + std::error_code e2(std::errc::operation_not_supported); VERIFY( !(e1 != e1) ); VERIFY( e1 != e2 ); diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc index 572d2449546..5ea76f77a19 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc @@ -28,7 +28,7 @@ void test01() // 1 std::error_condition e1; VERIFY( e1.value() == 0 ); - VERIFY( e1.category() == std::posix_category ); + VERIFY( e1.category() == std::generic_category ); // 2 const __gnu_test::test_category cat; @@ -37,9 +37,9 @@ void test01() VERIFY( e2.category() == cat ); // 3 - std::error_condition e3(std::posix_error::operation_not_supported); - VERIFY( e3.value() == int(std::posix_error::operation_not_supported) ); - VERIFY( e3.category() == std::posix_category ); + std::error_condition e3(std::errc::operation_not_supported); + VERIFY( e3.value() == int(std::errc::operation_not_supported) ); + VERIFY( e3.category() == std::generic_category ); } int main() diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc index c1cda2626d4..d55256d564d 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc @@ -34,7 +34,7 @@ void test01() } // 2 - std::error_condition e2(std::posix_error::operation_not_supported); + std::error_condition e2(std::errc::operation_not_supported); if (e2) { VERIFY( true ); diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc index 4bdf36190a9..7d7c80f66c5 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc @@ -27,7 +27,7 @@ void test01() bool test __attribute__((unused)) = true; std::error_condition e1; - std::error_condition e2(std::posix_error::operation_not_supported); + std::error_condition e2(std::errc::operation_not_supported); VERIFY( e1 == e1 ); VERIFY( !(e1 == e2) ); diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/not_equal.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/not_equal.cc index 1b78b0af029..50a4e90a6c9 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/not_equal.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/not_equal.cc @@ -27,7 +27,7 @@ void test01() bool test __attribute__((unused)) = true; std::error_condition e1; - std::error_condition e2(std::posix_error::operation_not_supported); + std::error_condition e2(std::errc::operation_not_supported); VERIFY( !(e1 != e1) ); VERIFY( e1 != e2 ); diff --git a/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc new file mode 100644 index 00000000000..6eff4ee5bda --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc @@ -0,0 +1,158 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2008 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 2, 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include <system_error> + +#define TEST_ERRC(x) errc x(errc::x); (void)x + +void test01() +{ + using std::errc; + + TEST_ERRC(address_family_not_supported); + TEST_ERRC(address_in_use); + TEST_ERRC(address_not_available); + TEST_ERRC(already_connected); + TEST_ERRC(argument_list_too_long); + TEST_ERRC(argument_out_of_domain); + TEST_ERRC(bad_address); + TEST_ERRC(bad_file_descriptor); + +#ifdef _GLIBCXX_HAVE_EBADMSG + TEST_ERRC(bad_message); +#endif + + TEST_ERRC(broken_pipe); + TEST_ERRC(connection_aborted); + TEST_ERRC(connection_already_in_progress); + TEST_ERRC(connection_refused); + TEST_ERRC(connection_reset); + TEST_ERRC(cross_device_link); + TEST_ERRC(destination_address_required); + TEST_ERRC(device_or_resource_busy); + TEST_ERRC(directory_not_empty); + TEST_ERRC(executable_format_error); + TEST_ERRC(file_exists); + TEST_ERRC(file_too_large); + TEST_ERRC(filename_too_long); + TEST_ERRC(function_not_supported); + TEST_ERRC(host_unreachable); + +#ifdef _GLIBCXX_HAVE_EIDRM + TEST_ERRC(identifier_removed); +#endif + + TEST_ERRC(illegal_byte_sequence); + TEST_ERRC(inappropriate_io_control_operation); + TEST_ERRC(interrupted); + TEST_ERRC(invalid_argument); + TEST_ERRC(invalid_seek); + TEST_ERRC(io_error); + TEST_ERRC(is_a_directory); + TEST_ERRC(message_size); + TEST_ERRC(network_down); + TEST_ERRC(network_reset); + TEST_ERRC(network_unreachable); + TEST_ERRC(no_buffer_space); + TEST_ERRC(no_child_process); + +#ifdef _GLIBCXX_HAVE_ENOLINK + TEST_ERRC(no_link); +#endif + + TEST_ERRC(no_lock_available); + +#ifdef _GLIBCXX_HAVE_ENODATA + TEST_ERRC(no_message_available); +#endif + + TEST_ERRC(no_message); + TEST_ERRC(no_protocol_option); + TEST_ERRC(no_space_on_device); + +#ifdef _GLIBCXX_HAVE_ENOSR + TEST_ERRC(no_stream_resources); +#endif + + TEST_ERRC(no_such_device_or_address); + TEST_ERRC(no_such_device); + TEST_ERRC(no_such_file_or_directory); + TEST_ERRC(no_such_process); + TEST_ERRC(not_a_directory); + TEST_ERRC(not_a_socket); + +#ifdef _GLIBCXX_HAVE_ENOSTR + TEST_ERRC(not_a_stream); +#endif + + TEST_ERRC(not_connected); + TEST_ERRC(not_enough_memory); + TEST_ERRC(not_supported); + +#ifdef _GLIBCXX_HAVE_ECANCELED + TEST_ERRC(operation_canceled); +#endif + + TEST_ERRC(operation_in_progress); + TEST_ERRC(operation_not_permitted); + TEST_ERRC(operation_not_supported); + TEST_ERRC(operation_would_block); + +#ifdef _GLIBCXX_HAVE_EOWNERDEAD + TEST_ERRC(owner_dead); +#endif + + TEST_ERRC(permission_denied); + +#ifdef _GLIBCXX_HAVE_EPROTO + TEST_ERRC(protocol_error); +#endif + + TEST_ERRC(protocol_not_supported); + TEST_ERRC(read_only_file_system); + TEST_ERRC(resource_deadlock_would_occur); + TEST_ERRC(resource_unavailable_try_again); + TEST_ERRC(result_out_of_range); + +#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE + TEST_ERRC(state_not_recoverable); +#endif + +#ifdef _GLIBCXX_HAVE_ETIME + TEST_ERRC(stream_timeout); +#endif + +#ifdef _GLIBCXX_HAVE_ETXTBSY + TEST_ERRC(text_file_busy); +#endif + + TEST_ERRC(timed_out); + TEST_ERRC(too_many_files_open_in_system); + TEST_ERRC(too_many_files_open); + TEST_ERRC(too_many_links); + TEST_ERRC(too_many_symbolic_link_levels); + +#ifdef _GLIBCXX_HAVE_EOVERFLOW + TEST_ERRC(value_too_large); +#endif + + TEST_ERRC(wrong_protocol_type); +} diff --git a/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc index 00a24572fbd..416d849b14f 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc @@ -27,135 +27,4 @@ namespace gnu using std::error_code; using std::error_category; using std::system_category; - - using std::posix_error::posix_errno; - using std::posix_error::address_family_not_supported; - using std::posix_error::address_in_use; - using std::posix_error::address_not_available; - using std::posix_error::already_connected; - using std::posix_error::argument_list_too_long; - using std::posix_error::argument_out_of_domain; - using std::posix_error::bad_address; - using std::posix_error::bad_file_descriptor; - -#ifdef _GLIBCXX_HAVE_EBADMSG - using std::posix_error::bad_message; -#endif - - using std::posix_error::broken_pipe; - using std::posix_error::connection_aborted; - using std::posix_error::connection_already_in_progress; - using std::posix_error::connection_refused; - using std::posix_error::connection_reset; - using std::posix_error::cross_device_link; - using std::posix_error::destination_address_required; - using std::posix_error::device_or_resource_busy; - using std::posix_error::directory_not_empty; - using std::posix_error::executable_format_error; - using std::posix_error::file_exists; - using std::posix_error::file_too_large; - using std::posix_error::filename_too_long; - using std::posix_error::function_not_supported; - using std::posix_error::host_unreachable; - -#ifdef _GLIBCXX_HAVE_EIDRM - using std::posix_error::identifier_removed; -#endif - - using std::posix_error::illegal_byte_sequence; - using std::posix_error::inappropriate_io_control_operation; - using std::posix_error::interrupted; - using std::posix_error::invalid_argument; - using std::posix_error::invalid_seek; - using std::posix_error::io_error; - using std::posix_error::is_a_directory; - using std::posix_error::message_size; - using std::posix_error::network_down; - using std::posix_error::network_reset; - using std::posix_error::network_unreachable; - using std::posix_error::no_buffer_space; - using std::posix_error::no_child_process; - -#ifdef _GLIBCXX_HAVE_ENOLINK - using std::posix_error::no_link; -#endif - - using std::posix_error::no_lock_available; - -#ifdef _GLIBCXX_HAVE_ENODATA - using std::posix_error::no_message_available; -#endif - - using std::posix_error::no_message; - using std::posix_error::no_posix_equivalent; - using std::posix_error::no_protocol_option; - using std::posix_error::no_space_on_device; - -#ifdef _GLIBCXX_HAVE_ENOSR - using std::posix_error::no_stream_resources; -#endif - - using std::posix_error::no_such_device_or_address; - using std::posix_error::no_such_device; - using std::posix_error::no_such_file_or_directory; - using std::posix_error::no_such_process; - using std::posix_error::not_a_directory; - using std::posix_error::not_a_socket; - -#ifdef _GLIBCXX_HAVE_ENOSTR - using std::posix_error::not_a_stream; -#endif - - using std::posix_error::not_connected; - using std::posix_error::not_enough_memory; - using std::posix_error::not_supported; - -#ifdef _GLIBCXX_HAVE_ECANCELED - using std::posix_error::operation_canceled; -#endif - - using std::posix_error::operation_in_progress; - using std::posix_error::operation_not_permitted; - using std::posix_error::operation_not_supported; - using std::posix_error::operation_would_block; - -#ifdef _GLIBCXX_HAVE_EOWNERDEAD - using std::posix_error::owner_dead; -#endif - - using std::posix_error::permission_denied; - -#ifdef _GLIBCXX_HAVE_EPROTO - using std::posix_error::protocol_error; -#endif - - using std::posix_error::protocol_not_supported; - using std::posix_error::read_only_file_system; - using std::posix_error::resource_deadlock_would_occur; - using std::posix_error::resource_unavailable_try_again; - using std::posix_error::result_out_of_range; - -#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE - using std::posix_error::state_not_recoverable; -#endif - -#ifdef _GLIBCXX_HAVE_ETIME - using std::posix_error::stream_timeout; -#endif - -#ifdef _GLIBCXX_HAVE_ETXTBSY - using std::posix_error::text_file_busy; -#endif - - using std::posix_error::timed_out; - using std::posix_error::too_many_files_open_in_system; - using std::posix_error::too_many_files_open; - using std::posix_error::too_many_links; - using std::posix_error::too_many_synbolic_link_levels; - -#ifdef _GLIBCXX_HAVE_EOVERFLOW - using std::posix_error::value_too_large; -#endif - - using std::posix_error::wrong_protocol_type; } diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc index 9fc24f1f25d..bf73398616b 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc @@ -27,7 +27,7 @@ int main() { bool test __attribute__((unused)) = true; const std::string s("too late: boulangerie out of pain au raisin"); - const std::error_code e(std::posix_error::operation_not_supported); + const std::error_code e(std::errc::operation_not_supported); // 1 { diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc index 5934982fa47..e7304a1036e 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc @@ -32,7 +32,7 @@ void test01() bool test __attribute__((unused)) = true; std::string s("after nine thirty, this request cannot be met"); - std::system_error obj = std::system_error(std::posix_error::invalid_argument, s); + std::system_error obj = std::system_error(std::errc::invalid_argument, s); std::string s1(obj.what()); std::string s2(obj.what()); VERIFY( s1 == s2 ); diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc index 765c5a210ec..1f6ec0fc2de 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -129,8 +129,6 @@ test01() VERIFY( test ); VERIFY( d1 == -1.0 ); } - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc index 5645c0af9b8..32510e0f47f 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -129,8 +129,6 @@ test01() VERIFY( test ); VERIFY( f1 == -1.0f ); } - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc index 6f1efd0f4b9..0dc2df22df9 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -194,8 +194,6 @@ test01() } VERIFY( test ); VERIFY( i1 == 1 ); - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc index 683063fadf0..25970f2eb5f 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -157,8 +157,6 @@ test01() } VERIFY( test ); VERIFY( l1 == numeric_limits<long>::min() ); - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc index 3a5d73a954b..54f4ffe1eae 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -106,8 +106,6 @@ test01() test = false; } VERIFY( test ); - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc index 6d922156281..b20c5c5efeb 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -157,8 +157,6 @@ test01() } VERIFY( test ); VERIFY( ll1 == numeric_limits<long long>::min() ); - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc index c2d6cead337..20c6e08d2fc 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -144,8 +144,6 @@ test01() } VERIFY( test ); VERIFY( ul1 == numeric_limits<unsigned long>::max() ); - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc index 30c94ff8255..94ef49602fb 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -144,8 +144,6 @@ test01() } VERIFY( test ); VERIFY( ull1 == numeric_limits<unsigned long long>::max() ); - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc index 7a7d0657340..a332c41a1db 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -27,8 +29,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = true; using namespace std; @@ -55,8 +55,6 @@ test01() long double ld2 = -4.0L; string six(to_string(ld2)); VERIFY( six == "-4.000000" ); - -#endif } int main() diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/capacity/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/capacity/1.cc new file mode 100644 index 00000000000..e5ad77be917 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/capacity/1.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list capacity [lib.forward_list.capacity] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following. +// +void +test01() +{ + std::forward_list<double> fld; + VERIFY(fld.empty() == true); + + fld.push_front(1.0); + VERIFY(fld.empty() == false); + + fld.resize(0); + VERIFY(fld.empty() == true); + + VERIFY( fld.max_size() + == std::allocator<std::_Fwd_list_node<double> >().max_size() ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc b/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc new file mode 100644 index 00000000000..3ccfa357040 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on list (via swap). If the implementation changed +// this test may begin to fail. + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +int main() +{ + std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; + std::forward_list<double> b = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + + VERIFY((a == b) == false); + VERIFY((a < b) == true); + VERIFY((a != b) == true); + VERIFY((a > b) == false); + VERIFY((a >= b) == false); + VERIFY((a <= b) == true); + + VERIFY((b == a) == false); + VERIFY((b < a) == false); + VERIFY((b != a) == true); + VERIFY((b > a) == true); + VERIFY((b >= a) == true); + VERIFY((b <= a) == false); + + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/1.cc new file mode 100644 index 00000000000..4bb5501055c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/1.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Default construction +void +test01() +{ + std::forward_list<double> fld; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/2.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/2.cc new file mode 100644 index 00000000000..44c1318462c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/2.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Construction from iterator range +// Copy construction with allocator +void +test01() +{ + const int ni = 10; + int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + std::forward_list<int> flccin(i, i+ni); + std::forward_list<int> flcc(flccin, std::allocator<int>()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/3.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/3.cc new file mode 100644 index 00000000000..f09c884e1d7 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/3.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Move construction with allocator +void +test01() +{ + const int ni = 10; + int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + std::forward_list<int> flmc(std::forward_list<int>(i, i+ni), std::allocator<int>()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/4.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/4.cc new file mode 100644 index 00000000000..7cb33913442 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/4.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Construction from given number of default item +void +test01() +{ + std::forward_list<double> flvd(10); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/5.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/5.cc new file mode 100644 index 00000000000..2a4540ce64f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/5.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Construction from given number of given item +void +test01() +{ + std::forward_list<float> flv(10, 5.0F); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/6.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/6.cc new file mode 100644 index 00000000000..6210c0c8cdc --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/6.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Construction from iterator range +void +test01() +{ + const int ni = 10; + int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + std::forward_list<int> fl(i, i+ni); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/7.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/7.cc new file mode 100644 index 00000000000..2338db28cdc --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/7.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Copy construction +void +test01() +{ + const int ni = 10; + int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + std::forward_list<int> fl(i, i+ni); + std::forward_list<int> flc(fl); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/8.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/8.cc new file mode 100644 index 00000000000..daac89dafcb --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/8.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Move construction +void +test01() +{ + const int ni = 10; + int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + std::forward_list<int> fl(i, i+ni); + std::forward_list<int> flm(std::move(fl)); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/9.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/9.cc new file mode 100644 index 00000000000..1470d8117d1 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/9.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following. +// Construction from initializer list +void +test01() +{ + std::forward_list<double> flil({1.0, 2.0, 3.0, 4.0, 5.0}); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/1.cc new file mode 100644 index 00000000000..3498c6efacd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/1.cc @@ -0,0 +1,73 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +#include <array> + +bool test __attribute__((unused)) = true; + +class PathPoint +{ +public: + PathPoint(char t, std::array<double, 3> & c) + : type(t), coord(c) { } + char getType() const { return type; } +private: + char type; + std::array<double, 3> coord; +}; + +// This test verifies the following. +// emplace_front +// pop_front +// emplace_after +void +test01() +{ + std::forward_list<PathPoint> path; + std::array<double, 3> coord1 = { { 0.0, 1.0, 2.0 } }; + path.emplace_front('a', coord1); + + std::forward_list<PathPoint>::const_iterator pos = path.cbegin(); + + std::array<double, 3> coord2 = { { 3.0, 4.0, 5.0 } }; + path.emplace_after(pos, 'b', coord2); + + VERIFY(path.front().getType() == 'a'); + + path.pop_front(); + + VERIFY(path.front().getType() == 'b'); + + path.pop_front(); + + VERIFY(path.empty() == true); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/2.cc b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/2.cc new file mode 100644 index 00000000000..a6283580586 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/2.cc @@ -0,0 +1,135 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +#include <string> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// insert_after single item +// before_begin iterator +void +test01() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + fl.insert_after(fl.before_begin(), 42); + VERIFY(fl.front() == 42); +} + +// This test verifies the following: +void +test02() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY(*pos == 1); + + // Note: Calling l.insert_after(pos, 5, 42); without the long five + // gets resolved to the iterator range version and fails to compile! + fl.insert_after(pos, 5, 42); + VERIFY(*pos == 1); + + ++pos; + VERIFY(*pos == 42); + ++pos; + ++pos; + ++pos; + ++pos; + VERIFY(*pos == 42); +} + +// This test verifies the following: +void +test03() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY(*pos == 1); + + int i[3] = {666, 777, 888}; + fl.insert_after(pos, i, i+3); + VERIFY(*pos == 1); + + ++pos; + ++pos; + ++pos; + VERIFY(*pos == 888); + ++pos; + VERIFY(*pos == 2); +} + +// This test verifies the following: +void +test04() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY(*pos == 1); + + fl.insert_after(pos, {-1, -2, -3, -4, -5}); + VERIFY(*pos == 1); + + ++pos; + ++pos; + ++pos; + VERIFY(*pos == -3); +} + +// This test verifies the following: +void +test05() +{ + std::forward_list<std::string> fl({"AAA", "BBB", "CCC"}); + + std::forward_list<std::string>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY(*pos == "BBB"); + + std::string x( "XXX" ); + fl.insert_after(pos, std::move(x)); + VERIFY(*pos == "BBB"); + ++pos; + VERIFY(*pos == "XXX"); + ++pos; + VERIFY(*pos == "CCC"); +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/3.cc b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/3.cc new file mode 100644 index 00000000000..027dd18be97 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/3.cc @@ -0,0 +1,83 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// cbegin +// erase_after one iterator +// pos is useable and points to current element +void +test01() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY(*pos == 1); + + std::forward_list<int>::iterator next = fl.erase_after(pos); + VERIFY(*next == 1); + + VERIFY(*pos == 1); + ++pos; + VERIFY(*pos == 3); +} + +// This test verifies the following: +// cbegin +// erase_after iterator range +// pos is useable and points to current element +void +test02() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY(*pos == 1); + + std::forward_list<int>::iterator stop = fl.begin(); + ++stop; + ++stop; + ++stop; + ++stop; + VERIFY(*stop == 4); + + std::forward_list<int>::iterator next = fl.erase_after(pos, stop); + VERIFY(*next == 1); + + VERIFY(*pos == 1); + ++pos; + VERIFY(*pos == 5); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/4.cc b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/4.cc new file mode 100644 index 00000000000..9f9f8c65c8b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/4.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// swap +void +test01() +{ + std::forward_list<int> fl1({0, 1, 2, 3, 4, 5}); + std::forward_list<int> fl2({666, 777, 888}); + + fl1.swap(fl2); + + VERIFY(fl1.front() == 666); + VERIFY(fl2.front() == 0); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/5.cc b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/5.cc new file mode 100644 index 00000000000..17ad9297447 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/5.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// clear +void +test01() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + VERIFY(fl.empty() == false); + + fl.clear(); + + VERIFY(fl.empty() == true); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/moveable.cc b/libstdc++-v3/testsuite/23_containers/forward_list/moveable.cc new file mode 100644 index 00000000000..3ca95fdf013 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/moveable.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on list (via swap). If the implementation changed +// this test may begin to fail. + +#include <forward_list> +#include <utility> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +int main() +{ + std::forward_list<int> a, b; + a.push_front(1); + + b = std::move(a); + VERIFY(b.empty() == false); + VERIFY(*b.begin() == 1); + VERIFY(a.empty() == true); + + std::forward_list<int> c(std::move(b)); + VERIFY(c.empty() == false); + (*c.begin() == 1 ); + VERIFY( b.empty() == true ); + + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc new file mode 100644 index 00000000000..71dc27cde95 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc @@ -0,0 +1,107 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// +void +test01() +{ + std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; + std::forward_list<double>::const_iterator posa = a.cbefore_begin(); + + std::forward_list<double> x = {666.0, 777.0, 888.0}; + + a.splice_after(posa, x); + + ++posa; + VERIFY(*posa == 666.0); + + VERIFY(x.empty() == true); +} + +// This test verifies the following: +// +void +test02() +{ + std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; + std::forward_list<double>::const_iterator posa = a.cbefore_begin(); + ++posa; + VERIFY(*posa == 0.0); + + std::forward_list<double> y = {10.0, 11.0, 12.0, 13.0, 14.0, 15.0}; + std::forward_list<double>::const_iterator befy = y.cbefore_begin(); + ++befy; + VERIFY(*befy == 10.0); + std::forward_list<double>::const_iterator endy = befy; + ++endy; + ++endy; + ++endy; + ++endy; + VERIFY(*endy == 14.0); + + a.splice_after(posa, y, befy, endy); + VERIFY(*posa == 0.0); + + VERIFY(*befy == 10.0); + ++befy; + VERIFY(*befy == 15.0); +} + +// This test verifies the following: +// +void +test03() +{ + std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; + std::forward_list<double>::const_iterator posa = a.cbefore_begin(); + ++posa; + ++posa; + VERIFY(*posa == 1.0); + + std::forward_list<double> z = {42.0, 43.0, 44.0}; + std::forward_list<double>::const_iterator posz = z.begin(); + VERIFY(*posz == 42.0); + + a.splice_after(posa, z, posz); + VERIFY(*posa == 1.0); + ++posa; + VERIFY(*posa == 43.0); + + VERIFY(*posz == 42.0); + ++posz; + VERIFY(*posz == 44.0); +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/2.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/2.cc new file mode 100644 index 00000000000..bbd51af1202 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/2.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// remove +void +test01() +{ + std::forward_list<int> fl ={0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + fl.remove(7); + + std::forward_list<int>::const_iterator pos = fl.cbefore_begin(); + for (std::size_t i = 0; i < 7; ++i) + ++pos; + VERIFY(*pos == 6); + + ++pos; + VERIFY(*pos == 8); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/3.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/3.cc new file mode 100644 index 00000000000..c5bbb8a0ca1 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/3.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +#include <algorithm> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// remove_if +void +test01() +{ + std::forward_list<int> fl ={0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + fl.remove_if(std::bind2nd(std::less<int>(),5)); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + VERIFY(*pos == 5); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/4.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/4.cc new file mode 100644 index 00000000000..35e5bf8e21d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/4.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// unique +void +test01() +{ + std::forward_list<int> fl = {99, 5, 99, 6, -5, 666, 777, 888, + 42, 42, 42, 42, 42, 7, 0, 0, 0, 9, 9, 9}; + + fl.unique(); + + std::forward_list<int> fl2 = {99, 5, 99, 6, -5, 666, 777, 888, 42, 7, 0, 9}; + VERIFY(fl == fl2); +} + +// Test comparison predicate. +template<typename Num> + class Mod + { + public: + Mod(const Num & mod) + { + m = mod; + } + bool operator()(const Num i, const Num j) + { + return i%m == j%m; + } + private: + Num m; + }; + +// This test verifies the following: +// unique with predicate +void +test02() +{ + std::forward_list<int> fl = {99, 5, 99, 6, -5, 666, 777, 888, 42, 7, 0, 9}; + + fl.unique(Mod<int>(111)); + + std::forward_list<int> fl2 = {99, 5, 99, 6, -5, 666, 42, 7, 0, 9}; + VERIFY(fl == fl2); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc new file mode 100644 index 00000000000..a75b91d9cc8 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// +void +test01() +{ + std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; + std::forward_list<double> b = {1.0, 2.0, 3.0, 4.0, 4.0, 5.0}; + + a.merge(b); + + std::forward_list<double> r = {0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, + 4.0, 4.0, 4.0, 5.0}; + + VERIFY(a == r); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/6.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/6.cc new file mode 100644 index 00000000000..dc6268bb329 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/6.cc @@ -0,0 +1,84 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// Comparison functor. +template<typename Num> + class Comp + { + public: + Comp(const Num & num) + { + n = num; + } + bool operator()(const Num i, const Num j) + { + return (n * i) < (n * j); + } + private: + Num n; + }; + +// This test verifies the following: +// +void +test01() +{ + const unsigned int n = 13; + int order[][n] = { + { 0,1,2,3,4,5,6,7,8,9,10,11,12 }, + { 6,2,8,4,11,1,12,7,3,9,5,0,10 }, + { 12,11,10,9,8,7,6,5,4,3,2,1,0 }, + }; + std::forward_list<int> sorted(order[0], order[0] + n); + + for (unsigned int i = 0; i < sizeof(order)/sizeof(*order); ++i) + { + std::forward_list<int> head(order[i], order[i] + n); + + head.sort(); + + VERIFY(head == sorted); + } + + std::forward_list<int> reversed(order[2], order[2] + n); + for (unsigned int i = 0; i < sizeof(order)/sizeof(*order); ++i) + { + std::forward_list<int> head(order[i], order[i] + n); + + Comp<int> comp(-1); + head.sort( comp ); + + VERIFY(head == reversed); + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/7.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/7.cc new file mode 100644 index 00000000000..a51ce77eab5 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/7.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +#include <algorithm> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// +void +test01() +{ + const unsigned int n = 13; + int order[n] = {0,1,2,3,4,5,6,7,8,9,10,11,12}; + + std::forward_list<int> fl(order, order + n); + + std::forward_list<int> fl2; + for (std::size_t i = 0; i < n; ++i) + fl2.push_front(order[i]); + + fl.reverse(); + + VERIFY(std::lexicographical_compare(fl.begin(), fl.end(), + fl2.begin(), fl2.end()) == false); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/requirements/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/1.cc new file mode 100644 index 00000000000..40f8ad1d39f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/1.cc @@ -0,0 +1,70 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// A nontrivial type. +template<typename T> + struct A { }; + +// Another nontrivial type +struct B { }; + +// A nontrivial type convertible from an int +struct C +{ + C(int i) : i_(i) { } + bool operator==(const C& rhs) { return i_ == rhs.i_; } + int i_; +}; + +// This test verifies the following. +// +void +test01() +{ + std::forward_list< A<B> > lst; + VERIFY(lst.begin() == lst.end()); + VERIFY(std::distance(lst.begin(), lst.end()) == 0); + + // check type definitions -- will fail compile if missing + typedef std::forward_list< A<B> >::reference reference; + typedef std::forward_list< A<B> >::const_reference const_reference; + typedef std::forward_list< A<B> >::iterator iterator; + typedef std::forward_list< A<B> >::const_iterator const_iterator; + typedef std::forward_list< A<B> >::size_type size_type; + typedef std::forward_list< A<B> >::difference_type difference_type; + typedef std::forward_list< A<B> >::value_type value_type; + typedef std::forward_list< A<B> >::allocator_type allocator_type; + typedef std::forward_list< A<B> >::pointer pointer; + typedef std::forward_list< A<B> >::const_pointer const_pointer; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/1.cc new file mode 100644 index 00000000000..2650632e26c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/1.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <forward_list> + +// { dg-do compile } + +template class std::forward_list<int>; diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/3.cc new file mode 100644 index 00000000000..ca34423cc4d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/3.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <forward_list> + +// { dg-do compile } + +// libstdc++/21770 +template class std::forward_list<int, std::allocator<char> >; diff --git a/libstdc++-v3/testsuite/23_containers/headers/forward_list/synopsis.cc b/libstdc++-v3/testsuite/23_containers/headers/forward_list/synopsis.cc new file mode 100644 index 00000000000..339982cf155 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/headers/forward_list/synopsis.cc @@ -0,0 +1,53 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 2, 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include <forward_list> + +namespace std { + template <class T, class Allocator> class forward_list; + + template <class T, class Allocator> + bool operator==(const forward_list<T,Allocator>& x, const forward_list<T,Allocator>&); + + template <class T, class Allocator> + bool operator< (const forward_list<T,Allocator>& x, const forward_list<T,Allocator>&); + + template <class T, class Allocator> + bool operator!=(const forward_list<T,Allocator>& x, const forward_list<T,Allocator>&); + + template <class T, class Allocator> + bool operator> (const forward_list<T,Allocator>& x, const forward_list<T,Allocator>&); + + template <class T, class Allocator> + bool operator>=(const forward_list<T,Allocator>& x, const forward_list<T,Allocator>&); + + template <class T, class Allocator> + bool operator<=(const forward_list<T,Allocator>& x, const forward_list<T,Allocator>&); + + template <class T, class Allocator> + void swap(forward_list<T,Allocator>& x, forward_list<T,Allocator>& y); + + template <class T, class Allocator> + void swap(forward_list<T,Allocator>&& x, forward_list<T,Allocator>& y); + + template <class T, class Allocator> + void swap(forward_list<T,Allocator>& x, forward_list<T,Allocator>&& y); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/list/capacity/29134.cc index 513466565f6..f334479431a 100644 --- a/libstdc++-v3/testsuite/23_containers/list/capacity/29134.cc +++ b/libstdc++-v3/testsuite/23_containers/list/capacity/29134.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2006 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008 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 @@ -28,7 +28,13 @@ void test01() std::list<int> l; - VERIFY( l.max_size() == l.get_allocator().max_size() ); +#ifndef _GLIBCXX_DEBUG + using std::_List_node; +#else + using std::_GLIBCXX_STD_D::_List_node; +#endif + + VERIFY( l.max_size() == std::allocator<_List_node<int> >().max_size() ); } int main() diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc index 23c541a8d29..5e7d7ea855b 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1383 } +// { dg-error "no matching" "" { target *-*-* } 1389 } // { dg-excess-errors "" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc index 479c416590f..dd9a4c34529 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1352 } +// { dg-error "no matching" "" { target *-*-* } 1358 } // { dg-excess-errors "" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc index 3fd79856a5e..507c60df2fb 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1352 } +// { dg-error "no matching" "" { target *-*-* } 1358 } // { dg-excess-errors "" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc index 9b5e13a6e25..497db793cef 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1352 } +// { dg-error "no matching" "" { target *-*-* } 1358 } // { dg-excess-errors "" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/map/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/map/capacity/29134.cc index 6383eefa3ab..b43f091e31f 100644 --- a/libstdc++-v3/testsuite/23_containers/map/capacity/29134.cc +++ b/libstdc++-v3/testsuite/23_containers/map/capacity/29134.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2006 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008 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 @@ -28,7 +28,8 @@ void test01() std::map<int, int> m; - VERIFY( m.max_size() == m.get_allocator().max_size() ); + VERIFY( (m.max_size() == std::allocator<std::_Rb_tree_node< + std::pair<const int, int> > >().max_size()) ); } int main() diff --git a/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc b/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc index 7d66059b1fd..dd8888af3d2 100644 --- a/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc @@ -1,6 +1,6 @@ // { dg-do compile } -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -42,5 +42,5 @@ void test01() test &= itr == mapByName.end(); // { dg-error "no" } } -// { dg-error "candidates are" "" { target *-*-* } 210 } -// { dg-error "candidates are" "" { target *-*-* } 214 } +// { dg-error "candidates are" "" { target *-*-* } 217 } +// { dg-error "candidates are" "" { target *-*-* } 221 } diff --git a/libstdc++-v3/testsuite/23_containers/multimap/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/multimap/capacity/29134.cc index 466a3341f9e..c592fd1f1bd 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/capacity/29134.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/capacity/29134.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2006 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008 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 @@ -28,7 +28,8 @@ void test01() std::multimap<int, int> mm; - VERIFY( mm.max_size() == mm.get_allocator().max_size() ); + VERIFY( (mm.max_size() == std::allocator<std::_Rb_tree_node< + std::pair<const int, int> > >().max_size()) ); } int main() diff --git a/libstdc++-v3/testsuite/23_containers/multiset/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/multiset/capacity/29134.cc index ddfb165e8d9..f75e65268ff 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/capacity/29134.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/capacity/29134.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2006 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008 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 @@ -28,7 +28,8 @@ void test01() std::multiset<int> ms; - VERIFY( ms.max_size() == ms.get_allocator().max_size() ); + VERIFY( ms.max_size() + == std::allocator<std::_Rb_tree_node<int> >().max_size() ); } int main() diff --git a/libstdc++-v3/testsuite/23_containers/set/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/set/capacity/29134.cc index 51650399b73..6669f27d1ea 100644 --- a/libstdc++-v3/testsuite/23_containers/set/capacity/29134.cc +++ b/libstdc++-v3/testsuite/23_containers/set/capacity/29134.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2006 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008 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 @@ -28,7 +28,8 @@ void test01() std::set<int> s; - VERIFY( s.max_size() == s.get_allocator().max_size() ); + VERIFY( s.max_size() == + std::allocator<std::_Rb_tree_node<int> >().max_size() ); } int main() diff --git a/libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc b/libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc index a999e5b9697..5dfb45e98c9 100644 --- a/libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc @@ -1,6 +1,6 @@ // { dg-do compile } -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -40,5 +40,5 @@ void test01() test &= itr == setByName.end(); // { dg-error "no" } } -// { dg-error "candidates are" "" { target *-*-* } 285 } -// { dg-error "candidates are" "" { target *-*-* } 289 } +// { dg-error "candidates are" "" { target *-*-* } 292 } +// { dg-error "candidates are" "" { target *-*-* } 296 } diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc index e4814d6f5d9..82031316859 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc @@ -33,7 +33,7 @@ void test() char buf[64]; error_code e1; - error_code e2(posix_error::bad_address); + error_code e2(errc::bad_address); string s, s1, s2; { diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc index 73c838b4399..7cd416598f3 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc @@ -33,7 +33,7 @@ void test() wchar_t buf[64]; error_code e1; - error_code e2(posix_error::bad_address); + error_code e2(errc::bad_address); wstring s, s1, s2; { diff --git a/libstdc++-v3/testsuite/30_threads/unique_lock/locking/2.cc b/libstdc++-v3/testsuite/30_threads/unique_lock/locking/2.cc index 2a3aa17c5e8..e2599eb5c5e 100644 --- a/libstdc++-v3/testsuite/30_threads/unique_lock/locking/2.cc +++ b/libstdc++-v3/testsuite/30_threads/unique_lock/locking/2.cc @@ -53,8 +53,7 @@ void test01() } catch (const std::system_error& ex) { - VERIFY( ex.code() == std::error_code( - std::posix_error::operation_not_permitted) ); + VERIFY( ex.code() == std::error_code(std::errc::operation_not_permitted) ); } catch (...) { @@ -91,7 +90,7 @@ void test02() catch (const std::system_error& ex) { VERIFY( ex.code() == std::error_code( - std::posix_error::resource_deadlock_would_occur) ); + std::errc::resource_deadlock_would_occur) ); } catch (...) { diff --git a/libstdc++-v3/testsuite/Makefile.am b/libstdc++-v3/testsuite/Makefile.am index 407d7c95f91..14ce3b7bf4c 100644 --- a/libstdc++-v3/testsuite/Makefile.am +++ b/libstdc++-v3/testsuite/Makefile.am @@ -21,7 +21,9 @@ ## Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, ## USA. -AUTOMAKE_OPTIONS = dejagnu nostdinc +AUTOMAKE_OPTIONS = nostdinc +RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir +EXPECT = expect include $(top_srcdir)/fragment.am @@ -86,6 +88,80 @@ new-abi-baseline: fi; \ ${extract_symvers} ../src/.libs/libstdc++.so $${output}) +%/site.exp: site.exp + -test -d $* || mkdir $* + @srcdir=`cd $(srcdir); ${PWD_COMMAND}`; + objdir=`${PWD_COMMAND}`/$*; \ + sed -e "s|^set srcdir .*$$|set srcdir $$srcdir|" \ + -e "s|^set objdir .*$$|set objdir $$objdir|" \ + site.exp > $*/site.exp.tmp + @-rm -f $*/site.bak + @test ! -f $*/site.exp || mv $*/site.exp $*/site.bak + @mv $*/site.exp.tmp $*/site.exp + +check_DEJAGNU_normal_targets = $(patsubst %,check-DEJAGNUnormal%,0 1 2 3) +$(check_DEJAGNU_normal_targets): check-DEJAGNUnormal%: normal%/site.exp + +# Run the testsuite in normal mode. +check-DEJAGNU $(check_DEJAGNU_normal_targets): check-DEJAGNU%: site.exp + if [ -z "$*$(filter-out --target_board=%, $(RUNTESTFLAGS))" ] \ + && [ "$(filter -j, $(MFLAGS))" = "-j" ]; then \ + $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNUnormal0 check-DEJAGNUnormal1 \ + check-DEJAGNUnormal2 check-DEJAGNUnormal3; \ + for idx in 0 1 2 3; do \ + mv -f normal$$idx/libstdc++.sum normal$$idx/libstdc++.sum.sep; \ + mv -f normal$$idx/libstdc++.log normal$$idx/libstdc++.log.sep; \ + done; \ + mv -f libstdc++.sum libstdc++.sum.sep; \ + mv -f libstdc++.log libstdc++.log.sep; \ + $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh \ + libstdc++.sum.sep normal0/libstdc++.sum.sep \ + normal1/libstdc++.sum.sep normal2/libstdc++.sum.sep \ + normal3/libstdc++.sum.sep > libstdc++.sum; \ + $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh -L \ + libstdc++.log.sep normal0/libstdc++.log.sep \ + normal1/libstdc++.log.sep normal2/libstdc++.log.sep \ + normal3/libstdc++.log.sep > libstdc++.log; \ + exit 0; \ + fi; \ + srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \ + EXPECT=$(EXPECT); export EXPECT; \ + runtest=$(RUNTEST); \ + if [ -z "$$runtest" ]; then runtest=runtest; fi; \ + tool=libstdc++; \ + dirs=; \ + case "$*" in \ + normal0) \ + if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ + $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) \ + $(RUNTESTFLAGS) abi.exp; \ + else echo "WARNING: could not find \`runtest'" 1>&2; :;\ + fi; \ + dirs="`cd $$srcdir; echo [013-9][0-9]_*/* [abep]*/*`";; \ + normal1) \ + dirs="`cd $$srcdir; echo 2[0-2]_*/*`";; \ + normal2) \ + dirs="`cd $$srcdir; echo 2[4-9]_*/*`";; \ + normal3) \ + dirs="`cd $$srcdir; echo 23_*/* t*/*`";; \ + esac; \ + if [ -n "$*" ]; then cd "$*"; fi; \ + if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ + if [ -n "$$dirs" ]; then \ + $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) \ + $(RUNTESTFLAGS) \ + "conformance.exp=`echo $$dirs | sed 's/ /* /g;s/$$/*/'`"; \ + else \ + $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) \ + $(RUNTESTFLAGS); \ + fi; \ + else echo "WARNING: could not find \`runtest'" 1>&2; :;\ + fi + +check-am: + $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU +.PHONY: check-DEJAGNU + # Use 'new-abi-baseline' to create an initial symbol file. Then run # 'check-abi' to test for changes against that file. check-abi: site.exp baseline_symbols diff --git a/libstdc++-v3/testsuite/Makefile.in b/libstdc++-v3/testsuite/Makefile.in index 94d0964fdc2..85a2ffdaa74 100644 --- a/libstdc++-v3/testsuite/Makefile.in +++ b/libstdc++-v3/testsuite/Makefile.in @@ -66,10 +66,6 @@ depcomp = am__depfiles_maybe = SOURCES = DIST_SOURCES = -DEJATOOL = $(PACKAGE) -RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir -EXPECT = expect -RUNTEST = runtest DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABI_TWEAKS_SRCDIR = @ABI_TWEAKS_SRCDIR@ ACLOCAL = @ACLOCAL@ @@ -272,7 +268,9 @@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ toplevel_srcdir = @toplevel_srcdir@ -AUTOMAKE_OPTIONS = dejagnu nostdinc +AUTOMAKE_OPTIONS = nostdinc +RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir +EXPECT = expect # May be used by various substitution variables. gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) @@ -304,6 +302,7 @@ lists_of_files = \ baseline_file = ${baseline_dir}/baseline_symbols.txt extract_symvers = $(glibcxx_srcdir)/scripts/extract_symvers +check_DEJAGNU_normal_targets = $(patsubst %,check-DEJAGNUnormal%,0 1 2 3) # Runs the testsuite, but in compile only mode. # Can be used to test sources with non-GNU FE's at various warning @@ -381,23 +380,6 @@ ctags: CTAGS CTAGS: -check-DEJAGNU: site.exp - srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \ - EXPECT=$(EXPECT); export EXPECT; \ - runtest=$(RUNTEST); \ - if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ - l='$(DEJATOOL)'; for tool in $$l; do \ - $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \ - done; \ - else echo "WARNING: could not find \`runtest'" 1>&2; :;\ - fi - -distclean-DEJAGNU: - -rm -f site.exp site.bak - -l='$(DEJATOOL)'; for tool in $$l; do \ - rm -f $$tool.sum $$tool.log; \ - done - distdir: $(DISTFILES) $(mkdir_p) $(distdir)/.. @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ @@ -427,7 +409,6 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU check: check-am all-am: Makefile installdirs: @@ -462,8 +443,7 @@ clean-am: clean-generic clean-libtool clean-local mostlyclean-am distclean: distclean-am -rm -f Makefile -distclean-am: clean-am distclean-DEJAGNU distclean-generic \ - distclean-libtool +distclean-am: clean-am distclean-generic distclean-libtool dvi: dvi-am @@ -503,16 +483,15 @@ ps-am: uninstall-am: uninstall-info-am -.PHONY: all all-am check check-DEJAGNU check-am clean clean-generic \ - clean-libtool clean-local distclean distclean-DEJAGNU \ - distclean-generic distclean-libtool distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-exec install-exec-am install-info \ - install-info-am install-man install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \ - uninstall-info-am +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + clean-local distclean distclean-generic distclean-libtool \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + uninstall uninstall-am uninstall-info-am # This rule generates all of the testsuite_files* lists at once. @@ -565,6 +544,78 @@ new-abi-baseline: fi; \ ${extract_symvers} ../src/.libs/libstdc++.so $${output}) +%/site.exp: site.exp + -test -d $* || mkdir $* + @srcdir=`cd $(srcdir); ${PWD_COMMAND}`; + objdir=`${PWD_COMMAND}`/$*; \ + sed -e "s|^set srcdir .*$$|set srcdir $$srcdir|" \ + -e "s|^set objdir .*$$|set objdir $$objdir|" \ + site.exp > $*/site.exp.tmp + @-rm -f $*/site.bak + @test ! -f $*/site.exp || mv $*/site.exp $*/site.bak + @mv $*/site.exp.tmp $*/site.exp +$(check_DEJAGNU_normal_targets): check-DEJAGNUnormal%: normal%/site.exp + +# Run the testsuite in normal mode. +check-DEJAGNU $(check_DEJAGNU_normal_targets): check-DEJAGNU%: site.exp + if [ -z "$*$(filter-out --target_board=%, $(RUNTESTFLAGS))" ] \ + && [ "$(filter -j, $(MFLAGS))" = "-j" ]; then \ + $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNUnormal0 check-DEJAGNUnormal1 \ + check-DEJAGNUnormal2 check-DEJAGNUnormal3; \ + for idx in 0 1 2 3; do \ + mv -f normal$$idx/libstdc++.sum normal$$idx/libstdc++.sum.sep; \ + mv -f normal$$idx/libstdc++.log normal$$idx/libstdc++.log.sep; \ + done; \ + mv -f libstdc++.sum libstdc++.sum.sep; \ + mv -f libstdc++.log libstdc++.log.sep; \ + $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh \ + libstdc++.sum.sep normal0/libstdc++.sum.sep \ + normal1/libstdc++.sum.sep normal2/libstdc++.sum.sep \ + normal3/libstdc++.sum.sep > libstdc++.sum; \ + $(SHELL) $(srcdir)/../../contrib/dg-extract-results.sh -L \ + libstdc++.log.sep normal0/libstdc++.log.sep \ + normal1/libstdc++.log.sep normal2/libstdc++.log.sep \ + normal3/libstdc++.log.sep > libstdc++.log; \ + exit 0; \ + fi; \ + srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \ + EXPECT=$(EXPECT); export EXPECT; \ + runtest=$(RUNTEST); \ + if [ -z "$$runtest" ]; then runtest=runtest; fi; \ + tool=libstdc++; \ + dirs=; \ + case "$*" in \ + normal0) \ + if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ + $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) \ + $(RUNTESTFLAGS) abi.exp; \ + else echo "WARNING: could not find \`runtest'" 1>&2; :;\ + fi; \ + dirs="`cd $$srcdir; echo [013-9][0-9]_*/* [abep]*/*`";; \ + normal1) \ + dirs="`cd $$srcdir; echo 2[0-2]_*/*`";; \ + normal2) \ + dirs="`cd $$srcdir; echo 2[4-9]_*/*`";; \ + normal3) \ + dirs="`cd $$srcdir; echo 23_*/* t*/*`";; \ + esac; \ + if [ -n "$*" ]; then cd "$*"; fi; \ + if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ + if [ -n "$$dirs" ]; then \ + $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) \ + $(RUNTESTFLAGS) \ + "conformance.exp=`echo $$dirs | sed 's/ /* /g;s/$$/*/'`"; \ + else \ + $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) \ + $(RUNTESTFLAGS); \ + fi; \ + else echo "WARNING: could not find \`runtest'" 1>&2; :;\ + fi + +check-am: + $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU +.PHONY: check-DEJAGNU + # Use 'new-abi-baseline' to create an initial symbol file. Then run # 'check-abi' to test for changes against that file. check-abi: site.exp baseline_symbols diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp index 0f1bfcfe559..78072256476 100644 --- a/libstdc++-v3/testsuite/lib/dg-options.exp +++ b/libstdc++-v3/testsuite/lib/dg-options.exp @@ -124,3 +124,12 @@ proc dg-require-nanosleep { args } { } return } + +proc dg-require-string-conversions { args } { + if { ![ check_v3_target_string_conversions ] } { + upvar dg-do-what dg-do-what + set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] + return + } + return +} diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 10eac6294b5..8a4e8c430c4 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -1236,3 +1236,61 @@ proc check_v3_target_nanosleep { } { verbose "check_v3_target_nanosleep: $et_nanosleep" 2 return $et_nanosleep } + +proc check_v3_target_string_conversions { } { + global cxxflags + global DEFAULT_CXXFLAGS + global et_string_conversions + + global tool + + if { ![info exists et_string_conversions_target_name] } { + set et_string_conversions_target_name "" + } + + # If the target has changed since we set the cached value, clear it. + set current_target [current_target_name] + if { $current_target != $et_string_conversions_target_name } { + verbose "check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2 + set et_string_conversions_target_name $current_target + if [info exists et_string_conversions] { + verbose "check_v3_target_string_conversions: removing cached result" 2 + unset et_string_conversions + } + } + + if [info exists et_string_conversions] { + verbose "check_v3_target_string_conversions: using cached result" 2 + } else { + set et_string_conversions 0 + + # Set up and compile a C++0x test program that depends + # on the string_conversions facilities to be available. + set src string_conversions[pid].cc + set exe string_conversions[pid].exe + + set f [open $src "w"] + puts $f "#include <bits/c++config.h>" + puts $f "int main()" + puts $f "#if defined(_GLIBCXX_USE_C99) && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)" + puts $f "{ return 0; }" + puts $f "#endif" + close $f + + set cxxflags_saved $cxxflags + set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" + + set lines [v3_target_compile $src $exe executable ""] + set cxxflags $cxxflags_saved + file delete $src + + if [string match "" $lines] { + # No error message, compilation succeeded. + set et_string_conversions 1 + } else { + verbose "check_v3_target_string_conversions: compilation failed" 2 + } + } + verbose "check_v3_target_string_conversions: $et_string_conversions" 2 + return $et_string_conversions +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/capacity/29134-map.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/capacity/29134-map.cc index 459ace41a88..24d51ef508e 100644 --- a/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/capacity/29134-map.cc +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_map/capacity/29134-map.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2006 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008 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 @@ -28,7 +28,8 @@ void test01() std::tr1::unordered_map<int, int> um; - VERIFY( um.max_size() == um.get_allocator().max_size() ); + VERIFY( (um.max_size() == std::allocator<std::tr1::__detail::_Hash_node< + std::pair<const int, int>, false> >().max_size())); } int main() diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/capacity/29134-multimap.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/capacity/29134-multimap.cc index af41fa154d6..dc1db508811 100644 --- a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/capacity/29134-multimap.cc +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multimap/capacity/29134-multimap.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2006 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008 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 @@ -28,7 +28,8 @@ void test01() std::tr1::unordered_multimap<int, int> umm; - VERIFY( umm.max_size() == umm.get_allocator().max_size() ); + VERIFY( (umm.max_size() == std::allocator<std::tr1::__detail::_Hash_node< + std::pair<const int, int>, false> >().max_size()) ); } int main() diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multiset/capacity/29134-multiset.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multiset/capacity/29134-multiset.cc index 923af9be118..f4e2f6a1c25 100644 --- a/libstdc++-v3/testsuite/tr1/6_containers/unordered_multiset/capacity/29134-multiset.cc +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_multiset/capacity/29134-multiset.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2006 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008 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 @@ -28,7 +28,8 @@ void test01() std::tr1::unordered_multiset<int> ums; - VERIFY( ums.max_size() == ums.get_allocator().max_size() ); + VERIFY( (ums.max_size() == std::allocator<std::tr1::__detail::_Hash_node< + int, false> >().max_size()) ); } int main() diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/capacity/29134-set.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/capacity/29134-set.cc index 5822341c85e..ca8333e42f6 100644 --- a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/capacity/29134-set.cc +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/capacity/29134-set.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2006 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008 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 @@ -28,7 +28,8 @@ void test01() std::tr1::unordered_set<int> us; - VERIFY( us.max_size() == us.get_allocator().max_size() ); + VERIFY( (us.max_size() == std::allocator<std::tr1::__detail::_Hash_node< + int, false> >().max_size()) ); } int main() |