2009-12-17 09:37:16 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
|
2015-01-05 13:33:28 +01:00
|
|
|
// Copyright (C) 2009-2015 Free Software Foundation, Inc.
|
2009-12-17 09:37:16 +00:00
|
|
|
//
|
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
|
// software; you can redistribute it and/or modify it under the terms
|
|
|
|
// of the GNU General Public License as published by the Free Software
|
|
|
|
// Foundation; either version 3, or (at your option) any later
|
|
|
|
// version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this library; see the file COPYING3. If not see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#ifndef _GLIBCXX_EXCEPTION_SAFETY_H
|
|
|
|
#define _GLIBCXX_EXCEPTION_SAFETY_H
|
|
|
|
|
|
|
|
#include <testsuite_container_traits.h>
|
|
|
|
#include <ext/throw_allocator.h>
|
|
|
|
|
|
|
|
// Container requirement testing.
|
|
|
|
namespace __gnu_test
|
|
|
|
{
|
|
|
|
// Base class for exception testing, contains utilities.
|
|
|
|
struct setup_base
|
|
|
|
{
|
|
|
|
typedef std::size_t size_type;
|
|
|
|
typedef std::uniform_int_distribution<size_type> distribution_type;
|
|
|
|
typedef std::mt19937 engine_type;
|
|
|
|
|
|
|
|
// Return randomly generated integer on range [0, __max_size].
|
|
|
|
static size_type
|
|
|
|
generate(size_type __max_size)
|
|
|
|
{
|
|
|
|
// Make the generator static...
|
|
|
|
const engine_type engine;
|
|
|
|
const distribution_type distribution;
|
|
|
|
static auto generator = std::bind(distribution, engine,
|
|
|
|
std::placeholders::_1);
|
|
|
|
|
|
|
|
// ... but set the range for this particular invocation here.
|
|
|
|
const typename distribution_type::param_type p(0, __max_size);
|
|
|
|
size_type random = generator(p);
|
|
|
|
if (random < distribution.min() || random > distribution.max())
|
2013-09-21 19:04:13 -07:00
|
|
|
std::__throw_out_of_range_fmt(__N("setup_base::generate\n"
|
|
|
|
"random number generated is: %zu "
|
|
|
|
"out of range [%zu, %zu]\n"),
|
|
|
|
(size_t)random,
|
|
|
|
(size_t)distribution.min(),
|
|
|
|
(size_t)distribution.max());
|
2009-12-17 09:37:16 +00:00
|
|
|
return random;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Given an instantiating type, return a unique value.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct generate_unique
|
|
|
|
{
|
|
|
|
typedef _Tp value_type;
|
|
|
|
|
|
|
|
operator value_type()
|
|
|
|
{
|
|
|
|
static value_type __ret;
|
|
|
|
++__ret;
|
|
|
|
return __ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Partial specialization for pair.
|
|
|
|
template<typename _Tp1, typename _Tp2>
|
|
|
|
struct generate_unique<std::pair<const _Tp1, _Tp2>>
|
|
|
|
{
|
|
|
|
typedef _Tp1 first_type;
|
|
|
|
typedef _Tp2 second_type;
|
|
|
|
typedef std::pair<const _Tp1, _Tp2> pair_type;
|
|
|
|
|
|
|
|
operator pair_type()
|
|
|
|
{
|
|
|
|
static first_type _S_1;
|
|
|
|
static second_type _S_2;
|
|
|
|
++_S_1;
|
|
|
|
++_S_2;
|
|
|
|
return pair_type(_S_1, _S_2);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Partial specialization for throw_value
|
|
|
|
template<typename _Cond>
|
|
|
|
struct generate_unique<__gnu_cxx::throw_value_base<_Cond>>
|
|
|
|
{
|
|
|
|
typedef __gnu_cxx::throw_value_base<_Cond> value_type;
|
|
|
|
|
|
|
|
operator value_type()
|
|
|
|
{
|
|
|
|
static size_t _S_i(0);
|
|
|
|
return value_type(_S_i++);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Construct container of size n directly. _Tp == container type.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct make_container_base
|
|
|
|
{
|
|
|
|
_Tp _M_container;
|
|
|
|
|
|
|
|
make_container_base() = default;
|
|
|
|
make_container_base(const size_type n): _M_container(n) { }
|
|
|
|
|
|
|
|
operator _Tp&() { return _M_container; }
|
|
|
|
};
|
|
|
|
|
|
|
|
// Construct container of size n, via multiple insertions. For
|
|
|
|
// associated and unordered types, unique value_type elements are
|
|
|
|
// necessary.
|
|
|
|
template<typename _Tp, bool = traits<_Tp>::is_mapped::value>
|
|
|
|
struct make_insert_container_base
|
|
|
|
: public make_container_base<_Tp>
|
|
|
|
{
|
|
|
|
using make_container_base<_Tp>::_M_container;
|
|
|
|
typedef typename _Tp::value_type value_type;
|
|
|
|
|
|
|
|
make_insert_container_base(const size_type n)
|
|
|
|
{
|
|
|
|
for (size_type i = 0; i < n; ++i)
|
|
|
|
{
|
|
|
|
value_type v = generate_unique<value_type>();
|
|
|
|
_M_container.insert(v);
|
|
|
|
}
|
|
|
|
assert(_M_container.size() == n);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
struct make_insert_container_base<_Tp, false>
|
|
|
|
: public make_container_base<_Tp>
|
|
|
|
{
|
|
|
|
using make_container_base<_Tp>::_M_container;
|
|
|
|
typedef typename _Tp::value_type value_type;
|
|
|
|
|
|
|
|
make_insert_container_base(const size_type n)
|
|
|
|
{
|
|
|
|
for (size_type i = 0; i < n; ++i)
|
|
|
|
{
|
|
|
|
value_type v = generate_unique<value_type>();
|
|
|
|
_M_container.insert(_M_container.end(), v);
|
|
|
|
}
|
|
|
|
assert(_M_container.size() == n);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename _Tp, bool = traits<_Tp>::has_size_type_constructor::value>
|
|
|
|
struct make_container_n;
|
|
|
|
|
|
|
|
// Specialization for non-associative types that have a constructor with
|
|
|
|
// a size argument.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct make_container_n<_Tp, true>
|
|
|
|
: public make_container_base<_Tp>
|
|
|
|
{
|
|
|
|
make_container_n(const size_type n) : make_container_base<_Tp>(n) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
struct make_container_n<_Tp, false>
|
|
|
|
: public make_insert_container_base<_Tp>
|
|
|
|
{
|
|
|
|
make_container_n(const size_type n)
|
|
|
|
: make_insert_container_base<_Tp>(n) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Randomly size and populate a given container reference.
|
|
|
|
// NB: Responsibility for turning off exceptions lies with caller.
|
|
|
|
template<typename _Tp, bool = traits<_Tp>::is_allocator_aware::value>
|
|
|
|
struct populate
|
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef typename container_type::allocator_type allocator_type;
|
|
|
|
typedef typename container_type::value_type value_type;
|
|
|
|
|
|
|
|
populate(_Tp& __container)
|
|
|
|
{
|
|
|
|
const allocator_type a = __container.get_allocator();
|
|
|
|
|
|
|
|
// Size test container.
|
|
|
|
const size_type max_elements = 100;
|
|
|
|
size_type n = generate(max_elements);
|
|
|
|
|
|
|
|
// Construct new container.
|
|
|
|
make_container_n<container_type> made(n);
|
|
|
|
container_type& tmp = made;
|
|
|
|
std::swap(tmp, __container);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Partial specialization, empty.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct populate<_Tp, false>
|
|
|
|
{
|
|
|
|
populate(_Tp&) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
// Compare two containers for equivalence.
|
|
|
|
// Right now, that means size.
|
|
|
|
// Returns true if equal, throws if not.
|
|
|
|
template<typename _Tp>
|
|
|
|
static bool
|
|
|
|
compare(const _Tp& __control, const _Tp& __test)
|
|
|
|
{
|
|
|
|
// Make sure test container is in a consistent state, as
|
|
|
|
// compared to the control container.
|
|
|
|
// NB: Should be equivalent to __test != __control, but
|
|
|
|
// computed without equivalence operators
|
2012-11-05 20:58:35 +00:00
|
|
|
const size_type szt
|
|
|
|
= std::distance(__test.begin(), __test.end());
|
|
|
|
const size_type szc
|
|
|
|
= std::distance(__control.begin(), __control.end());
|
|
|
|
|
|
|
|
if (szt != szc)
|
|
|
|
throw std::logic_error(
|
|
|
|
"setup_base::compare containers size not equal");
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
// Should test iterator validity before and after exception.
|
|
|
|
bool __equal_it = std::equal(__test.begin(), __test.end(),
|
|
|
|
__control.begin());
|
|
|
|
|
2012-11-05 20:58:35 +00:00
|
|
|
if (!__equal_it)
|
|
|
|
throw std::logic_error(
|
|
|
|
"setup_base::compare containers iterators not equal");
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Containing structure holding functors.
|
|
|
|
struct functor_base : public setup_base
|
|
|
|
{
|
|
|
|
// Abstract the erase function.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct erase_base
|
|
|
|
{
|
|
|
|
typedef typename _Tp::iterator iterator;
|
2010-11-08 16:07:32 +00:00
|
|
|
typedef typename _Tp::const_iterator const_iterator;
|
2009-12-17 09:37:16 +00:00
|
|
|
|
2010-11-08 16:07:32 +00:00
|
|
|
iterator (_Tp::* _F_erase_point)(const_iterator);
|
|
|
|
iterator (_Tp::* _F_erase_range)(const_iterator, const_iterator);
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
erase_base()
|
|
|
|
: _F_erase_point(&_Tp::erase), _F_erase_range(&_Tp::erase) { }
|
|
|
|
};
|
|
|
|
|
New std::string implementation.
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_CXX11_ABI): Remove.
(GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI, GLIBCXX_DEFAULT_ABI): Add.
* configure.ac: Use new macros.
* configure: Regenerate.
* Makefile.in: Regenerate.
* doc/Makefile.in: Regenerate.
* libsupc++/Makefile.in: Regenerate.
* po/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
* include/Makefile.am: Set _GLIBCXX_USE_DUAL_ABI.
* include/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Export symbols related to new std::string.
Tighten old patterns to not match new symbols.
* config/locale/generic/monetary_members.cc: Guard some definitions
to not compile with new ABI.
* config/locale/gnu/monetary_members.cc: Likewise.
* config/locale/gnu/numeric_members.cc: Prevent double-free.
* config/os/gnu-linux/ldbl-extra.ver: Add new __gnu_cxx_ldbl128
exports. Tighten old patterns.
* doc/xml/manual/configure.xml: Document new configure options.
* doc/html/*: Regenerate.
* include/bits/basic_string.h (__cxx11::basic_string): Define new
non-reference-counted implementation in inline namespace __cxx11.
(stoi, stol, stoll, stof, stod, stold, to_string): Conditionally use
inline namespace.
(literals::string_literals::operator"): Conditionally use abi-tag.
* include/bits/basic_string.tcc (__cxx11::basic_string): Define.
* include/bits/c++config: Define _GLIBCXX_USE_DUAL_ABI and
LDBL_CXX11_ABI namespace macros.
* include/bits/locale_classes.h (locale::name()): Use abi_tag when
new ABI is in use.
(locale::_S_twinned_facets): New static member.
(locale::facet::__shim): Declare new type.
(locale::_facet::_M_sso_shim, locale::_facet::_M_cow_shim): New
functions for creating shims.
(locale::_Impl::_M_facet_unchecked): New member function for use
during construction.
(locale::_Impl::_M_init_extra): New member functions to create second
version of some facets.
(collate, collate_byname): Use abi_tag when new ABI is in use.
* include/bits/locale_facets.h: Add _GLIBCXX_NUM_CXX11_FACETS macro.
(numpunct, numpunct_byname): Use __cxx11 namespace.
(num_get::_M_extract_float, num_get::_M_extract_int): Use abi_tag
when new ABI is in use.
(num_get::__do_get, num_put::__do_put): Do not declare long double
compat functions for new ABI.
* include/bits/locale_facets.tcc (num_get, num_put): Use abi_tag on
definitions.
(numpunct, numpunct_byname): Qualify explicit instantiations.
* include/bits/locale_facets_nonio.h (time_get, time_get_byname,
moneypunct, moneypunct_byname, money_get, money_put, messages,
messages_byname): Use new inline namespace macros.
(money_get::__do_get, money_put::__do_put): Do not declare long
double compat functions for new ABI.
* include/bits/locale_facets_nonio.tcc (money_get, money_put): Use
new namespace macros.
(money_get::__do_get, money_put::__do_put): Do not define for new ABI.
* include/bits/localefwd.h (numpunct, numpunct_byname, collate,
collate_byname, time_get, time_get_byname, moneypunct,
moneypunct_byname, money_get, money_put, messages, messages_byname):
Use new namespace macros.
* include/bits/regex.h: Use inline namespace macros.
* include/bits/stl_list.h (_List_base, list): Use inline namespace
instead of abi-tag.
* include/bits/stringfwd.h (basic_string): Use namespace macros.
* include/std/iosfwd (basic_stringbuf, basic_istringstream,
basic_ostringstream, basic_stringstream): Likewise.
* include/std/sstream: Likewise.
(basic_stringbuf::__xfer_bufptrs): Update streambuf pointers on move.
* include/std/stdexcept (__cow_string, __sso_string): New types for
indirectly using std::string with either ABI.
(logic_error, runtime_error): Replace std::string member with
__cow_string when new ABI is in use. Declare non-inline copy
constructor and assignment operator. Declare const char* constructors.
(domain_error, invalid_argument, length_error, out_of_range,
range_error, overflow_error, underflow_error): Declare const char*
constructors.
* include/std/system_error (error_category): Replace with new
definition in inline namespace _V2.
(error_code::message, error_condition::message): Use abi_tag on
functions returning std::string.
* python/libstdcxx/v6/printers.py (StdStringPrinter): Handle new ABI.
* src/c++11/Makefile.am: Add new files.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/compatibility-c++0x.cc: Compile with old std::string ABI.
Define old error_category symbols.
* src/c++11/cow-fstream-inst.cc: New. Instantiate fstream members
using old std::string ABI.
* src/c++11/cow-locale_init.cc (locale::_Impl::_M_init_extra): Define.
* src/c++11/cow-shim_facets.cc: Define shim facets using old ABI.
* src/c++11/cow-sstream-inst.cc: Instantiate stringstreams using old
std::string ABI.
* src/c++11/cow-stdexcept.cc: Define new constructors and assignment
operators.
(__cow_string, error_category::_M_message): Define.
* src/c++11/cow-string-inst.cc: Explicit instantiations using old
std::string. Include src/c++98/istream-string.cc.
* src/c++11/cow-wstring-inst.cc: Explicit instantiations using old
std::wstring.
* src/c++11/cxx11-hash_tr1.cc: Explicit instantiations using new
string.
* src/c++11/cxx11-ios_failure.cc: Add sanity check.
* src/c++11/cxx11-locale-inst.cc: Instantiate facets using new
std::string.
* src/c++11/cxx11-shim_facets.cc: Define shim facets using new ABI.
* src/c++11/cxx11-stdexcept.cc: Define constructors taking new
std::string.
* src/c++11/cxx11-wlocale-inst.cc: Instantiate facets using
new std::wstring.
* src/c++11/fstream-inst.cc: Compile with new ABI.
* src/c++11/functexcept.cc: Compile with old ABI.
* src/c++11/random.cc: Compile with new ABI.
* src/c++11/sstream-inst.cc: Compile with new ABI.
* src/c++11/string-inst.cc: Explicit instantiations for new string.
* src/c++11/system_error.cc (__sso_string, error_category::_M_message):
Define.
* src/c++11/wstring-inst.cc: Compile with new ABI.
* src/c++98/Makefile.am: Compile some host files twice for old and
new std::string. Add new files.
* src/c++98/Makefile.in: Regenerate.
* src/c++98/compatibility-ldbl.cc: Compile with old ABI.
* src/c++98/compatibility.cc: Likewise.
* src/c++98/concept-inst.cc: Likewise.
* src/c++98/hash_tr1.cc: Likewise.
* src/c++98/istream-string.cc: New file defining functions that
work with istream and std::string moved from ...
* src/c++98/istream.cc: ... here.
* src/c++98/cow-istream-string.cc: Recompile istream-string.cc with
old ABI.
* src/c++98/locale-inst.cc: Adjust facet instantiations to work for
either ABI.
* src/c++98/locale.cc (locale::_M_install_facet,
locale::_M_install_cache): Handle twinned facets.
* src/c++98/locale-facets.cc: Compile with old std::string ABI.
(__verify_grouping): Define new overload and old std::string version.
* src/c++98/locale_init.cc: Initialize twinned facets.
* src/c++98/localename.cc: Likewise.
* src/c++98/misc-inst.cc: Instantiate C++98-only std::string members.
(__verify_grouping): Define new std::string version.
* src/c++98/stdexcept.cc: Compile with old std::string ABI.
* src/c++98/wlocale-inst.cc: Likewise.
* testsuite/18_support/50594.cc: Adjust to work with SSO strings.
* testsuite/21_strings/basic_string/capacity/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/18654.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/2.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc:
Likewise.
* testsuite/21_strings/headers/string/synopsis.cc: Use inline
namespace macros.
* testsuite/23_containers/headers/list/synopsis.cc: Likewise.
* testsuite/27_io/basic_ios/copyfmt/char/1.cc: Set dg-options so
correct exception type can be caught.
* testsuite/27_io/basic_ios/exceptions/char/1.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/char/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/char/12297.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/ios_base/storage/2.cc: Likewise.
* testsuite/27_io/ios_base/failure/cxx11.cc: Disable for old ABI.
* testsuite/ext/profile/mutex_extensions_neg.cc: Adjust dg-error.
* testsuite/libstdc++-prettyprinters/libfundts.cc: Use old ABI.
* testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
* testsuite/util/exception/safety.h: Adjust member function types
for new std::string.
* testsuite/util/testsuite_abi.cc: Add new version and ignore
__float128 symbols in __cxx11 namespace.
From-SVN: r218964
2014-12-19 18:16:39 +00:00
|
|
|
#if _GLIBCXX_USE_CXX11_ABI == 0 || __cplusplus < 201103L
|
stl_deque.h (deque<>::insert(iterator, const value_type&), [...]): Adjust C++11 signatures to take a const_iterator.
2013-06-27 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_deque.h (deque<>::insert(iterator,
const value_type&), deque<>::insert(iterator, value_type&&),
deque<>::emplace(iterator, _Args&&...)): Adjust C++11 signatures to
take a const_iterator.
(deque<>::erase): Simplify.
* include/bits/stl_list.h: Likewise.
(_List_iterator<>::_M_const_cast): Add.
* include/bits/stl_vector.h: Likewise.
* include/bits/stl_bvector.h: Likewise.
(_Bit_iterator::_M_const_cast): Add.
* include/bits/deque.tcc: Adjust definitions.
* include/bits/list.tcc: Likewise.
* include/bits/vector.tcc: Likewise.
* include/bits/stl_iterator.h (__normal_iterator<>::_M_const_cast):
Define trivial version in C++98 mode.
* include/ext/vstring.h (__versa_string<>::insert(iterator, _CharT),
__versa_string<>::replace(iterator, iterator, const __versa_string&),
__versa_string<>::replace(iterator, iterator, const _CharT*,
size_type), __versa_string<>::replace(iterator, iterator,
const _CharT*), __versa_string<>::replace(iterator, iterator,
size_type, _CharT)): Adjust C++11 signatures to take a pair of
const_iterators.
* include/debug/deque: Adjust.
* include/debug/list: Likewise.
* include/debug/vector: Likewise.
* include/profile/deque: Likewise.
* include/profile/list: Likewise.
* include/profile/vector: Likewise.
(vector<>::emplace): Add.
* testsuite/util/exception/safety.h: Update.
* testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc:
New.
* testsuite/23_containers/deque/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/23_containers/list/modifiers/emplace/const_iterator.cc:
Likewise.
* testsuite/23_containers/list/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/23_containers/vector/bool/modifiers/insert/
const_iterator.cc: Likewise.
* testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc:
Likewise.
* testsuite/23_containers/vector/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/char/54577.cc: Move to testsuite/
ext/vstring/modifiers/erase/char/.
* testsuite/ext/vstring/modifiers/wchar_t/54577.cc: Move to testsuite/
ext/vstring/modifiers/wchar_t/.
* testsuite/ext/vstring/modifiers/char/pop_back.cc: Move to testsuite/
ext/vstring/modifiers/pop_back/char/.
* testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc: Move to
testsuite/ext/vstring/modifiers/pop_back/wchar_t/.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/assign_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.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.
From-SVN: r200458
2013-06-27 09:51:21 +00:00
|
|
|
// Specialization, old C++03 signature.
|
2010-11-08 16:07:32 +00:00
|
|
|
template<typename _Tp1, typename _Tp2, typename _Tp3>
|
|
|
|
struct erase_base<std::basic_string<_Tp1, _Tp2, _Tp3>>
|
2009-12-17 09:37:16 +00:00
|
|
|
{
|
2010-11-08 16:07:32 +00:00
|
|
|
typedef std::basic_string<_Tp1, _Tp2, _Tp3> container_type;
|
2009-12-17 09:37:16 +00:00
|
|
|
typedef typename container_type::iterator iterator;
|
|
|
|
|
2010-11-08 16:07:32 +00:00
|
|
|
iterator (container_type::* _F_erase_point)(iterator);
|
|
|
|
iterator (container_type::* _F_erase_range)(iterator, iterator);
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
erase_base()
|
2010-11-08 16:07:32 +00:00
|
|
|
: _F_erase_point(&container_type::erase),
|
|
|
|
_F_erase_range(&container_type::erase) { }
|
2009-12-17 09:37:16 +00:00
|
|
|
};
|
New std::string implementation.
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_CXX11_ABI): Remove.
(GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI, GLIBCXX_DEFAULT_ABI): Add.
* configure.ac: Use new macros.
* configure: Regenerate.
* Makefile.in: Regenerate.
* doc/Makefile.in: Regenerate.
* libsupc++/Makefile.in: Regenerate.
* po/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
* include/Makefile.am: Set _GLIBCXX_USE_DUAL_ABI.
* include/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Export symbols related to new std::string.
Tighten old patterns to not match new symbols.
* config/locale/generic/monetary_members.cc: Guard some definitions
to not compile with new ABI.
* config/locale/gnu/monetary_members.cc: Likewise.
* config/locale/gnu/numeric_members.cc: Prevent double-free.
* config/os/gnu-linux/ldbl-extra.ver: Add new __gnu_cxx_ldbl128
exports. Tighten old patterns.
* doc/xml/manual/configure.xml: Document new configure options.
* doc/html/*: Regenerate.
* include/bits/basic_string.h (__cxx11::basic_string): Define new
non-reference-counted implementation in inline namespace __cxx11.
(stoi, stol, stoll, stof, stod, stold, to_string): Conditionally use
inline namespace.
(literals::string_literals::operator"): Conditionally use abi-tag.
* include/bits/basic_string.tcc (__cxx11::basic_string): Define.
* include/bits/c++config: Define _GLIBCXX_USE_DUAL_ABI and
LDBL_CXX11_ABI namespace macros.
* include/bits/locale_classes.h (locale::name()): Use abi_tag when
new ABI is in use.
(locale::_S_twinned_facets): New static member.
(locale::facet::__shim): Declare new type.
(locale::_facet::_M_sso_shim, locale::_facet::_M_cow_shim): New
functions for creating shims.
(locale::_Impl::_M_facet_unchecked): New member function for use
during construction.
(locale::_Impl::_M_init_extra): New member functions to create second
version of some facets.
(collate, collate_byname): Use abi_tag when new ABI is in use.
* include/bits/locale_facets.h: Add _GLIBCXX_NUM_CXX11_FACETS macro.
(numpunct, numpunct_byname): Use __cxx11 namespace.
(num_get::_M_extract_float, num_get::_M_extract_int): Use abi_tag
when new ABI is in use.
(num_get::__do_get, num_put::__do_put): Do not declare long double
compat functions for new ABI.
* include/bits/locale_facets.tcc (num_get, num_put): Use abi_tag on
definitions.
(numpunct, numpunct_byname): Qualify explicit instantiations.
* include/bits/locale_facets_nonio.h (time_get, time_get_byname,
moneypunct, moneypunct_byname, money_get, money_put, messages,
messages_byname): Use new inline namespace macros.
(money_get::__do_get, money_put::__do_put): Do not declare long
double compat functions for new ABI.
* include/bits/locale_facets_nonio.tcc (money_get, money_put): Use
new namespace macros.
(money_get::__do_get, money_put::__do_put): Do not define for new ABI.
* include/bits/localefwd.h (numpunct, numpunct_byname, collate,
collate_byname, time_get, time_get_byname, moneypunct,
moneypunct_byname, money_get, money_put, messages, messages_byname):
Use new namespace macros.
* include/bits/regex.h: Use inline namespace macros.
* include/bits/stl_list.h (_List_base, list): Use inline namespace
instead of abi-tag.
* include/bits/stringfwd.h (basic_string): Use namespace macros.
* include/std/iosfwd (basic_stringbuf, basic_istringstream,
basic_ostringstream, basic_stringstream): Likewise.
* include/std/sstream: Likewise.
(basic_stringbuf::__xfer_bufptrs): Update streambuf pointers on move.
* include/std/stdexcept (__cow_string, __sso_string): New types for
indirectly using std::string with either ABI.
(logic_error, runtime_error): Replace std::string member with
__cow_string when new ABI is in use. Declare non-inline copy
constructor and assignment operator. Declare const char* constructors.
(domain_error, invalid_argument, length_error, out_of_range,
range_error, overflow_error, underflow_error): Declare const char*
constructors.
* include/std/system_error (error_category): Replace with new
definition in inline namespace _V2.
(error_code::message, error_condition::message): Use abi_tag on
functions returning std::string.
* python/libstdcxx/v6/printers.py (StdStringPrinter): Handle new ABI.
* src/c++11/Makefile.am: Add new files.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/compatibility-c++0x.cc: Compile with old std::string ABI.
Define old error_category symbols.
* src/c++11/cow-fstream-inst.cc: New. Instantiate fstream members
using old std::string ABI.
* src/c++11/cow-locale_init.cc (locale::_Impl::_M_init_extra): Define.
* src/c++11/cow-shim_facets.cc: Define shim facets using old ABI.
* src/c++11/cow-sstream-inst.cc: Instantiate stringstreams using old
std::string ABI.
* src/c++11/cow-stdexcept.cc: Define new constructors and assignment
operators.
(__cow_string, error_category::_M_message): Define.
* src/c++11/cow-string-inst.cc: Explicit instantiations using old
std::string. Include src/c++98/istream-string.cc.
* src/c++11/cow-wstring-inst.cc: Explicit instantiations using old
std::wstring.
* src/c++11/cxx11-hash_tr1.cc: Explicit instantiations using new
string.
* src/c++11/cxx11-ios_failure.cc: Add sanity check.
* src/c++11/cxx11-locale-inst.cc: Instantiate facets using new
std::string.
* src/c++11/cxx11-shim_facets.cc: Define shim facets using new ABI.
* src/c++11/cxx11-stdexcept.cc: Define constructors taking new
std::string.
* src/c++11/cxx11-wlocale-inst.cc: Instantiate facets using
new std::wstring.
* src/c++11/fstream-inst.cc: Compile with new ABI.
* src/c++11/functexcept.cc: Compile with old ABI.
* src/c++11/random.cc: Compile with new ABI.
* src/c++11/sstream-inst.cc: Compile with new ABI.
* src/c++11/string-inst.cc: Explicit instantiations for new string.
* src/c++11/system_error.cc (__sso_string, error_category::_M_message):
Define.
* src/c++11/wstring-inst.cc: Compile with new ABI.
* src/c++98/Makefile.am: Compile some host files twice for old and
new std::string. Add new files.
* src/c++98/Makefile.in: Regenerate.
* src/c++98/compatibility-ldbl.cc: Compile with old ABI.
* src/c++98/compatibility.cc: Likewise.
* src/c++98/concept-inst.cc: Likewise.
* src/c++98/hash_tr1.cc: Likewise.
* src/c++98/istream-string.cc: New file defining functions that
work with istream and std::string moved from ...
* src/c++98/istream.cc: ... here.
* src/c++98/cow-istream-string.cc: Recompile istream-string.cc with
old ABI.
* src/c++98/locale-inst.cc: Adjust facet instantiations to work for
either ABI.
* src/c++98/locale.cc (locale::_M_install_facet,
locale::_M_install_cache): Handle twinned facets.
* src/c++98/locale-facets.cc: Compile with old std::string ABI.
(__verify_grouping): Define new overload and old std::string version.
* src/c++98/locale_init.cc: Initialize twinned facets.
* src/c++98/localename.cc: Likewise.
* src/c++98/misc-inst.cc: Instantiate C++98-only std::string members.
(__verify_grouping): Define new std::string version.
* src/c++98/stdexcept.cc: Compile with old std::string ABI.
* src/c++98/wlocale-inst.cc: Likewise.
* testsuite/18_support/50594.cc: Adjust to work with SSO strings.
* testsuite/21_strings/basic_string/capacity/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/18654.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/2.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc:
Likewise.
* testsuite/21_strings/headers/string/synopsis.cc: Use inline
namespace macros.
* testsuite/23_containers/headers/list/synopsis.cc: Likewise.
* testsuite/27_io/basic_ios/copyfmt/char/1.cc: Set dg-options so
correct exception type can be caught.
* testsuite/27_io/basic_ios/exceptions/char/1.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/char/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/char/12297.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/ios_base/storage/2.cc: Likewise.
* testsuite/27_io/ios_base/failure/cxx11.cc: Disable for old ABI.
* testsuite/ext/profile/mutex_extensions_neg.cc: Adjust dg-error.
* testsuite/libstdc++-prettyprinters/libfundts.cc: Use old ABI.
* testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
* testsuite/util/exception/safety.h: Adjust member function types
for new std::string.
* testsuite/util/testsuite_abi.cc: Add new version and ignore
__float128 symbols in __cxx11 namespace.
From-SVN: r218964
2014-12-19 18:16:39 +00:00
|
|
|
#endif
|
2009-12-17 09:37:16 +00:00
|
|
|
|
2010-11-08 16:07:32 +00:00
|
|
|
// Specialization, as forward_list has erase_after.
|
|
|
|
template<typename _Tp1, typename _Tp2>
|
|
|
|
struct erase_base<std::forward_list<_Tp1, _Tp2>>
|
2010-02-10 16:09:42 +00:00
|
|
|
{
|
2010-11-08 16:07:32 +00:00
|
|
|
typedef std::forward_list<_Tp1, _Tp2> container_type;
|
2010-02-10 16:09:42 +00:00
|
|
|
typedef typename container_type::iterator iterator;
|
|
|
|
typedef typename container_type::const_iterator const_iterator;
|
|
|
|
|
2010-03-09 01:56:42 +00:00
|
|
|
iterator (container_type::* _F_erase_point)(const_iterator);
|
|
|
|
iterator (container_type::* _F_erase_range)(const_iterator,
|
|
|
|
const_iterator);
|
2010-02-10 16:09:42 +00:00
|
|
|
|
|
|
|
erase_base()
|
2010-11-08 16:07:32 +00:00
|
|
|
: _F_erase_point(&container_type::erase_after),
|
|
|
|
_F_erase_range(&container_type::erase_after) { }
|
2010-02-10 16:09:42 +00:00
|
|
|
};
|
|
|
|
|
[multiple changes]
2010-09-29 Paolo Carlini <paolo.carlini@oracle.com>
* include/Makefile.am: Add debug/forward_list.
* include/Makefile.in: Regenerate.
* testsuite/util/testsuite_container_traits.h (traits_base):
Add has_erase_after and hash_insert_after typedefs.
(traits<forward_list<>>): Adjust.
* testsuite/util/exception/safety.h (erase_point, erase_range,
insert_point): Deal correctly with forward_list.
* include/Makefile.am: Add.
2010-09-29 François Dumont <francois.cppdevs@free.fr>
* src/debug.cc: Add forward_list specific debug messages.
* include/debug/forward_list: New.
* include/debug/formatter.h: Add debug message ids and before begin
iterator state.
* include/debug/macros.h (__glibcxx_check_insert_after,
__glibcxx_check_insert_range_after, __glibcxx_check_erase_after,
__glibcxx_check_erase_range_after): Add.
* include/debug/safe_iterator.h (_BeforeBeginHelper): Add.
(_Safe_iterator<>::_M_before_dereferenceable,
_Safe_iterator<>::_M_is_before_begin): Add.
(_Safe_iterator<>::_M_dereferenceable, _Safe_iterator<>::_M_is_end,
_Safe_iterator<>::_M_incrementable): Adjust.
* include/std/forward_list: Include debug/forward when _GLIBCXX_DEBUG
defined.
* include/bits/forward_list.h, forward_list.tcc: Put in std::__norm
when debug mode is active.
* testsuite/23_containers/forward_list/capacity/1.cc: Fix to compile
even in debug mode.
* testsuite/23_containers/forward_list/debug/erase_after1.cc,
erase_after2.cc, erase_after3.cc, erase_after4.cc, erase_after5.cc,
insert_after1.cc,erase_after6.cc, erase_after7.cc, insert_after2.cc,
erase_after8.cc, insert_after3.cc, erase_after9.cc: New.
From-SVN: r164717
2010-09-29 11:56:34 +00:00
|
|
|
template<typename _Tp,
|
|
|
|
bool = traits<_Tp>::has_erase::value,
|
|
|
|
bool = traits<_Tp>::has_erase_after::value>
|
|
|
|
struct erase_point;
|
|
|
|
|
|
|
|
// Specialization for most containers.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct erase_point<_Tp, true, false> : public erase_base<_Tp>
|
2009-12-17 09:37:16 +00:00
|
|
|
{
|
|
|
|
using erase_base<_Tp>::_F_erase_point;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __container)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// NB: Should be equivalent to size() member function, but
|
|
|
|
// computed with begin() and end().
|
|
|
|
const size_type sz = std::distance(__container.begin(),
|
|
|
|
__container.end());
|
|
|
|
|
|
|
|
// NB: Lowest common denominator: use forward iterator operations.
|
|
|
|
auto i = __container.begin();
|
|
|
|
std::advance(i, generate(sz));
|
|
|
|
|
|
|
|
// Makes it easier to think of this as __container.erase(i)
|
|
|
|
(__container.*_F_erase_point)(i);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
[multiple changes]
2010-09-29 Paolo Carlini <paolo.carlini@oracle.com>
* include/Makefile.am: Add debug/forward_list.
* include/Makefile.in: Regenerate.
* testsuite/util/testsuite_container_traits.h (traits_base):
Add has_erase_after and hash_insert_after typedefs.
(traits<forward_list<>>): Adjust.
* testsuite/util/exception/safety.h (erase_point, erase_range,
insert_point): Deal correctly with forward_list.
* include/Makefile.am: Add.
2010-09-29 François Dumont <francois.cppdevs@free.fr>
* src/debug.cc: Add forward_list specific debug messages.
* include/debug/forward_list: New.
* include/debug/formatter.h: Add debug message ids and before begin
iterator state.
* include/debug/macros.h (__glibcxx_check_insert_after,
__glibcxx_check_insert_range_after, __glibcxx_check_erase_after,
__glibcxx_check_erase_range_after): Add.
* include/debug/safe_iterator.h (_BeforeBeginHelper): Add.
(_Safe_iterator<>::_M_before_dereferenceable,
_Safe_iterator<>::_M_is_before_begin): Add.
(_Safe_iterator<>::_M_dereferenceable, _Safe_iterator<>::_M_is_end,
_Safe_iterator<>::_M_incrementable): Adjust.
* include/std/forward_list: Include debug/forward when _GLIBCXX_DEBUG
defined.
* include/bits/forward_list.h, forward_list.tcc: Put in std::__norm
when debug mode is active.
* testsuite/23_containers/forward_list/capacity/1.cc: Fix to compile
even in debug mode.
* testsuite/23_containers/forward_list/debug/erase_after1.cc,
erase_after2.cc, erase_after3.cc, erase_after4.cc, erase_after5.cc,
insert_after1.cc,erase_after6.cc, erase_after7.cc, insert_after2.cc,
erase_after8.cc, insert_after3.cc, erase_after9.cc: New.
From-SVN: r164717
2010-09-29 11:56:34 +00:00
|
|
|
// Specialization for forward_list.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct erase_point<_Tp, false, true> : public erase_base<_Tp>
|
|
|
|
{
|
|
|
|
using erase_base<_Tp>::_F_erase_point;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __container)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// NB: Should be equivalent to size() member function, but
|
|
|
|
// computed with begin() and end().
|
|
|
|
const size_type sz = std::distance(__container.begin(),
|
|
|
|
__container.end());
|
|
|
|
|
|
|
|
// NB: Lowest common denominator: use forward iterator operations.
|
|
|
|
auto i = __container.before_begin();
|
|
|
|
std::advance(i, generate(sz));
|
|
|
|
|
|
|
|
// Makes it easier to think of this as __container.erase(i)
|
|
|
|
(__container.*_F_erase_point)(i);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-12-17 09:37:16 +00:00
|
|
|
// Specialization, empty.
|
|
|
|
template<typename _Tp>
|
[multiple changes]
2010-09-29 Paolo Carlini <paolo.carlini@oracle.com>
* include/Makefile.am: Add debug/forward_list.
* include/Makefile.in: Regenerate.
* testsuite/util/testsuite_container_traits.h (traits_base):
Add has_erase_after and hash_insert_after typedefs.
(traits<forward_list<>>): Adjust.
* testsuite/util/exception/safety.h (erase_point, erase_range,
insert_point): Deal correctly with forward_list.
* include/Makefile.am: Add.
2010-09-29 François Dumont <francois.cppdevs@free.fr>
* src/debug.cc: Add forward_list specific debug messages.
* include/debug/forward_list: New.
* include/debug/formatter.h: Add debug message ids and before begin
iterator state.
* include/debug/macros.h (__glibcxx_check_insert_after,
__glibcxx_check_insert_range_after, __glibcxx_check_erase_after,
__glibcxx_check_erase_range_after): Add.
* include/debug/safe_iterator.h (_BeforeBeginHelper): Add.
(_Safe_iterator<>::_M_before_dereferenceable,
_Safe_iterator<>::_M_is_before_begin): Add.
(_Safe_iterator<>::_M_dereferenceable, _Safe_iterator<>::_M_is_end,
_Safe_iterator<>::_M_incrementable): Adjust.
* include/std/forward_list: Include debug/forward when _GLIBCXX_DEBUG
defined.
* include/bits/forward_list.h, forward_list.tcc: Put in std::__norm
when debug mode is active.
* testsuite/23_containers/forward_list/capacity/1.cc: Fix to compile
even in debug mode.
* testsuite/23_containers/forward_list/debug/erase_after1.cc,
erase_after2.cc, erase_after3.cc, erase_after4.cc, erase_after5.cc,
insert_after1.cc,erase_after6.cc, erase_after7.cc, insert_after2.cc,
erase_after8.cc, insert_after3.cc, erase_after9.cc: New.
From-SVN: r164717
2010-09-29 11:56:34 +00:00
|
|
|
struct erase_point<_Tp, false, false>
|
2009-12-17 09:37:16 +00:00
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp&) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
[multiple changes]
2010-09-29 Paolo Carlini <paolo.carlini@oracle.com>
* include/Makefile.am: Add debug/forward_list.
* include/Makefile.in: Regenerate.
* testsuite/util/testsuite_container_traits.h (traits_base):
Add has_erase_after and hash_insert_after typedefs.
(traits<forward_list<>>): Adjust.
* testsuite/util/exception/safety.h (erase_point, erase_range,
insert_point): Deal correctly with forward_list.
* include/Makefile.am: Add.
2010-09-29 François Dumont <francois.cppdevs@free.fr>
* src/debug.cc: Add forward_list specific debug messages.
* include/debug/forward_list: New.
* include/debug/formatter.h: Add debug message ids and before begin
iterator state.
* include/debug/macros.h (__glibcxx_check_insert_after,
__glibcxx_check_insert_range_after, __glibcxx_check_erase_after,
__glibcxx_check_erase_range_after): Add.
* include/debug/safe_iterator.h (_BeforeBeginHelper): Add.
(_Safe_iterator<>::_M_before_dereferenceable,
_Safe_iterator<>::_M_is_before_begin): Add.
(_Safe_iterator<>::_M_dereferenceable, _Safe_iterator<>::_M_is_end,
_Safe_iterator<>::_M_incrementable): Adjust.
* include/std/forward_list: Include debug/forward when _GLIBCXX_DEBUG
defined.
* include/bits/forward_list.h, forward_list.tcc: Put in std::__norm
when debug mode is active.
* testsuite/23_containers/forward_list/capacity/1.cc: Fix to compile
even in debug mode.
* testsuite/23_containers/forward_list/debug/erase_after1.cc,
erase_after2.cc, erase_after3.cc, erase_after4.cc, erase_after5.cc,
insert_after1.cc,erase_after6.cc, erase_after7.cc, insert_after2.cc,
erase_after8.cc, insert_after3.cc, erase_after9.cc: New.
From-SVN: r164717
2010-09-29 11:56:34 +00:00
|
|
|
template<typename _Tp,
|
|
|
|
bool = traits<_Tp>::has_erase::value,
|
|
|
|
bool = traits<_Tp>::has_erase_after::value>
|
|
|
|
struct erase_range;
|
|
|
|
|
|
|
|
// Specialization for most containers.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct erase_range<_Tp, true, false> : public erase_base<_Tp>
|
2009-12-17 09:37:16 +00:00
|
|
|
{
|
|
|
|
using erase_base<_Tp>::_F_erase_range;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __container)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const size_type sz = std::distance(__container.begin(),
|
|
|
|
__container.end());
|
|
|
|
size_type s1 = generate(sz);
|
|
|
|
size_type s2 = generate(sz);
|
|
|
|
auto i1 = __container.begin();
|
|
|
|
auto i2 = __container.begin();
|
|
|
|
std::advance(i1, std::min(s1, s2));
|
|
|
|
std::advance(i2, std::max(s1, s2));
|
|
|
|
|
|
|
|
// Makes it easier to think of this as __container.erase(i1, i2).
|
|
|
|
(__container.*_F_erase_range)(i1, i2);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
[multiple changes]
2010-09-29 Paolo Carlini <paolo.carlini@oracle.com>
* include/Makefile.am: Add debug/forward_list.
* include/Makefile.in: Regenerate.
* testsuite/util/testsuite_container_traits.h (traits_base):
Add has_erase_after and hash_insert_after typedefs.
(traits<forward_list<>>): Adjust.
* testsuite/util/exception/safety.h (erase_point, erase_range,
insert_point): Deal correctly with forward_list.
* include/Makefile.am: Add.
2010-09-29 François Dumont <francois.cppdevs@free.fr>
* src/debug.cc: Add forward_list specific debug messages.
* include/debug/forward_list: New.
* include/debug/formatter.h: Add debug message ids and before begin
iterator state.
* include/debug/macros.h (__glibcxx_check_insert_after,
__glibcxx_check_insert_range_after, __glibcxx_check_erase_after,
__glibcxx_check_erase_range_after): Add.
* include/debug/safe_iterator.h (_BeforeBeginHelper): Add.
(_Safe_iterator<>::_M_before_dereferenceable,
_Safe_iterator<>::_M_is_before_begin): Add.
(_Safe_iterator<>::_M_dereferenceable, _Safe_iterator<>::_M_is_end,
_Safe_iterator<>::_M_incrementable): Adjust.
* include/std/forward_list: Include debug/forward when _GLIBCXX_DEBUG
defined.
* include/bits/forward_list.h, forward_list.tcc: Put in std::__norm
when debug mode is active.
* testsuite/23_containers/forward_list/capacity/1.cc: Fix to compile
even in debug mode.
* testsuite/23_containers/forward_list/debug/erase_after1.cc,
erase_after2.cc, erase_after3.cc, erase_after4.cc, erase_after5.cc,
insert_after1.cc,erase_after6.cc, erase_after7.cc, insert_after2.cc,
erase_after8.cc, insert_after3.cc, erase_after9.cc: New.
From-SVN: r164717
2010-09-29 11:56:34 +00:00
|
|
|
// Specialization for forward_list.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct erase_range<_Tp, false, true> : public erase_base<_Tp>
|
|
|
|
{
|
|
|
|
using erase_base<_Tp>::_F_erase_range;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __container)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const size_type sz = std::distance(__container.begin(),
|
|
|
|
__container.end());
|
|
|
|
size_type s1 = generate(sz);
|
|
|
|
size_type s2 = generate(sz);
|
|
|
|
auto i1 = __container.before_begin();
|
|
|
|
auto i2 = __container.before_begin();
|
|
|
|
std::advance(i1, std::min(s1, s2));
|
|
|
|
std::advance(i2, std::max(s1, s2));
|
|
|
|
|
|
|
|
// Makes it easier to think of this as __container.erase(i1, i2).
|
|
|
|
(__container.*_F_erase_range)(i1, i2);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-12-17 09:37:16 +00:00
|
|
|
// Specialization, empty.
|
|
|
|
template<typename _Tp>
|
[multiple changes]
2010-09-29 Paolo Carlini <paolo.carlini@oracle.com>
* include/Makefile.am: Add debug/forward_list.
* include/Makefile.in: Regenerate.
* testsuite/util/testsuite_container_traits.h (traits_base):
Add has_erase_after and hash_insert_after typedefs.
(traits<forward_list<>>): Adjust.
* testsuite/util/exception/safety.h (erase_point, erase_range,
insert_point): Deal correctly with forward_list.
* include/Makefile.am: Add.
2010-09-29 François Dumont <francois.cppdevs@free.fr>
* src/debug.cc: Add forward_list specific debug messages.
* include/debug/forward_list: New.
* include/debug/formatter.h: Add debug message ids and before begin
iterator state.
* include/debug/macros.h (__glibcxx_check_insert_after,
__glibcxx_check_insert_range_after, __glibcxx_check_erase_after,
__glibcxx_check_erase_range_after): Add.
* include/debug/safe_iterator.h (_BeforeBeginHelper): Add.
(_Safe_iterator<>::_M_before_dereferenceable,
_Safe_iterator<>::_M_is_before_begin): Add.
(_Safe_iterator<>::_M_dereferenceable, _Safe_iterator<>::_M_is_end,
_Safe_iterator<>::_M_incrementable): Adjust.
* include/std/forward_list: Include debug/forward when _GLIBCXX_DEBUG
defined.
* include/bits/forward_list.h, forward_list.tcc: Put in std::__norm
when debug mode is active.
* testsuite/23_containers/forward_list/capacity/1.cc: Fix to compile
even in debug mode.
* testsuite/23_containers/forward_list/debug/erase_after1.cc,
erase_after2.cc, erase_after3.cc, erase_after4.cc, erase_after5.cc,
insert_after1.cc,erase_after6.cc, erase_after7.cc, insert_after2.cc,
erase_after8.cc, insert_after3.cc, erase_after9.cc: New.
From-SVN: r164717
2010-09-29 11:56:34 +00:00
|
|
|
struct erase_range<_Tp, false, false>
|
2009-12-17 09:37:16 +00:00
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp&) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<typename _Tp, bool = traits<_Tp>::has_push_pop::value>
|
|
|
|
struct pop_front
|
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp& __container)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
__container.pop_front();
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Specialization, empty.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct pop_front<_Tp, false>
|
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp&) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<typename _Tp, bool = traits<_Tp>::has_push_pop::value
|
|
|
|
&& traits<_Tp>::is_reversible::value>
|
|
|
|
struct pop_back
|
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp& __container)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
__container.pop_back();
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Specialization, empty.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct pop_back<_Tp, false>
|
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp&) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<typename _Tp, bool = traits<_Tp>::has_push_pop::value>
|
|
|
|
struct push_front
|
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef typename container_type::value_type value_type;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
__test.push_front(cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assumes containers start out equivalent.
|
|
|
|
void
|
|
|
|
operator()(_Tp& __control, _Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
__test.push_front(cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Specialization, empty.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct push_front<_Tp, false>
|
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp&) { }
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp&, _Tp&) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<typename _Tp, bool = traits<_Tp>::has_push_pop::value
|
|
|
|
&& traits<_Tp>::is_reversible::value>
|
|
|
|
struct push_back
|
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef typename container_type::value_type value_type;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
__test.push_back(cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assumes containers start out equivalent.
|
|
|
|
void
|
|
|
|
operator()(_Tp& __control, _Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
__test.push_back(cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Specialization, empty.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct push_back<_Tp, false>
|
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp&) { }
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp&, _Tp&) { }
|
|
|
|
};
|
|
|
|
|
2012-11-05 20:58:35 +00:00
|
|
|
template<typename _Tp, bool = traits<_Tp>::has_push_pop::value
|
|
|
|
&& traits<_Tp>::has_emplace::value>
|
|
|
|
struct emplace_front
|
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef typename container_type::value_type value_type;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
__test.emplace_front(cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assumes containers start out equivalent.
|
|
|
|
void
|
|
|
|
operator()(_Tp& __control, _Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
__test.emplace_front(cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Specialization, empty.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct emplace_front<_Tp, false>
|
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp&) { }
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp&, _Tp&) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<typename _Tp, bool = traits<_Tp>::has_push_pop::value
|
|
|
|
&& traits<_Tp>::has_emplace::value
|
|
|
|
&& traits<_Tp>::is_reversible::value>
|
|
|
|
struct emplace_back
|
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef typename container_type::value_type value_type;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
__test.emplace_back(cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assumes containers start out equivalent.
|
|
|
|
void
|
|
|
|
operator()(_Tp& __control, _Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
__test.push_back(cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Specialization, empty.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct emplace_back<_Tp, false>
|
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp&) { }
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp&, _Tp&) { }
|
|
|
|
};
|
|
|
|
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
// Abstract the insert function into two parts:
|
|
|
|
// 1, insert_base_functions == holds function pointer
|
|
|
|
// 2, insert_base == links function pointer to class insert method
|
|
|
|
template<typename _Tp>
|
|
|
|
struct insert_base
|
|
|
|
{
|
|
|
|
typedef typename _Tp::iterator iterator;
|
2010-11-08 16:07:32 +00:00
|
|
|
typedef typename _Tp::const_iterator const_iterator;
|
2009-12-17 09:37:16 +00:00
|
|
|
typedef typename _Tp::value_type value_type;
|
|
|
|
|
2010-11-08 16:07:32 +00:00
|
|
|
iterator (_Tp::* _F_insert_point)(const_iterator, const value_type&);
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
insert_base() : _F_insert_point(&_Tp::insert) { }
|
|
|
|
};
|
|
|
|
|
stl_deque.h (deque<>::insert(iterator, const value_type&), [...]): Adjust C++11 signatures to take a const_iterator.
2013-06-27 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_deque.h (deque<>::insert(iterator,
const value_type&), deque<>::insert(iterator, value_type&&),
deque<>::emplace(iterator, _Args&&...)): Adjust C++11 signatures to
take a const_iterator.
(deque<>::erase): Simplify.
* include/bits/stl_list.h: Likewise.
(_List_iterator<>::_M_const_cast): Add.
* include/bits/stl_vector.h: Likewise.
* include/bits/stl_bvector.h: Likewise.
(_Bit_iterator::_M_const_cast): Add.
* include/bits/deque.tcc: Adjust definitions.
* include/bits/list.tcc: Likewise.
* include/bits/vector.tcc: Likewise.
* include/bits/stl_iterator.h (__normal_iterator<>::_M_const_cast):
Define trivial version in C++98 mode.
* include/ext/vstring.h (__versa_string<>::insert(iterator, _CharT),
__versa_string<>::replace(iterator, iterator, const __versa_string&),
__versa_string<>::replace(iterator, iterator, const _CharT*,
size_type), __versa_string<>::replace(iterator, iterator,
const _CharT*), __versa_string<>::replace(iterator, iterator,
size_type, _CharT)): Adjust C++11 signatures to take a pair of
const_iterators.
* include/debug/deque: Adjust.
* include/debug/list: Likewise.
* include/debug/vector: Likewise.
* include/profile/deque: Likewise.
* include/profile/list: Likewise.
* include/profile/vector: Likewise.
(vector<>::emplace): Add.
* testsuite/util/exception/safety.h: Update.
* testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc:
New.
* testsuite/23_containers/deque/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/23_containers/list/modifiers/emplace/const_iterator.cc:
Likewise.
* testsuite/23_containers/list/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/23_containers/vector/bool/modifiers/insert/
const_iterator.cc: Likewise.
* testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc:
Likewise.
* testsuite/23_containers/vector/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/char/54577.cc: Move to testsuite/
ext/vstring/modifiers/erase/char/.
* testsuite/ext/vstring/modifiers/wchar_t/54577.cc: Move to testsuite/
ext/vstring/modifiers/wchar_t/.
* testsuite/ext/vstring/modifiers/char/pop_back.cc: Move to testsuite/
ext/vstring/modifiers/pop_back/char/.
* testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc: Move to
testsuite/ext/vstring/modifiers/pop_back/wchar_t/.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/assign_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.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.
From-SVN: r200458
2013-06-27 09:51:21 +00:00
|
|
|
// Specialization, old C++03 signature.
|
2010-11-08 16:07:32 +00:00
|
|
|
template<typename _Tp1, typename _Tp2, typename _Tp3>
|
|
|
|
struct insert_base<std::basic_string<_Tp1, _Tp2, _Tp3>>
|
2010-02-10 16:09:42 +00:00
|
|
|
{
|
2010-11-08 16:07:32 +00:00
|
|
|
typedef std::basic_string<_Tp1, _Tp2, _Tp3> container_type;
|
2010-02-10 16:09:42 +00:00
|
|
|
typedef typename container_type::iterator iterator;
|
New std::string implementation.
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_CXX11_ABI): Remove.
(GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI, GLIBCXX_DEFAULT_ABI): Add.
* configure.ac: Use new macros.
* configure: Regenerate.
* Makefile.in: Regenerate.
* doc/Makefile.in: Regenerate.
* libsupc++/Makefile.in: Regenerate.
* po/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
* include/Makefile.am: Set _GLIBCXX_USE_DUAL_ABI.
* include/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Export symbols related to new std::string.
Tighten old patterns to not match new symbols.
* config/locale/generic/monetary_members.cc: Guard some definitions
to not compile with new ABI.
* config/locale/gnu/monetary_members.cc: Likewise.
* config/locale/gnu/numeric_members.cc: Prevent double-free.
* config/os/gnu-linux/ldbl-extra.ver: Add new __gnu_cxx_ldbl128
exports. Tighten old patterns.
* doc/xml/manual/configure.xml: Document new configure options.
* doc/html/*: Regenerate.
* include/bits/basic_string.h (__cxx11::basic_string): Define new
non-reference-counted implementation in inline namespace __cxx11.
(stoi, stol, stoll, stof, stod, stold, to_string): Conditionally use
inline namespace.
(literals::string_literals::operator"): Conditionally use abi-tag.
* include/bits/basic_string.tcc (__cxx11::basic_string): Define.
* include/bits/c++config: Define _GLIBCXX_USE_DUAL_ABI and
LDBL_CXX11_ABI namespace macros.
* include/bits/locale_classes.h (locale::name()): Use abi_tag when
new ABI is in use.
(locale::_S_twinned_facets): New static member.
(locale::facet::__shim): Declare new type.
(locale::_facet::_M_sso_shim, locale::_facet::_M_cow_shim): New
functions for creating shims.
(locale::_Impl::_M_facet_unchecked): New member function for use
during construction.
(locale::_Impl::_M_init_extra): New member functions to create second
version of some facets.
(collate, collate_byname): Use abi_tag when new ABI is in use.
* include/bits/locale_facets.h: Add _GLIBCXX_NUM_CXX11_FACETS macro.
(numpunct, numpunct_byname): Use __cxx11 namespace.
(num_get::_M_extract_float, num_get::_M_extract_int): Use abi_tag
when new ABI is in use.
(num_get::__do_get, num_put::__do_put): Do not declare long double
compat functions for new ABI.
* include/bits/locale_facets.tcc (num_get, num_put): Use abi_tag on
definitions.
(numpunct, numpunct_byname): Qualify explicit instantiations.
* include/bits/locale_facets_nonio.h (time_get, time_get_byname,
moneypunct, moneypunct_byname, money_get, money_put, messages,
messages_byname): Use new inline namespace macros.
(money_get::__do_get, money_put::__do_put): Do not declare long
double compat functions for new ABI.
* include/bits/locale_facets_nonio.tcc (money_get, money_put): Use
new namespace macros.
(money_get::__do_get, money_put::__do_put): Do not define for new ABI.
* include/bits/localefwd.h (numpunct, numpunct_byname, collate,
collate_byname, time_get, time_get_byname, moneypunct,
moneypunct_byname, money_get, money_put, messages, messages_byname):
Use new namespace macros.
* include/bits/regex.h: Use inline namespace macros.
* include/bits/stl_list.h (_List_base, list): Use inline namespace
instead of abi-tag.
* include/bits/stringfwd.h (basic_string): Use namespace macros.
* include/std/iosfwd (basic_stringbuf, basic_istringstream,
basic_ostringstream, basic_stringstream): Likewise.
* include/std/sstream: Likewise.
(basic_stringbuf::__xfer_bufptrs): Update streambuf pointers on move.
* include/std/stdexcept (__cow_string, __sso_string): New types for
indirectly using std::string with either ABI.
(logic_error, runtime_error): Replace std::string member with
__cow_string when new ABI is in use. Declare non-inline copy
constructor and assignment operator. Declare const char* constructors.
(domain_error, invalid_argument, length_error, out_of_range,
range_error, overflow_error, underflow_error): Declare const char*
constructors.
* include/std/system_error (error_category): Replace with new
definition in inline namespace _V2.
(error_code::message, error_condition::message): Use abi_tag on
functions returning std::string.
* python/libstdcxx/v6/printers.py (StdStringPrinter): Handle new ABI.
* src/c++11/Makefile.am: Add new files.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/compatibility-c++0x.cc: Compile with old std::string ABI.
Define old error_category symbols.
* src/c++11/cow-fstream-inst.cc: New. Instantiate fstream members
using old std::string ABI.
* src/c++11/cow-locale_init.cc (locale::_Impl::_M_init_extra): Define.
* src/c++11/cow-shim_facets.cc: Define shim facets using old ABI.
* src/c++11/cow-sstream-inst.cc: Instantiate stringstreams using old
std::string ABI.
* src/c++11/cow-stdexcept.cc: Define new constructors and assignment
operators.
(__cow_string, error_category::_M_message): Define.
* src/c++11/cow-string-inst.cc: Explicit instantiations using old
std::string. Include src/c++98/istream-string.cc.
* src/c++11/cow-wstring-inst.cc: Explicit instantiations using old
std::wstring.
* src/c++11/cxx11-hash_tr1.cc: Explicit instantiations using new
string.
* src/c++11/cxx11-ios_failure.cc: Add sanity check.
* src/c++11/cxx11-locale-inst.cc: Instantiate facets using new
std::string.
* src/c++11/cxx11-shim_facets.cc: Define shim facets using new ABI.
* src/c++11/cxx11-stdexcept.cc: Define constructors taking new
std::string.
* src/c++11/cxx11-wlocale-inst.cc: Instantiate facets using
new std::wstring.
* src/c++11/fstream-inst.cc: Compile with new ABI.
* src/c++11/functexcept.cc: Compile with old ABI.
* src/c++11/random.cc: Compile with new ABI.
* src/c++11/sstream-inst.cc: Compile with new ABI.
* src/c++11/string-inst.cc: Explicit instantiations for new string.
* src/c++11/system_error.cc (__sso_string, error_category::_M_message):
Define.
* src/c++11/wstring-inst.cc: Compile with new ABI.
* src/c++98/Makefile.am: Compile some host files twice for old and
new std::string. Add new files.
* src/c++98/Makefile.in: Regenerate.
* src/c++98/compatibility-ldbl.cc: Compile with old ABI.
* src/c++98/compatibility.cc: Likewise.
* src/c++98/concept-inst.cc: Likewise.
* src/c++98/hash_tr1.cc: Likewise.
* src/c++98/istream-string.cc: New file defining functions that
work with istream and std::string moved from ...
* src/c++98/istream.cc: ... here.
* src/c++98/cow-istream-string.cc: Recompile istream-string.cc with
old ABI.
* src/c++98/locale-inst.cc: Adjust facet instantiations to work for
either ABI.
* src/c++98/locale.cc (locale::_M_install_facet,
locale::_M_install_cache): Handle twinned facets.
* src/c++98/locale-facets.cc: Compile with old std::string ABI.
(__verify_grouping): Define new overload and old std::string version.
* src/c++98/locale_init.cc: Initialize twinned facets.
* src/c++98/localename.cc: Likewise.
* src/c++98/misc-inst.cc: Instantiate C++98-only std::string members.
(__verify_grouping): Define new std::string version.
* src/c++98/stdexcept.cc: Compile with old std::string ABI.
* src/c++98/wlocale-inst.cc: Likewise.
* testsuite/18_support/50594.cc: Adjust to work with SSO strings.
* testsuite/21_strings/basic_string/capacity/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/18654.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/2.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc:
Likewise.
* testsuite/21_strings/headers/string/synopsis.cc: Use inline
namespace macros.
* testsuite/23_containers/headers/list/synopsis.cc: Likewise.
* testsuite/27_io/basic_ios/copyfmt/char/1.cc: Set dg-options so
correct exception type can be caught.
* testsuite/27_io/basic_ios/exceptions/char/1.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/char/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/char/12297.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/ios_base/storage/2.cc: Likewise.
* testsuite/27_io/ios_base/failure/cxx11.cc: Disable for old ABI.
* testsuite/ext/profile/mutex_extensions_neg.cc: Adjust dg-error.
* testsuite/libstdc++-prettyprinters/libfundts.cc: Use old ABI.
* testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
* testsuite/util/exception/safety.h: Adjust member function types
for new std::string.
* testsuite/util/testsuite_abi.cc: Add new version and ignore
__float128 symbols in __cxx11 namespace.
From-SVN: r218964
2014-12-19 18:16:39 +00:00
|
|
|
typedef typename container_type::const_iterator const_iterator;
|
2010-02-10 16:09:42 +00:00
|
|
|
typedef typename container_type::value_type value_type;
|
|
|
|
|
New std::string implementation.
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_CXX11_ABI): Remove.
(GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI, GLIBCXX_DEFAULT_ABI): Add.
* configure.ac: Use new macros.
* configure: Regenerate.
* Makefile.in: Regenerate.
* doc/Makefile.in: Regenerate.
* libsupc++/Makefile.in: Regenerate.
* po/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
* include/Makefile.am: Set _GLIBCXX_USE_DUAL_ABI.
* include/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Export symbols related to new std::string.
Tighten old patterns to not match new symbols.
* config/locale/generic/monetary_members.cc: Guard some definitions
to not compile with new ABI.
* config/locale/gnu/monetary_members.cc: Likewise.
* config/locale/gnu/numeric_members.cc: Prevent double-free.
* config/os/gnu-linux/ldbl-extra.ver: Add new __gnu_cxx_ldbl128
exports. Tighten old patterns.
* doc/xml/manual/configure.xml: Document new configure options.
* doc/html/*: Regenerate.
* include/bits/basic_string.h (__cxx11::basic_string): Define new
non-reference-counted implementation in inline namespace __cxx11.
(stoi, stol, stoll, stof, stod, stold, to_string): Conditionally use
inline namespace.
(literals::string_literals::operator"): Conditionally use abi-tag.
* include/bits/basic_string.tcc (__cxx11::basic_string): Define.
* include/bits/c++config: Define _GLIBCXX_USE_DUAL_ABI and
LDBL_CXX11_ABI namespace macros.
* include/bits/locale_classes.h (locale::name()): Use abi_tag when
new ABI is in use.
(locale::_S_twinned_facets): New static member.
(locale::facet::__shim): Declare new type.
(locale::_facet::_M_sso_shim, locale::_facet::_M_cow_shim): New
functions for creating shims.
(locale::_Impl::_M_facet_unchecked): New member function for use
during construction.
(locale::_Impl::_M_init_extra): New member functions to create second
version of some facets.
(collate, collate_byname): Use abi_tag when new ABI is in use.
* include/bits/locale_facets.h: Add _GLIBCXX_NUM_CXX11_FACETS macro.
(numpunct, numpunct_byname): Use __cxx11 namespace.
(num_get::_M_extract_float, num_get::_M_extract_int): Use abi_tag
when new ABI is in use.
(num_get::__do_get, num_put::__do_put): Do not declare long double
compat functions for new ABI.
* include/bits/locale_facets.tcc (num_get, num_put): Use abi_tag on
definitions.
(numpunct, numpunct_byname): Qualify explicit instantiations.
* include/bits/locale_facets_nonio.h (time_get, time_get_byname,
moneypunct, moneypunct_byname, money_get, money_put, messages,
messages_byname): Use new inline namespace macros.
(money_get::__do_get, money_put::__do_put): Do not declare long
double compat functions for new ABI.
* include/bits/locale_facets_nonio.tcc (money_get, money_put): Use
new namespace macros.
(money_get::__do_get, money_put::__do_put): Do not define for new ABI.
* include/bits/localefwd.h (numpunct, numpunct_byname, collate,
collate_byname, time_get, time_get_byname, moneypunct,
moneypunct_byname, money_get, money_put, messages, messages_byname):
Use new namespace macros.
* include/bits/regex.h: Use inline namespace macros.
* include/bits/stl_list.h (_List_base, list): Use inline namespace
instead of abi-tag.
* include/bits/stringfwd.h (basic_string): Use namespace macros.
* include/std/iosfwd (basic_stringbuf, basic_istringstream,
basic_ostringstream, basic_stringstream): Likewise.
* include/std/sstream: Likewise.
(basic_stringbuf::__xfer_bufptrs): Update streambuf pointers on move.
* include/std/stdexcept (__cow_string, __sso_string): New types for
indirectly using std::string with either ABI.
(logic_error, runtime_error): Replace std::string member with
__cow_string when new ABI is in use. Declare non-inline copy
constructor and assignment operator. Declare const char* constructors.
(domain_error, invalid_argument, length_error, out_of_range,
range_error, overflow_error, underflow_error): Declare const char*
constructors.
* include/std/system_error (error_category): Replace with new
definition in inline namespace _V2.
(error_code::message, error_condition::message): Use abi_tag on
functions returning std::string.
* python/libstdcxx/v6/printers.py (StdStringPrinter): Handle new ABI.
* src/c++11/Makefile.am: Add new files.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/compatibility-c++0x.cc: Compile with old std::string ABI.
Define old error_category symbols.
* src/c++11/cow-fstream-inst.cc: New. Instantiate fstream members
using old std::string ABI.
* src/c++11/cow-locale_init.cc (locale::_Impl::_M_init_extra): Define.
* src/c++11/cow-shim_facets.cc: Define shim facets using old ABI.
* src/c++11/cow-sstream-inst.cc: Instantiate stringstreams using old
std::string ABI.
* src/c++11/cow-stdexcept.cc: Define new constructors and assignment
operators.
(__cow_string, error_category::_M_message): Define.
* src/c++11/cow-string-inst.cc: Explicit instantiations using old
std::string. Include src/c++98/istream-string.cc.
* src/c++11/cow-wstring-inst.cc: Explicit instantiations using old
std::wstring.
* src/c++11/cxx11-hash_tr1.cc: Explicit instantiations using new
string.
* src/c++11/cxx11-ios_failure.cc: Add sanity check.
* src/c++11/cxx11-locale-inst.cc: Instantiate facets using new
std::string.
* src/c++11/cxx11-shim_facets.cc: Define shim facets using new ABI.
* src/c++11/cxx11-stdexcept.cc: Define constructors taking new
std::string.
* src/c++11/cxx11-wlocale-inst.cc: Instantiate facets using
new std::wstring.
* src/c++11/fstream-inst.cc: Compile with new ABI.
* src/c++11/functexcept.cc: Compile with old ABI.
* src/c++11/random.cc: Compile with new ABI.
* src/c++11/sstream-inst.cc: Compile with new ABI.
* src/c++11/string-inst.cc: Explicit instantiations for new string.
* src/c++11/system_error.cc (__sso_string, error_category::_M_message):
Define.
* src/c++11/wstring-inst.cc: Compile with new ABI.
* src/c++98/Makefile.am: Compile some host files twice for old and
new std::string. Add new files.
* src/c++98/Makefile.in: Regenerate.
* src/c++98/compatibility-ldbl.cc: Compile with old ABI.
* src/c++98/compatibility.cc: Likewise.
* src/c++98/concept-inst.cc: Likewise.
* src/c++98/hash_tr1.cc: Likewise.
* src/c++98/istream-string.cc: New file defining functions that
work with istream and std::string moved from ...
* src/c++98/istream.cc: ... here.
* src/c++98/cow-istream-string.cc: Recompile istream-string.cc with
old ABI.
* src/c++98/locale-inst.cc: Adjust facet instantiations to work for
either ABI.
* src/c++98/locale.cc (locale::_M_install_facet,
locale::_M_install_cache): Handle twinned facets.
* src/c++98/locale-facets.cc: Compile with old std::string ABI.
(__verify_grouping): Define new overload and old std::string version.
* src/c++98/locale_init.cc: Initialize twinned facets.
* src/c++98/localename.cc: Likewise.
* src/c++98/misc-inst.cc: Instantiate C++98-only std::string members.
(__verify_grouping): Define new std::string version.
* src/c++98/stdexcept.cc: Compile with old std::string ABI.
* src/c++98/wlocale-inst.cc: Likewise.
* testsuite/18_support/50594.cc: Adjust to work with SSO strings.
* testsuite/21_strings/basic_string/capacity/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/18654.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/2.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc:
Likewise.
* testsuite/21_strings/headers/string/synopsis.cc: Use inline
namespace macros.
* testsuite/23_containers/headers/list/synopsis.cc: Likewise.
* testsuite/27_io/basic_ios/copyfmt/char/1.cc: Set dg-options so
correct exception type can be caught.
* testsuite/27_io/basic_ios/exceptions/char/1.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/char/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/char/12297.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/ios_base/storage/2.cc: Likewise.
* testsuite/27_io/ios_base/failure/cxx11.cc: Disable for old ABI.
* testsuite/ext/profile/mutex_extensions_neg.cc: Adjust dg-error.
* testsuite/libstdc++-prettyprinters/libfundts.cc: Use old ABI.
* testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
* testsuite/util/exception/safety.h: Adjust member function types
for new std::string.
* testsuite/util/testsuite_abi.cc: Add new version and ignore
__float128 symbols in __cxx11 namespace.
From-SVN: r218964
2014-12-19 18:16:39 +00:00
|
|
|
#if _GLIBCXX_USE_CXX11_ABI == 0 || __cplusplus < 201103L
|
2010-11-08 16:07:32 +00:00
|
|
|
iterator (container_type::* _F_insert_point)(iterator, value_type);
|
New std::string implementation.
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_CXX11_ABI): Remove.
(GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI, GLIBCXX_DEFAULT_ABI): Add.
* configure.ac: Use new macros.
* configure: Regenerate.
* Makefile.in: Regenerate.
* doc/Makefile.in: Regenerate.
* libsupc++/Makefile.in: Regenerate.
* po/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
* include/Makefile.am: Set _GLIBCXX_USE_DUAL_ABI.
* include/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Export symbols related to new std::string.
Tighten old patterns to not match new symbols.
* config/locale/generic/monetary_members.cc: Guard some definitions
to not compile with new ABI.
* config/locale/gnu/monetary_members.cc: Likewise.
* config/locale/gnu/numeric_members.cc: Prevent double-free.
* config/os/gnu-linux/ldbl-extra.ver: Add new __gnu_cxx_ldbl128
exports. Tighten old patterns.
* doc/xml/manual/configure.xml: Document new configure options.
* doc/html/*: Regenerate.
* include/bits/basic_string.h (__cxx11::basic_string): Define new
non-reference-counted implementation in inline namespace __cxx11.
(stoi, stol, stoll, stof, stod, stold, to_string): Conditionally use
inline namespace.
(literals::string_literals::operator"): Conditionally use abi-tag.
* include/bits/basic_string.tcc (__cxx11::basic_string): Define.
* include/bits/c++config: Define _GLIBCXX_USE_DUAL_ABI and
LDBL_CXX11_ABI namespace macros.
* include/bits/locale_classes.h (locale::name()): Use abi_tag when
new ABI is in use.
(locale::_S_twinned_facets): New static member.
(locale::facet::__shim): Declare new type.
(locale::_facet::_M_sso_shim, locale::_facet::_M_cow_shim): New
functions for creating shims.
(locale::_Impl::_M_facet_unchecked): New member function for use
during construction.
(locale::_Impl::_M_init_extra): New member functions to create second
version of some facets.
(collate, collate_byname): Use abi_tag when new ABI is in use.
* include/bits/locale_facets.h: Add _GLIBCXX_NUM_CXX11_FACETS macro.
(numpunct, numpunct_byname): Use __cxx11 namespace.
(num_get::_M_extract_float, num_get::_M_extract_int): Use abi_tag
when new ABI is in use.
(num_get::__do_get, num_put::__do_put): Do not declare long double
compat functions for new ABI.
* include/bits/locale_facets.tcc (num_get, num_put): Use abi_tag on
definitions.
(numpunct, numpunct_byname): Qualify explicit instantiations.
* include/bits/locale_facets_nonio.h (time_get, time_get_byname,
moneypunct, moneypunct_byname, money_get, money_put, messages,
messages_byname): Use new inline namespace macros.
(money_get::__do_get, money_put::__do_put): Do not declare long
double compat functions for new ABI.
* include/bits/locale_facets_nonio.tcc (money_get, money_put): Use
new namespace macros.
(money_get::__do_get, money_put::__do_put): Do not define for new ABI.
* include/bits/localefwd.h (numpunct, numpunct_byname, collate,
collate_byname, time_get, time_get_byname, moneypunct,
moneypunct_byname, money_get, money_put, messages, messages_byname):
Use new namespace macros.
* include/bits/regex.h: Use inline namespace macros.
* include/bits/stl_list.h (_List_base, list): Use inline namespace
instead of abi-tag.
* include/bits/stringfwd.h (basic_string): Use namespace macros.
* include/std/iosfwd (basic_stringbuf, basic_istringstream,
basic_ostringstream, basic_stringstream): Likewise.
* include/std/sstream: Likewise.
(basic_stringbuf::__xfer_bufptrs): Update streambuf pointers on move.
* include/std/stdexcept (__cow_string, __sso_string): New types for
indirectly using std::string with either ABI.
(logic_error, runtime_error): Replace std::string member with
__cow_string when new ABI is in use. Declare non-inline copy
constructor and assignment operator. Declare const char* constructors.
(domain_error, invalid_argument, length_error, out_of_range,
range_error, overflow_error, underflow_error): Declare const char*
constructors.
* include/std/system_error (error_category): Replace with new
definition in inline namespace _V2.
(error_code::message, error_condition::message): Use abi_tag on
functions returning std::string.
* python/libstdcxx/v6/printers.py (StdStringPrinter): Handle new ABI.
* src/c++11/Makefile.am: Add new files.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/compatibility-c++0x.cc: Compile with old std::string ABI.
Define old error_category symbols.
* src/c++11/cow-fstream-inst.cc: New. Instantiate fstream members
using old std::string ABI.
* src/c++11/cow-locale_init.cc (locale::_Impl::_M_init_extra): Define.
* src/c++11/cow-shim_facets.cc: Define shim facets using old ABI.
* src/c++11/cow-sstream-inst.cc: Instantiate stringstreams using old
std::string ABI.
* src/c++11/cow-stdexcept.cc: Define new constructors and assignment
operators.
(__cow_string, error_category::_M_message): Define.
* src/c++11/cow-string-inst.cc: Explicit instantiations using old
std::string. Include src/c++98/istream-string.cc.
* src/c++11/cow-wstring-inst.cc: Explicit instantiations using old
std::wstring.
* src/c++11/cxx11-hash_tr1.cc: Explicit instantiations using new
string.
* src/c++11/cxx11-ios_failure.cc: Add sanity check.
* src/c++11/cxx11-locale-inst.cc: Instantiate facets using new
std::string.
* src/c++11/cxx11-shim_facets.cc: Define shim facets using new ABI.
* src/c++11/cxx11-stdexcept.cc: Define constructors taking new
std::string.
* src/c++11/cxx11-wlocale-inst.cc: Instantiate facets using
new std::wstring.
* src/c++11/fstream-inst.cc: Compile with new ABI.
* src/c++11/functexcept.cc: Compile with old ABI.
* src/c++11/random.cc: Compile with new ABI.
* src/c++11/sstream-inst.cc: Compile with new ABI.
* src/c++11/string-inst.cc: Explicit instantiations for new string.
* src/c++11/system_error.cc (__sso_string, error_category::_M_message):
Define.
* src/c++11/wstring-inst.cc: Compile with new ABI.
* src/c++98/Makefile.am: Compile some host files twice for old and
new std::string. Add new files.
* src/c++98/Makefile.in: Regenerate.
* src/c++98/compatibility-ldbl.cc: Compile with old ABI.
* src/c++98/compatibility.cc: Likewise.
* src/c++98/concept-inst.cc: Likewise.
* src/c++98/hash_tr1.cc: Likewise.
* src/c++98/istream-string.cc: New file defining functions that
work with istream and std::string moved from ...
* src/c++98/istream.cc: ... here.
* src/c++98/cow-istream-string.cc: Recompile istream-string.cc with
old ABI.
* src/c++98/locale-inst.cc: Adjust facet instantiations to work for
either ABI.
* src/c++98/locale.cc (locale::_M_install_facet,
locale::_M_install_cache): Handle twinned facets.
* src/c++98/locale-facets.cc: Compile with old std::string ABI.
(__verify_grouping): Define new overload and old std::string version.
* src/c++98/locale_init.cc: Initialize twinned facets.
* src/c++98/localename.cc: Likewise.
* src/c++98/misc-inst.cc: Instantiate C++98-only std::string members.
(__verify_grouping): Define new std::string version.
* src/c++98/stdexcept.cc: Compile with old std::string ABI.
* src/c++98/wlocale-inst.cc: Likewise.
* testsuite/18_support/50594.cc: Adjust to work with SSO strings.
* testsuite/21_strings/basic_string/capacity/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/18654.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/2.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc:
Likewise.
* testsuite/21_strings/headers/string/synopsis.cc: Use inline
namespace macros.
* testsuite/23_containers/headers/list/synopsis.cc: Likewise.
* testsuite/27_io/basic_ios/copyfmt/char/1.cc: Set dg-options so
correct exception type can be caught.
* testsuite/27_io/basic_ios/exceptions/char/1.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/char/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/char/12297.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/ios_base/storage/2.cc: Likewise.
* testsuite/27_io/ios_base/failure/cxx11.cc: Disable for old ABI.
* testsuite/ext/profile/mutex_extensions_neg.cc: Adjust dg-error.
* testsuite/libstdc++-prettyprinters/libfundts.cc: Use old ABI.
* testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
* testsuite/util/exception/safety.h: Adjust member function types
for new std::string.
* testsuite/util/testsuite_abi.cc: Add new version and ignore
__float128 symbols in __cxx11 namespace.
From-SVN: r218964
2014-12-19 18:16:39 +00:00
|
|
|
#else
|
|
|
|
iterator (container_type::* _F_insert_point)(const_iterator,
|
|
|
|
value_type);
|
|
|
|
#endif
|
2010-02-10 16:09:42 +00:00
|
|
|
|
|
|
|
insert_base() : _F_insert_point(&container_type::insert) { }
|
|
|
|
};
|
|
|
|
|
stl_deque.h (deque<>::insert(iterator, const value_type&), [...]): Adjust C++11 signatures to take a const_iterator.
2013-06-27 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_deque.h (deque<>::insert(iterator,
const value_type&), deque<>::insert(iterator, value_type&&),
deque<>::emplace(iterator, _Args&&...)): Adjust C++11 signatures to
take a const_iterator.
(deque<>::erase): Simplify.
* include/bits/stl_list.h: Likewise.
(_List_iterator<>::_M_const_cast): Add.
* include/bits/stl_vector.h: Likewise.
* include/bits/stl_bvector.h: Likewise.
(_Bit_iterator::_M_const_cast): Add.
* include/bits/deque.tcc: Adjust definitions.
* include/bits/list.tcc: Likewise.
* include/bits/vector.tcc: Likewise.
* include/bits/stl_iterator.h (__normal_iterator<>::_M_const_cast):
Define trivial version in C++98 mode.
* include/ext/vstring.h (__versa_string<>::insert(iterator, _CharT),
__versa_string<>::replace(iterator, iterator, const __versa_string&),
__versa_string<>::replace(iterator, iterator, const _CharT*,
size_type), __versa_string<>::replace(iterator, iterator,
const _CharT*), __versa_string<>::replace(iterator, iterator,
size_type, _CharT)): Adjust C++11 signatures to take a pair of
const_iterators.
* include/debug/deque: Adjust.
* include/debug/list: Likewise.
* include/debug/vector: Likewise.
* include/profile/deque: Likewise.
* include/profile/list: Likewise.
* include/profile/vector: Likewise.
(vector<>::emplace): Add.
* testsuite/util/exception/safety.h: Update.
* testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc:
New.
* testsuite/23_containers/deque/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/23_containers/list/modifiers/emplace/const_iterator.cc:
Likewise.
* testsuite/23_containers/list/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/23_containers/vector/bool/modifiers/insert/
const_iterator.cc: Likewise.
* testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc:
Likewise.
* testsuite/23_containers/vector/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/char/54577.cc: Move to testsuite/
ext/vstring/modifiers/erase/char/.
* testsuite/ext/vstring/modifiers/wchar_t/54577.cc: Move to testsuite/
ext/vstring/modifiers/wchar_t/.
* testsuite/ext/vstring/modifiers/char/pop_back.cc: Move to testsuite/
ext/vstring/modifiers/pop_back/char/.
* testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc: Move to
testsuite/ext/vstring/modifiers/pop_back/wchar_t/.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/assign_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.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.
From-SVN: r200458
2013-06-27 09:51:21 +00:00
|
|
|
// Specialization, by value.
|
2010-11-08 16:07:32 +00:00
|
|
|
template<typename _Tp1, typename _Tp2, typename _Tp3,
|
|
|
|
template <typename, typename, typename> class _Tp4>
|
|
|
|
struct insert_base<__gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>>
|
2010-02-10 16:09:42 +00:00
|
|
|
{
|
2010-11-08 16:07:32 +00:00
|
|
|
typedef __gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>
|
stl_deque.h (deque<>::insert(iterator, const value_type&), [...]): Adjust C++11 signatures to take a const_iterator.
2013-06-27 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_deque.h (deque<>::insert(iterator,
const value_type&), deque<>::insert(iterator, value_type&&),
deque<>::emplace(iterator, _Args&&...)): Adjust C++11 signatures to
take a const_iterator.
(deque<>::erase): Simplify.
* include/bits/stl_list.h: Likewise.
(_List_iterator<>::_M_const_cast): Add.
* include/bits/stl_vector.h: Likewise.
* include/bits/stl_bvector.h: Likewise.
(_Bit_iterator::_M_const_cast): Add.
* include/bits/deque.tcc: Adjust definitions.
* include/bits/list.tcc: Likewise.
* include/bits/vector.tcc: Likewise.
* include/bits/stl_iterator.h (__normal_iterator<>::_M_const_cast):
Define trivial version in C++98 mode.
* include/ext/vstring.h (__versa_string<>::insert(iterator, _CharT),
__versa_string<>::replace(iterator, iterator, const __versa_string&),
__versa_string<>::replace(iterator, iterator, const _CharT*,
size_type), __versa_string<>::replace(iterator, iterator,
const _CharT*), __versa_string<>::replace(iterator, iterator,
size_type, _CharT)): Adjust C++11 signatures to take a pair of
const_iterators.
* include/debug/deque: Adjust.
* include/debug/list: Likewise.
* include/debug/vector: Likewise.
* include/profile/deque: Likewise.
* include/profile/list: Likewise.
* include/profile/vector: Likewise.
(vector<>::emplace): Add.
* testsuite/util/exception/safety.h: Update.
* testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc:
New.
* testsuite/23_containers/deque/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/23_containers/list/modifiers/emplace/const_iterator.cc:
Likewise.
* testsuite/23_containers/list/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/23_containers/vector/bool/modifiers/insert/
const_iterator.cc: Likewise.
* testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc:
Likewise.
* testsuite/23_containers/vector/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/char/54577.cc: Move to testsuite/
ext/vstring/modifiers/erase/char/.
* testsuite/ext/vstring/modifiers/wchar_t/54577.cc: Move to testsuite/
ext/vstring/modifiers/wchar_t/.
* testsuite/ext/vstring/modifiers/char/pop_back.cc: Move to testsuite/
ext/vstring/modifiers/pop_back/char/.
* testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc: Move to
testsuite/ext/vstring/modifiers/pop_back/wchar_t/.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/assign_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.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.
From-SVN: r200458
2013-06-27 09:51:21 +00:00
|
|
|
container_type;
|
|
|
|
typedef typename container_type::iterator iterator;
|
|
|
|
typedef typename container_type::const_iterator const_iterator;
|
|
|
|
typedef typename container_type::value_type value_type;
|
2010-02-10 16:09:42 +00:00
|
|
|
|
stl_deque.h (deque<>::insert(iterator, const value_type&), [...]): Adjust C++11 signatures to take a const_iterator.
2013-06-27 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_deque.h (deque<>::insert(iterator,
const value_type&), deque<>::insert(iterator, value_type&&),
deque<>::emplace(iterator, _Args&&...)): Adjust C++11 signatures to
take a const_iterator.
(deque<>::erase): Simplify.
* include/bits/stl_list.h: Likewise.
(_List_iterator<>::_M_const_cast): Add.
* include/bits/stl_vector.h: Likewise.
* include/bits/stl_bvector.h: Likewise.
(_Bit_iterator::_M_const_cast): Add.
* include/bits/deque.tcc: Adjust definitions.
* include/bits/list.tcc: Likewise.
* include/bits/vector.tcc: Likewise.
* include/bits/stl_iterator.h (__normal_iterator<>::_M_const_cast):
Define trivial version in C++98 mode.
* include/ext/vstring.h (__versa_string<>::insert(iterator, _CharT),
__versa_string<>::replace(iterator, iterator, const __versa_string&),
__versa_string<>::replace(iterator, iterator, const _CharT*,
size_type), __versa_string<>::replace(iterator, iterator,
const _CharT*), __versa_string<>::replace(iterator, iterator,
size_type, _CharT)): Adjust C++11 signatures to take a pair of
const_iterators.
* include/debug/deque: Adjust.
* include/debug/list: Likewise.
* include/debug/vector: Likewise.
* include/profile/deque: Likewise.
* include/profile/list: Likewise.
* include/profile/vector: Likewise.
(vector<>::emplace): Add.
* testsuite/util/exception/safety.h: Update.
* testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc:
New.
* testsuite/23_containers/deque/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/23_containers/list/modifiers/emplace/const_iterator.cc:
Likewise.
* testsuite/23_containers/list/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/23_containers/vector/bool/modifiers/insert/
const_iterator.cc: Likewise.
* testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc:
Likewise.
* testsuite/23_containers/vector/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/char/54577.cc: Move to testsuite/
ext/vstring/modifiers/erase/char/.
* testsuite/ext/vstring/modifiers/wchar_t/54577.cc: Move to testsuite/
ext/vstring/modifiers/wchar_t/.
* testsuite/ext/vstring/modifiers/char/pop_back.cc: Move to testsuite/
ext/vstring/modifiers/pop_back/char/.
* testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc: Move to
testsuite/ext/vstring/modifiers/pop_back/wchar_t/.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/assign_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.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.
From-SVN: r200458
2013-06-27 09:51:21 +00:00
|
|
|
iterator (container_type::* _F_insert_point)(const_iterator,
|
|
|
|
value_type);
|
2010-02-10 16:09:42 +00:00
|
|
|
|
|
|
|
insert_base() : _F_insert_point(&container_type::insert) { }
|
|
|
|
};
|
|
|
|
|
2010-11-08 16:07:32 +00:00
|
|
|
// Specialization, as forward_list has insert_after.
|
|
|
|
template<typename _Tp1, typename _Tp2>
|
|
|
|
struct insert_base<std::forward_list<_Tp1, _Tp2>>
|
2010-02-10 16:09:42 +00:00
|
|
|
{
|
2010-11-08 16:07:32 +00:00
|
|
|
typedef std::forward_list<_Tp1, _Tp2> container_type;
|
2010-02-10 16:09:42 +00:00
|
|
|
typedef typename container_type::iterator iterator;
|
|
|
|
typedef typename container_type::const_iterator const_iterator;
|
|
|
|
typedef typename container_type::value_type value_type;
|
|
|
|
|
|
|
|
iterator (container_type::* _F_insert_point)(const_iterator,
|
|
|
|
const value_type&);
|
|
|
|
|
2010-11-08 16:07:32 +00:00
|
|
|
insert_base() : _F_insert_point(&container_type::insert_after) { }
|
2010-02-10 16:09:42 +00:00
|
|
|
};
|
|
|
|
|
2012-11-05 20:58:35 +00:00
|
|
|
template<typename _Tp, bool = traits<_Tp>::has_insert::value,
|
|
|
|
bool = traits<_Tp>::has_insert_after::value>
|
[multiple changes]
2010-09-29 Paolo Carlini <paolo.carlini@oracle.com>
* include/Makefile.am: Add debug/forward_list.
* include/Makefile.in: Regenerate.
* testsuite/util/testsuite_container_traits.h (traits_base):
Add has_erase_after and hash_insert_after typedefs.
(traits<forward_list<>>): Adjust.
* testsuite/util/exception/safety.h (erase_point, erase_range,
insert_point): Deal correctly with forward_list.
* include/Makefile.am: Add.
2010-09-29 François Dumont <francois.cppdevs@free.fr>
* src/debug.cc: Add forward_list specific debug messages.
* include/debug/forward_list: New.
* include/debug/formatter.h: Add debug message ids and before begin
iterator state.
* include/debug/macros.h (__glibcxx_check_insert_after,
__glibcxx_check_insert_range_after, __glibcxx_check_erase_after,
__glibcxx_check_erase_range_after): Add.
* include/debug/safe_iterator.h (_BeforeBeginHelper): Add.
(_Safe_iterator<>::_M_before_dereferenceable,
_Safe_iterator<>::_M_is_before_begin): Add.
(_Safe_iterator<>::_M_dereferenceable, _Safe_iterator<>::_M_is_end,
_Safe_iterator<>::_M_incrementable): Adjust.
* include/std/forward_list: Include debug/forward when _GLIBCXX_DEBUG
defined.
* include/bits/forward_list.h, forward_list.tcc: Put in std::__norm
when debug mode is active.
* testsuite/23_containers/forward_list/capacity/1.cc: Fix to compile
even in debug mode.
* testsuite/23_containers/forward_list/debug/erase_after1.cc,
erase_after2.cc, erase_after3.cc, erase_after4.cc, erase_after5.cc,
insert_after1.cc,erase_after6.cc, erase_after7.cc, insert_after2.cc,
erase_after8.cc, insert_after3.cc, erase_after9.cc: New.
From-SVN: r164717
2010-09-29 11:56:34 +00:00
|
|
|
struct insert_point;
|
|
|
|
|
|
|
|
// Specialization for most containers.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct insert_point<_Tp, true, false> : public insert_base<_Tp>
|
2009-12-17 09:37:16 +00:00
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef typename container_type::value_type value_type;
|
|
|
|
using insert_base<_Tp>::_F_insert_point;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
const size_type sz = std::distance(__test.begin(), __test.end());
|
|
|
|
size_type s = generate(sz);
|
|
|
|
auto i = __test.begin();
|
|
|
|
std::advance(i, s);
|
|
|
|
(__test.*_F_insert_point)(i, cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assumes containers start out equivalent.
|
|
|
|
void
|
|
|
|
operator()(_Tp& __control, _Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
const size_type sz = std::distance(__test.begin(), __test.end());
|
|
|
|
size_type s = generate(sz);
|
|
|
|
auto i = __test.begin();
|
|
|
|
std::advance(i, s);
|
|
|
|
(__test.*_F_insert_point)(i, cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
[multiple changes]
2010-09-29 Paolo Carlini <paolo.carlini@oracle.com>
* include/Makefile.am: Add debug/forward_list.
* include/Makefile.in: Regenerate.
* testsuite/util/testsuite_container_traits.h (traits_base):
Add has_erase_after and hash_insert_after typedefs.
(traits<forward_list<>>): Adjust.
* testsuite/util/exception/safety.h (erase_point, erase_range,
insert_point): Deal correctly with forward_list.
* include/Makefile.am: Add.
2010-09-29 François Dumont <francois.cppdevs@free.fr>
* src/debug.cc: Add forward_list specific debug messages.
* include/debug/forward_list: New.
* include/debug/formatter.h: Add debug message ids and before begin
iterator state.
* include/debug/macros.h (__glibcxx_check_insert_after,
__glibcxx_check_insert_range_after, __glibcxx_check_erase_after,
__glibcxx_check_erase_range_after): Add.
* include/debug/safe_iterator.h (_BeforeBeginHelper): Add.
(_Safe_iterator<>::_M_before_dereferenceable,
_Safe_iterator<>::_M_is_before_begin): Add.
(_Safe_iterator<>::_M_dereferenceable, _Safe_iterator<>::_M_is_end,
_Safe_iterator<>::_M_incrementable): Adjust.
* include/std/forward_list: Include debug/forward when _GLIBCXX_DEBUG
defined.
* include/bits/forward_list.h, forward_list.tcc: Put in std::__norm
when debug mode is active.
* testsuite/23_containers/forward_list/capacity/1.cc: Fix to compile
even in debug mode.
* testsuite/23_containers/forward_list/debug/erase_after1.cc,
erase_after2.cc, erase_after3.cc, erase_after4.cc, erase_after5.cc,
insert_after1.cc,erase_after6.cc, erase_after7.cc, insert_after2.cc,
erase_after8.cc, insert_after3.cc, erase_after9.cc: New.
From-SVN: r164717
2010-09-29 11:56:34 +00:00
|
|
|
// Specialization for forward_list.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct insert_point<_Tp, false, true> : public insert_base<_Tp>
|
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef typename container_type::value_type value_type;
|
|
|
|
using insert_base<_Tp>::_F_insert_point;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
const size_type sz = std::distance(__test.begin(), __test.end());
|
|
|
|
size_type s = generate(sz);
|
|
|
|
auto i = __test.before_begin();
|
|
|
|
std::advance(i, s);
|
|
|
|
(__test.*_F_insert_point)(i, cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assumes containers start out equivalent.
|
|
|
|
void
|
|
|
|
operator()(_Tp& __control, _Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
const size_type sz = std::distance(__test.begin(), __test.end());
|
|
|
|
size_type s = generate(sz);
|
|
|
|
auto i = __test.before_begin();
|
|
|
|
std::advance(i, s);
|
|
|
|
(__test.*_F_insert_point)(i, cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-12-17 09:37:16 +00:00
|
|
|
// Specialization, empty.
|
|
|
|
template<typename _Tp>
|
[multiple changes]
2010-09-29 Paolo Carlini <paolo.carlini@oracle.com>
* include/Makefile.am: Add debug/forward_list.
* include/Makefile.in: Regenerate.
* testsuite/util/testsuite_container_traits.h (traits_base):
Add has_erase_after and hash_insert_after typedefs.
(traits<forward_list<>>): Adjust.
* testsuite/util/exception/safety.h (erase_point, erase_range,
insert_point): Deal correctly with forward_list.
* include/Makefile.am: Add.
2010-09-29 François Dumont <francois.cppdevs@free.fr>
* src/debug.cc: Add forward_list specific debug messages.
* include/debug/forward_list: New.
* include/debug/formatter.h: Add debug message ids and before begin
iterator state.
* include/debug/macros.h (__glibcxx_check_insert_after,
__glibcxx_check_insert_range_after, __glibcxx_check_erase_after,
__glibcxx_check_erase_range_after): Add.
* include/debug/safe_iterator.h (_BeforeBeginHelper): Add.
(_Safe_iterator<>::_M_before_dereferenceable,
_Safe_iterator<>::_M_is_before_begin): Add.
(_Safe_iterator<>::_M_dereferenceable, _Safe_iterator<>::_M_is_end,
_Safe_iterator<>::_M_incrementable): Adjust.
* include/std/forward_list: Include debug/forward when _GLIBCXX_DEBUG
defined.
* include/bits/forward_list.h, forward_list.tcc: Put in std::__norm
when debug mode is active.
* testsuite/23_containers/forward_list/capacity/1.cc: Fix to compile
even in debug mode.
* testsuite/23_containers/forward_list/debug/erase_after1.cc,
erase_after2.cc, erase_after3.cc, erase_after4.cc, erase_after5.cc,
insert_after1.cc,erase_after6.cc, erase_after7.cc, insert_after2.cc,
erase_after8.cc, insert_after3.cc, erase_after9.cc: New.
From-SVN: r164717
2010-09-29 11:56:34 +00:00
|
|
|
struct insert_point<_Tp, false, false>
|
2009-12-17 09:37:16 +00:00
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp&) { }
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp&, _Tp&) { }
|
|
|
|
};
|
|
|
|
|
2012-11-05 20:58:35 +00:00
|
|
|
template<typename _Tp, bool = traits<_Tp>::has_emplace::value
|
|
|
|
&& (traits<_Tp>::is_associative::value
|
|
|
|
|| traits<_Tp>::is_unordered::value)>
|
2011-12-09 20:01:04 +00:00
|
|
|
struct emplace;
|
|
|
|
|
2012-11-05 20:58:35 +00:00
|
|
|
// Specialization for associative and unordered containers.
|
2011-12-09 20:01:04 +00:00
|
|
|
template<typename _Tp>
|
|
|
|
struct emplace<_Tp, true>
|
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef typename container_type::value_type value_type;
|
|
|
|
typedef typename container_type::size_type size_type;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
__test.emplace(cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assumes containers start out equivalent.
|
|
|
|
void
|
|
|
|
operator()(_Tp& __control, _Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
__test.emplace(cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Specialization, empty.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct emplace<_Tp, false>
|
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp&) { }
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp&, _Tp&) { }
|
|
|
|
};
|
|
|
|
|
2012-11-05 20:58:35 +00:00
|
|
|
template<typename _Tp, bool = traits<_Tp>::has_emplace::value,
|
|
|
|
bool = traits<_Tp>::is_associative::value
|
|
|
|
|| traits<_Tp>::is_unordered::value,
|
|
|
|
bool = traits<_Tp>::has_insert_after::value>
|
|
|
|
struct emplace_point;
|
2011-12-09 20:01:04 +00:00
|
|
|
|
|
|
|
// Specialization for most containers.
|
|
|
|
template<typename _Tp>
|
2012-11-05 20:58:35 +00:00
|
|
|
struct emplace_point<_Tp, true, false, false>
|
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef typename container_type::value_type value_type;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
const size_type sz = std::distance(__test.begin(), __test.end());
|
|
|
|
size_type s = generate(sz);
|
|
|
|
auto i = __test.begin();
|
|
|
|
std::advance(i, s);
|
|
|
|
__test.emplace(i, cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assumes containers start out equivalent.
|
|
|
|
void
|
|
|
|
operator()(_Tp& __control, _Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
const size_type sz = std::distance(__test.begin(), __test.end());
|
|
|
|
size_type s = generate(sz);
|
|
|
|
auto i = __test.begin();
|
|
|
|
std::advance(i, s);
|
|
|
|
__test.emplace(i, cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Specialization for associative and unordered containers.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct emplace_point<_Tp, true, true, false>
|
2011-12-09 20:01:04 +00:00
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef typename container_type::value_type value_type;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
const size_type sz = std::distance(__test.begin(), __test.end());
|
|
|
|
size_type s = generate(sz);
|
|
|
|
auto i = __test.begin();
|
|
|
|
std::advance(i, s);
|
|
|
|
__test.emplace_hint(i, cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assumes containers start out equivalent.
|
|
|
|
void
|
|
|
|
operator()(_Tp& __control, _Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
const size_type sz = std::distance(__test.begin(), __test.end());
|
|
|
|
size_type s = generate(sz);
|
|
|
|
auto i = __test.begin();
|
|
|
|
std::advance(i, s);
|
|
|
|
__test.emplace_hint(i, cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-11-05 20:58:35 +00:00
|
|
|
// Specialization for forward_list.
|
2011-12-09 20:01:04 +00:00
|
|
|
template<typename _Tp>
|
2012-11-05 20:58:35 +00:00
|
|
|
struct emplace_point<_Tp, true, false, true>
|
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef typename container_type::value_type value_type;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
const size_type sz = std::distance(__test.begin(), __test.end());
|
|
|
|
size_type s = generate(sz);
|
|
|
|
auto i = __test.before_begin();
|
|
|
|
std::advance(i, s);
|
|
|
|
__test.emplace_after(i, cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assumes containers start out equivalent.
|
|
|
|
void
|
|
|
|
operator()(_Tp& __control, _Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const value_type cv = generate_unique<value_type>();
|
|
|
|
const size_type sz = std::distance(__test.begin(), __test.end());
|
|
|
|
size_type s = generate(sz);
|
|
|
|
auto i = __test.before_begin();
|
|
|
|
std::advance(i, s);
|
|
|
|
__test.emplace_after(i, cv);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Specialization, empty.
|
|
|
|
template<typename _Tp, bool is_associative_or_unordered,
|
|
|
|
bool has_insert_after>
|
|
|
|
struct emplace_point<_Tp, false, is_associative_or_unordered,
|
|
|
|
has_insert_after>
|
2011-12-09 20:01:04 +00:00
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp&) { }
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp&, _Tp&) { }
|
|
|
|
};
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
template<typename _Tp, bool = traits<_Tp>::is_associative::value
|
|
|
|
|| traits<_Tp>::is_unordered::value>
|
|
|
|
struct clear
|
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp& __container)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
__container.clear();
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Specialization, empty.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct clear<_Tp, false>
|
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp&) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<typename _Tp, bool = traits<_Tp>::is_unordered::value>
|
|
|
|
struct rehash
|
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
size_type s = generate(__test.bucket_count());
|
|
|
|
__test.rehash(s);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __control, _Tp& __test)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
size_type s = generate(__test.bucket_count());
|
|
|
|
__test.rehash(s);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{
|
|
|
|
// Also check hash status.
|
|
|
|
bool fail(false);
|
|
|
|
if (__control.load_factor() != __test.load_factor())
|
|
|
|
fail = true;
|
|
|
|
if (__control.max_load_factor() != __test.max_load_factor())
|
|
|
|
fail = true;
|
|
|
|
if (__control.bucket_count() != __test.bucket_count())
|
|
|
|
fail = true;
|
|
|
|
if (__control.max_bucket_count() != __test.max_bucket_count())
|
|
|
|
fail = true;
|
|
|
|
|
|
|
|
if (fail)
|
|
|
|
{
|
|
|
|
char buf[40];
|
|
|
|
std::string __s("setup_base::rehash "
|
|
|
|
"containers not equal");
|
|
|
|
__s += "\n";
|
|
|
|
__s += "\n";
|
|
|
|
__s += "\t\t\tcontrol : test";
|
|
|
|
__s += "\n";
|
|
|
|
__s += "load_factor\t\t";
|
|
|
|
__builtin_sprintf(buf, "%lu", __control.load_factor());
|
|
|
|
__s += buf;
|
|
|
|
__s += " : ";
|
|
|
|
__builtin_sprintf(buf, "%lu", __test.load_factor());
|
|
|
|
__s += buf;
|
|
|
|
__s += "\n";
|
|
|
|
|
|
|
|
__s += "max_load_factor\t\t";
|
|
|
|
__builtin_sprintf(buf, "%lu", __control.max_load_factor());
|
|
|
|
__s += buf;
|
|
|
|
__s += " : ";
|
|
|
|
__builtin_sprintf(buf, "%lu", __test.max_load_factor());
|
|
|
|
__s += buf;
|
|
|
|
__s += "\n";
|
|
|
|
|
|
|
|
__s += "bucket_count\t\t";
|
|
|
|
__builtin_sprintf(buf, "%lu", __control.bucket_count());
|
|
|
|
__s += buf;
|
|
|
|
__s += " : ";
|
|
|
|
__builtin_sprintf(buf, "%lu", __test.bucket_count());
|
|
|
|
__s += buf;
|
|
|
|
__s += "\n";
|
|
|
|
|
|
|
|
__s += "max_bucket_count\t";
|
|
|
|
__builtin_sprintf(buf, "%lu", __control.max_bucket_count());
|
|
|
|
__s += buf;
|
|
|
|
__s += " : ";
|
|
|
|
__builtin_sprintf(buf, "%lu", __test.max_bucket_count());
|
|
|
|
__s += buf;
|
|
|
|
__s += "\n";
|
|
|
|
|
|
|
|
std::__throw_logic_error(__s.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Specialization, empty.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct rehash<_Tp, false>
|
|
|
|
{
|
|
|
|
void
|
|
|
|
operator()(_Tp&) { }
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp&, _Tp&) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
struct swap
|
|
|
|
{
|
|
|
|
_Tp _M_other;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __container)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
__container.swap(_M_other);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
struct iterator_operations
|
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef typename container_type::iterator iterator;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __container)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// Any will do.
|
|
|
|
iterator i = __container.begin();
|
|
|
|
iterator __attribute__((unused)) icopy(i);
|
|
|
|
iterator __attribute__((unused)) iassign = i;
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
struct const_iterator_operations
|
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef typename container_type::const_iterator const_iterator;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __container)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// Any will do.
|
|
|
|
const_iterator i = __container.begin();
|
|
|
|
const_iterator __attribute__((unused)) icopy(i);
|
|
|
|
const_iterator __attribute__((unused)) iassign = i;
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
2013-04-22 20:22:07 +00:00
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
struct assign_operator
|
|
|
|
{
|
|
|
|
_Tp _M_other;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __container)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// An exception while assigning might leave the container empty
|
2013-11-15 17:33:59 +01:00
|
|
|
// making future attempts less relevant. So we copy it before to
|
2013-04-22 20:22:07 +00:00
|
|
|
// always assign to a non empty container. It also check for copy
|
|
|
|
// constructor exception safety at the same time.
|
|
|
|
_Tp __clone(__container);
|
|
|
|
__clone = _M_other;
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
template<typename _Tp>
|
|
|
|
struct move_assign_operator
|
|
|
|
{
|
|
|
|
_Tp _M_other;
|
|
|
|
|
|
|
|
void
|
|
|
|
operator()(_Tp& __container)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
__container = std::move(_M_other);
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{ throw; }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|
2009-12-17 09:37:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Base class for exception tests.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct test_base: public functor_base
|
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
|
|
|
|
typedef functor_base base_type;
|
|
|
|
typedef populate<container_type> populate;
|
|
|
|
typedef make_container_n<container_type> make_container_n;
|
|
|
|
|
|
|
|
typedef clear<container_type> clear;
|
|
|
|
typedef erase_point<container_type> erase_point;
|
|
|
|
typedef erase_range<container_type> erase_range;
|
|
|
|
typedef insert_point<container_type> insert_point;
|
2011-12-09 20:01:04 +00:00
|
|
|
typedef emplace<container_type> emplace;
|
2012-11-05 20:58:35 +00:00
|
|
|
typedef emplace_point<container_type> emplace_point;
|
|
|
|
typedef emplace_front<container_type> emplace_front;
|
|
|
|
typedef emplace_back<container_type> emplace_back;
|
2009-12-17 09:37:16 +00:00
|
|
|
typedef pop_front<container_type> pop_front;
|
|
|
|
typedef pop_back<container_type> pop_back;
|
|
|
|
typedef push_front<container_type> push_front;
|
|
|
|
typedef push_back<container_type> push_back;
|
|
|
|
typedef rehash<container_type> rehash;
|
|
|
|
typedef swap<container_type> swap;
|
|
|
|
typedef iterator_operations<container_type> iterator_ops;
|
|
|
|
typedef const_iterator_operations<container_type> const_iterator_ops;
|
2013-04-22 20:22:07 +00:00
|
|
|
typedef assign_operator<container_type> assign_operator;
|
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
typedef move_assign_operator<container_type> move_assign_operator;
|
|
|
|
#endif
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
using base_type::compare;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Run through all member functions for basic exception safety
|
|
|
|
// guarantee: no resource leaks when exceptions are thrown.
|
|
|
|
//
|
|
|
|
// Types of resources checked: memory.
|
|
|
|
//
|
|
|
|
// For each member function, use throw_value and throw_allocator as
|
|
|
|
// value_type and allocator_type to force potential exception safety
|
|
|
|
// errors.
|
|
|
|
//
|
|
|
|
// NB: Assumes
|
|
|
|
// _Tp::value_type is __gnu_cxx::throw_value_*
|
|
|
|
// _Tp::allocator_type is __gnu_cxx::throw_allocator_*
|
|
|
|
// And that the _Cond template parameter for them both is
|
|
|
|
// __gnu_cxx::limit_condition.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct basic_safety : public test_base<_Tp>
|
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef test_base<container_type> base_type;
|
|
|
|
typedef typename base_type::populate populate;
|
|
|
|
typedef std::function<void(container_type&)> function_type;
|
|
|
|
typedef __gnu_cxx::limit_condition condition_type;
|
|
|
|
|
|
|
|
using base_type::generate;
|
|
|
|
|
|
|
|
basic_safety() { run(); }
|
|
|
|
|
|
|
|
void
|
|
|
|
run()
|
|
|
|
{
|
2013-04-22 20:22:07 +00:00
|
|
|
{
|
|
|
|
// Setup.
|
|
|
|
condition_type::never_adjustor off;
|
|
|
|
|
|
|
|
// Construct containers.
|
|
|
|
container_type container;
|
|
|
|
populate p1(container);
|
|
|
|
|
|
|
|
// Construct list of member functions to exercise.
|
|
|
|
std::vector<function_type> functions;
|
|
|
|
typename base_type::iterator_ops iops;
|
|
|
|
functions.push_back(function_type(iops));
|
|
|
|
typename base_type::const_iterator_ops ciops;
|
|
|
|
functions.push_back(function_type(ciops));
|
2009-12-17 09:37:16 +00:00
|
|
|
|
2013-04-22 20:22:07 +00:00
|
|
|
typename base_type::erase_point erasep;
|
|
|
|
functions.push_back(function_type(erasep));
|
|
|
|
typename base_type::erase_range eraser;
|
|
|
|
functions.push_back(function_type(eraser));
|
|
|
|
typename base_type::insert_point insertp;
|
|
|
|
functions.push_back(function_type(insertp));
|
|
|
|
typename base_type::emplace emplace;
|
|
|
|
functions.push_back(function_type(emplace));
|
|
|
|
typename base_type::emplace_point emplacep;
|
|
|
|
functions.push_back(function_type(emplacep));
|
|
|
|
typename base_type::emplace_front emplacef;
|
|
|
|
functions.push_back(function_type(emplacef));
|
|
|
|
typename base_type::emplace_back emplaceb;
|
|
|
|
functions.push_back(function_type(emplaceb));
|
|
|
|
typename base_type::pop_front popf;
|
|
|
|
functions.push_back(function_type(popf));
|
|
|
|
typename base_type::pop_back popb;
|
|
|
|
functions.push_back(function_type(popb));
|
|
|
|
typename base_type::push_front pushf;
|
|
|
|
functions.push_back(function_type(pushf));
|
|
|
|
typename base_type::push_back pushb;
|
|
|
|
functions.push_back(function_type(pushb));
|
|
|
|
typename base_type::rehash rehash;
|
|
|
|
functions.push_back(function_type(rehash));
|
|
|
|
typename base_type::swap swap;
|
|
|
|
populate p2(swap._M_other);
|
|
|
|
functions.push_back(function_type(swap));
|
|
|
|
typename base_type::assign_operator assignop;
|
|
|
|
populate p3(assignop._M_other);
|
|
|
|
functions.push_back(function_type(assignop));
|
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
typename base_type::move_assign_operator massignop;
|
|
|
|
populate p4(massignop._M_other);
|
|
|
|
functions.push_back(function_type(massignop));
|
|
|
|
#endif
|
|
|
|
// Last.
|
|
|
|
typename base_type::clear clear;
|
|
|
|
functions.push_back(function_type(clear));
|
2009-12-17 09:37:16 +00:00
|
|
|
|
2013-04-22 20:22:07 +00:00
|
|
|
// Run tests.
|
|
|
|
size_t i(1);
|
|
|
|
for (auto it = functions.begin(); it != functions.end(); ++it)
|
|
|
|
{
|
|
|
|
function_type& f = *it;
|
|
|
|
i = run_steps_to_limit(i, container, f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now that all instances has been destroyed check that there is no
|
|
|
|
// allocation remaining.
|
|
|
|
std::cout << "Checking remaining stuff" << std::endl;
|
|
|
|
__gnu_cxx::annotate_base::check();
|
2009-12-17 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _Funct>
|
2013-04-22 20:22:07 +00:00
|
|
|
size_t
|
|
|
|
run_steps_to_limit(size_t __step, container_type& __cont,
|
|
|
|
const _Funct& __f)
|
2009-12-17 09:37:16 +00:00
|
|
|
{
|
|
|
|
bool exit(false);
|
2013-04-22 20:22:07 +00:00
|
|
|
auto a = __cont.get_allocator();
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
// Use the current step as an allocator label.
|
2013-04-22 20:22:07 +00:00
|
|
|
a.set_label(__step);
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2013-04-22 20:22:07 +00:00
|
|
|
condition_type::limit_adjustor limit(__step);
|
|
|
|
__f(__cont);
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
// If we get here, done.
|
|
|
|
exit = true;
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{
|
|
|
|
// Check this step for allocations.
|
|
|
|
// NB: Will throw std::logic_error if allocations.
|
2013-04-22 20:22:07 +00:00
|
|
|
a.check(__step);
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
// Check memory allocated with operator new.
|
|
|
|
|
|
|
|
}
|
2013-04-22 20:22:07 +00:00
|
|
|
++__step;
|
2009-12-17 09:37:16 +00:00
|
|
|
}
|
|
|
|
while (!exit);
|
|
|
|
|
|
|
|
// Log count info.
|
|
|
|
std::cout << __f.target_type().name() << std::endl;
|
2013-04-22 20:22:07 +00:00
|
|
|
std::cout << "end count " << __step << std::endl;
|
|
|
|
return __step;
|
2009-12-17 09:37:16 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Run through all member functions with a no throw requirement, sudden death.
|
|
|
|
// all: member functions erase, pop_back, pop_front, swap
|
|
|
|
// iterator copy ctor, assignment operator
|
|
|
|
// unordered and associative: clear
|
|
|
|
// NB: Assumes _Tp::allocator_type is __gnu_cxx::throw_allocator_random.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct generation_prohibited : public test_base<_Tp>
|
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef test_base<container_type> base_type;
|
|
|
|
typedef typename base_type::populate populate;
|
|
|
|
typedef __gnu_cxx::random_condition condition_type;
|
|
|
|
|
|
|
|
generation_prohibited() { run(); }
|
|
|
|
|
|
|
|
void
|
|
|
|
run()
|
|
|
|
{
|
|
|
|
// Furthermore, assumes that the test functor will throw
|
|
|
|
// forced_exception via throw_allocator, that all errors are
|
|
|
|
// propagated and in error. Sudden death!
|
|
|
|
|
|
|
|
// Setup.
|
2013-04-22 20:22:07 +00:00
|
|
|
container_type container;
|
|
|
|
typename base_type::swap swap;
|
|
|
|
|
2009-12-17 09:37:16 +00:00
|
|
|
{
|
|
|
|
condition_type::never_adjustor off;
|
2013-04-22 20:22:07 +00:00
|
|
|
populate p1(container);
|
|
|
|
populate p2(swap._M_other);
|
2009-12-17 09:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Run tests.
|
|
|
|
{
|
|
|
|
condition_type::always_adjustor on;
|
|
|
|
|
testsuite_container_traits.h (traits_base): Add has_throwing_erase trait.
2010-03-04 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/util/testsuite_container_traits.h (traits_base): Add
has_throwing_erase trait.
(traits<vector>, traits<deque>): Typedef the latter to true_type.
* testsuite/util/exception/safety.h (generation_prohibited):
Do not test vector::erase and deque::erase: can throw if
either copy constructor or assignment operator of value_type
throws.
* testsuite/23_containers/vector/requirements/exception/
generation_prohibited.cc: Remove xfail.
* testsuite/23_containers/deque/requirements/exception/
generation_prohibited.cc: Likewise.
* include/ext/throw_allocator.h (hash<__gnu_cxx::throw_value_limit>::
operator(), hash<__gnu_cxx::throw_value_random>::operator()): Pass
argument by const ref.
* testsuite/util/testsuite_container_traits.h (traits<map>,
traits<multimap>, traits<set>, traits<multiset>,
traits<unordered_map>, traits<unordered_multimap>,
traits<unordered_set>, traits<unordered_multiset>): Typedef
consistently has_erase and has_insert as true_type.
* testsuite/util/testsuite_container_traits.h
(traits<unordered_map>, traits<unordered_multimap>,
traits<unordered_set>, traits<unordered_multiset>): Do not wrongly
typedef has_size_type_constructor as true_type: the constructor
accepting a size_type actually gets the initial number of
buckets.
From-SVN: r157239
2010-03-05 01:51:56 +00:00
|
|
|
// NB: Vector and deque are special, erase can throw if the copy
|
|
|
|
// constructor or assignment operator of value_type throws.
|
|
|
|
if (!traits<container_type>::has_throwing_erase::value)
|
|
|
|
{
|
2013-04-22 20:22:07 +00:00
|
|
|
typename base_type::erase_point erasep;
|
|
|
|
erasep(container);
|
|
|
|
typename base_type::erase_range eraser;
|
|
|
|
eraser(container);
|
testsuite_container_traits.h (traits_base): Add has_throwing_erase trait.
2010-03-04 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/util/testsuite_container_traits.h (traits_base): Add
has_throwing_erase trait.
(traits<vector>, traits<deque>): Typedef the latter to true_type.
* testsuite/util/exception/safety.h (generation_prohibited):
Do not test vector::erase and deque::erase: can throw if
either copy constructor or assignment operator of value_type
throws.
* testsuite/23_containers/vector/requirements/exception/
generation_prohibited.cc: Remove xfail.
* testsuite/23_containers/deque/requirements/exception/
generation_prohibited.cc: Likewise.
* include/ext/throw_allocator.h (hash<__gnu_cxx::throw_value_limit>::
operator(), hash<__gnu_cxx::throw_value_random>::operator()): Pass
argument by const ref.
* testsuite/util/testsuite_container_traits.h (traits<map>,
traits<multimap>, traits<set>, traits<multiset>,
traits<unordered_map>, traits<unordered_multimap>,
traits<unordered_set>, traits<unordered_multiset>): Typedef
consistently has_erase and has_insert as true_type.
* testsuite/util/testsuite_container_traits.h
(traits<unordered_map>, traits<unordered_multimap>,
traits<unordered_set>, traits<unordered_multiset>): Do not wrongly
typedef has_size_type_constructor as true_type: the constructor
accepting a size_type actually gets the initial number of
buckets.
From-SVN: r157239
2010-03-05 01:51:56 +00:00
|
|
|
}
|
2009-12-17 09:37:16 +00:00
|
|
|
|
2013-04-22 20:22:07 +00:00
|
|
|
typename base_type::pop_front popf;
|
|
|
|
popf(container);
|
|
|
|
typename base_type::pop_back popb;
|
|
|
|
popb(container);
|
2009-12-17 09:37:16 +00:00
|
|
|
|
2013-04-22 20:22:07 +00:00
|
|
|
typename base_type::iterator_ops iops;
|
|
|
|
iops(container);
|
|
|
|
typename base_type::const_iterator_ops ciops;
|
|
|
|
ciops(container);
|
2009-12-17 09:37:16 +00:00
|
|
|
|
2013-04-22 20:22:07 +00:00
|
|
|
swap(container);
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
// Last.
|
2013-04-22 20:22:07 +00:00
|
|
|
typename base_type::clear clear;
|
|
|
|
clear(container);
|
2009-12-17 09:37:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Test strong exception guarantee.
|
|
|
|
// Run through all member functions with a roll-back, consistent
|
|
|
|
// coherent requirement.
|
2012-11-05 20:58:35 +00:00
|
|
|
// all: member functions insert and emplace of a single element, push_back,
|
|
|
|
// push_front
|
2009-12-17 09:37:16 +00:00
|
|
|
// unordered: rehash
|
|
|
|
template<typename _Tp>
|
|
|
|
struct propagation_consistent : public test_base<_Tp>
|
|
|
|
{
|
|
|
|
typedef _Tp container_type;
|
|
|
|
typedef test_base<container_type> base_type;
|
|
|
|
typedef typename base_type::populate populate;
|
|
|
|
typedef std::function<void(container_type&)> function_type;
|
|
|
|
typedef __gnu_cxx::limit_condition condition_type;
|
|
|
|
|
|
|
|
using base_type::compare;
|
|
|
|
|
|
|
|
propagation_consistent() { run(); }
|
|
|
|
|
|
|
|
// Run test.
|
|
|
|
void
|
|
|
|
run()
|
|
|
|
{
|
|
|
|
// Setup.
|
|
|
|
condition_type::never_adjustor off;
|
|
|
|
|
|
|
|
// Construct containers.
|
2013-04-22 20:22:07 +00:00
|
|
|
container_type container_control;
|
|
|
|
|
|
|
|
populate p(container_control);
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
// Construct list of member functions to exercise.
|
2013-04-22 20:22:07 +00:00
|
|
|
std::vector<function_type> functions;
|
|
|
|
typename base_type::emplace emplace;
|
|
|
|
functions.push_back(function_type(emplace));
|
|
|
|
typename base_type::emplace_point emplacep;
|
|
|
|
functions.push_back(function_type(emplacep));
|
|
|
|
typename base_type::emplace_front emplacef;
|
|
|
|
functions.push_back(function_type(emplacef));
|
|
|
|
typename base_type::emplace_back emplaceb;
|
|
|
|
functions.push_back(function_type(emplaceb));
|
|
|
|
typename base_type::push_front pushf;
|
|
|
|
functions.push_back(function_type(pushf));
|
|
|
|
typename base_type::push_back pushb;
|
|
|
|
functions.push_back(function_type(pushb));
|
|
|
|
typename base_type::insert_point insertp;
|
|
|
|
functions.push_back(function_type(insertp));
|
|
|
|
typename base_type::rehash rehash;
|
|
|
|
functions.push_back(function_type(rehash));
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
// Run tests.
|
2013-04-22 20:22:07 +00:00
|
|
|
for (auto i = functions.begin(); i != functions.end(); ++i)
|
2009-12-17 09:37:16 +00:00
|
|
|
{
|
|
|
|
function_type& f = *i;
|
2013-04-22 20:22:07 +00:00
|
|
|
run_steps_to_limit(container_control, f);
|
2009-12-17 09:37:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _Funct>
|
|
|
|
void
|
2013-04-22 20:22:07 +00:00
|
|
|
run_steps_to_limit(container_type& container_control, const _Funct& __f)
|
2009-12-17 09:37:16 +00:00
|
|
|
{
|
|
|
|
size_t i(1);
|
|
|
|
bool exit(false);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2013-04-22 20:22:07 +00:00
|
|
|
container_type container_test(container_control);
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
condition_type::limit_adjustor limit(i);
|
2013-04-22 20:22:07 +00:00
|
|
|
__f(container_test);
|
2009-12-17 09:37:16 +00:00
|
|
|
|
|
|
|
// If we get here, done.
|
|
|
|
exit = true;
|
|
|
|
}
|
|
|
|
catch(const __gnu_cxx::forced_error&)
|
|
|
|
{
|
2013-04-22 20:22:07 +00:00
|
|
|
compare(container_control, container_test);
|
2009-12-17 09:37:16 +00:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!exit);
|
|
|
|
|
|
|
|
// Log count info.
|
|
|
|
std::cout << __f.target_type().name() << std::endl;
|
|
|
|
std::cout << "end count " << i << std::endl;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace __gnu_test
|
|
|
|
|
|
|
|
#endif
|