aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/bits
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include/bits')
-rw-r--r--libstdc++-v3/include/bits/atomic_0.h5
-rw-r--r--libstdc++-v3/include/bits/atomic_2.h5
-rw-r--r--libstdc++-v3/include/bits/basic_string.h13
-rw-r--r--libstdc++-v3/include/bits/c++config6
-rw-r--r--libstdc++-v3/include/bits/random.h138
-rw-r--r--libstdc++-v3/include/bits/valarray_array.h31
6 files changed, 115 insertions, 83 deletions
diff --git a/libstdc++-v3/include/bits/atomic_0.h b/libstdc++-v3/include/bits/atomic_0.h
index a493ea66af9..0caffaf1e9f 100644
--- a/libstdc++-v3/include/bits/atomic_0.h
+++ b/libstdc++-v3/include/bits/atomic_0.h
@@ -82,14 +82,15 @@ namespace __atomic0
__r; })
/// atomic_flag
- struct atomic_flag : private __atomic_flag_base
+ struct atomic_flag : public __atomic_flag_base
{
atomic_flag() = default;
~atomic_flag() = default;
atomic_flag(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) = delete;
- atomic_flag(bool __i) { _M_i = __i; } // XXX deleted copy ctor != agg
+ // Conversion to ATOMIC_FLAG_INIT.
+ atomic_flag(bool __i): __atomic_flag_base({ __i }) { }
bool
test_and_set(memory_order __m = memory_order_seq_cst) volatile;
diff --git a/libstdc++-v3/include/bits/atomic_2.h b/libstdc++-v3/include/bits/atomic_2.h
index 8e8e7ff16f8..d39adb920a2 100644
--- a/libstdc++-v3/include/bits/atomic_2.h
+++ b/libstdc++-v3/include/bits/atomic_2.h
@@ -44,14 +44,15 @@
namespace __atomic2
{
/// atomic_flag
- struct atomic_flag : private __atomic_flag_base
+ struct atomic_flag : public __atomic_flag_base
{
atomic_flag() = default;
~atomic_flag() = default;
atomic_flag(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) = delete;
- atomic_flag(bool __i) { _M_i = __i; } // XXX deleted copy ctor != agg
+ // Conversion to ATOMIC_FLAG_INIT.
+ atomic_flag(bool __i): __atomic_flag_base({ __i }) { }
bool
test_and_set(memory_order __m = memory_order_seq_cst) volatile
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index bd54537cdc1..9d44dc4fdfc 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -540,7 +540,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
basic_string&
operator=(initializer_list<_CharT> __l)
{
- this->assign (__l.begin(), __l.end());
+ this->assign(__l.begin(), __l.size());
return *this;
}
#endif // __GXX_EXPERIMENTAL_CXX0X__
@@ -860,7 +860,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
*/
basic_string&
operator+=(initializer_list<_CharT> __l)
- { return this->append(__l.begin(), __l.end()); }
+ { return this->append(__l.begin(), __l.size()); }
#endif // __GXX_EXPERIMENTAL_CXX0X__
/**
@@ -926,7 +926,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
*/
basic_string&
append(initializer_list<_CharT> __l)
- { return this->append(__l.begin(), __l.end()); }
+ { return this->append(__l.begin(), __l.size()); }
#endif // __GXX_EXPERIMENTAL_CXX0X__
/**
@@ -1045,7 +1045,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
*/
basic_string&
assign(initializer_list<_CharT> __l)
- { return this->assign(__l.begin(), __l.end()); }
+ { return this->assign(__l.begin(), __l.size()); }
#endif // __GXX_EXPERIMENTAL_CXX0X__
/**
@@ -1089,7 +1089,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
*/
void
insert(iterator __p, initializer_list<_CharT> __l)
- { this->insert(__p, __l.begin(), __l.end()); }
+ {
+ _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
+ this->insert(__p - _M_ibegin(), __l.begin(), __l.size());
+ }
#endif // __GXX_EXPERIMENTAL_CXX0X__
/**
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 724f373ebae..f4f1f8b901f 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -147,7 +147,6 @@
# define _GLIBCXX_STD __cxx1998
# define _GLIBCXX_BEGIN_NAMESPACE(X) namespace X _GLIBCXX_VISIBILITY_ATTR(default) {
# define _GLIBCXX_END_NAMESPACE }
-# define _GLIBCXX_EXTERN_TEMPLATE -1
# endif
// debug + parallel
@@ -172,7 +171,6 @@
# define _GLIBCXX_STD __cxx1998
# define _GLIBCXX_BEGIN_NAMESPACE(X) namespace X _GLIBCXX_VISIBILITY_ATTR(default) {
# define _GLIBCXX_END_NAMESPACE }
-# define _GLIBCXX_EXTERN_TEMPLATE -1
# endif
# if __NO_INLINE__ && !__GXX_WEAK__
@@ -287,6 +285,10 @@ namespace std
// library to avoid multiple weak definitions for required types that
// are already explicitly instantiated in the library binary. This
// substantially reduces the binary size of resulting executables.
+
+// Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern
+// templates only in basic_string, thus activating its debug-mode
+// checks even at -O0.
#ifndef _GLIBCXX_EXTERN_TEMPLATE
# define _GLIBCXX_EXTERN_TEMPLATE 1
#endif
diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h
index 06aa6f87b91..2c2c79ca16b 100644
--- a/libstdc++-v3/include/bits/random.h
+++ b/libstdc++-v3/include/bits/random.h
@@ -32,7 +32,6 @@
namespace std
{
-
// [26.4] Random number generation
/**
@@ -154,10 +153,10 @@ namespace std
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
class linear_congruential_engine
{
- __glibcxx_class_requires(_UIntType, _UnsignedIntegerConcept)
- static_assert(__m == 0 || (__a < __m && __c < __m),
- "template arguments out of bounds"
- " in linear_congruential_engine");
+ static_assert(std::is_unsigned<_UIntType>::value, "template argument "
+ "_UIntType not an unsigned integral type");
+ static_assert(__m == 0u || (__a < __m && __c < __m),
+ "template argument __m out of bounds");
public:
/** The type of the generated random value. */
@@ -341,35 +340,27 @@ namespace std
_UIntType __c, size_t __l, _UIntType __f>
class mersenne_twister_engine
{
- __glibcxx_class_requires(_UIntType, _UnsignedIntegerConcept)
-
- static_assert(__m >= 1U,
- "mersenne_twister_engine template arguments out of bounds");
- static_assert(__n >= __m,
- "mersenne_twister_engine template arguments out of bounds");
- static_assert(__w >= __r,
- "mersenne_twister_engine template arguments out of bounds");
- static_assert(__w >= __u,
- "mersenne_twister_engine template arguments out of bounds");
- static_assert(__w >= __s,
- "mersenne_twister_engine template arguments out of bounds");
- static_assert(__w >= __t,
- "mersenne_twister_engine template arguments out of bounds");
- static_assert(__w >= __l,
- "mersenne_twister_engine template arguments out of bounds");
- static_assert(__w <=
- static_cast<size_t>(std::numeric_limits<_UIntType>::digits),
- "mersenne_twister_engine template arguments out of bounds");
+ static_assert(std::is_unsigned<_UIntType>::value, "template argument "
+ "_UIntType not an unsigned integral type");
+ static_assert(1u <= __m && __m <= __n,
+ "template argument __m out of bounds");
+ static_assert(__r <= __w, "template argument __r out of bound");
+ static_assert(__u <= __w, "template argument __u out of bound");
+ static_assert(__s <= __w, "template argument __s out of bound");
+ static_assert(__t <= __w, "template argument __t out of bound");
+ static_assert(__l <= __w, "template argument __l out of bound");
+ static_assert(__w <= std::numeric_limits<_UIntType>::digits,
+ "template argument __w out of bound");
static_assert(__a <= (__detail::_Shift<_UIntType, __w>::__value - 1),
- "mersenne_twister_engine template arguments out of bounds");
+ "template argument __a out of bound");
static_assert(__b <= (__detail::_Shift<_UIntType, __w>::__value - 1),
- "mersenne_twister_engine template arguments out of bounds");
+ "template argument __b out of bound");
static_assert(__c <= (__detail::_Shift<_UIntType, __w>::__value - 1),
- "mersenne_twister_engine template arguments out of bounds");
+ "template argument __c out of bound");
static_assert(__d <= (__detail::_Shift<_UIntType, __w>::__value - 1),
- "mersenne_twister_engine template arguments out of bounds");
+ "template argument __d out of bound");
static_assert(__f <= (__detail::_Shift<_UIntType, __w>::__value - 1),
- "mersenne_twister_engine template arguments out of bounds");
+ "template argument __f out of bound");
public:
/** The type of the generated random value. */
@@ -538,13 +529,12 @@ namespace std
template<typename _UIntType, size_t __w, size_t __s, size_t __r>
class subtract_with_carry_engine
{
- __glibcxx_class_requires(_UIntType, _UnsignedIntegerConcept)
- static_assert(__s > 0U && __r > __s
- && __w > 0U
- && __w <= static_cast<size_t>
- (std::numeric_limits<_UIntType>::digits),
- "template arguments out of bounds"
- " in subtract_with_carry_engine");
+ static_assert(std::is_unsigned<_UIntType>::value, "template argument "
+ "_UIntType not an unsigned integral type");
+ static_assert(0u < __s && __s < __r,
+ "template argument __s out of bounds");
+ static_assert(0u < __w && __w <= std::numeric_limits<_UIntType>::digits,
+ "template argument __w out of bounds");
public:
/** The type of the generated random value. */
@@ -702,9 +692,8 @@ namespace std
template<typename _RandomNumberEngine, size_t __p, size_t __r>
class discard_block_engine
{
- static_assert(__r >= 1U && __p >= __r,
- "template arguments out of bounds"
- " in discard_block_engine");
+ static_assert(1 <= __r && __r <= __p,
+ "template argument __r out of bounds");
public:
/** The type of the generated random value. */
@@ -903,12 +892,10 @@ namespace std
template<typename _RandomNumberEngine, size_t __w, typename _UIntType>
class independent_bits_engine
{
- static_assert(__w > 0U
- && __w <=
- static_cast<size_t>
- (std::numeric_limits<_UIntType>::digits),
- "template arguments out of bounds "
- "in independent_bits_engine");
+ static_assert(std::is_unsigned<_UIntType>::value, "template argument "
+ "_UIntType not an unsigned integral type");
+ static_assert(0u < __w && __w <= std::numeric_limits<_UIntType>::digits,
+ "template argument __w out of bounds");
public:
/** The type of the generated random value. */
@@ -1102,9 +1089,7 @@ namespace std
template<typename _RandomNumberEngine, size_t __k>
class shuffle_order_engine
{
- static_assert(__k >= 1U,
- "template arguments out of bounds"
- " in shuffle_order_engine");
+ static_assert(1u <= __k, "template argument __k out of bound");
public:
/** The type of the generated random value. */
@@ -1480,7 +1465,8 @@ namespace std
template<typename _IntType = int>
class uniform_int_distribution
{
- __glibcxx_class_requires(_IntType, _IntegerConcept)
+ static_assert(std::is_integral<_IntType>::value,
+ "template argument not an integral type");
public:
/** The type of the range of the distribution. */
@@ -1633,6 +1619,9 @@ namespace std
template<typename _RealType = double>
class uniform_real_distribution
{
+ static_assert(std::is_floating_point<_RealType>::value,
+ "template argument not a floating point type");
+
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
@@ -1791,6 +1780,9 @@ namespace std
template<typename _RealType = double>
class normal_distribution
{
+ static_assert(std::is_floating_point<_RealType>::value,
+ "template argument not a floating point type");
+
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
@@ -1943,6 +1935,9 @@ namespace std
template<typename _RealType = double>
class lognormal_distribution
{
+ static_assert(std::is_floating_point<_RealType>::value,
+ "template argument not a floating point type");
+
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
@@ -2086,6 +2081,9 @@ namespace std
template<typename _RealType = double>
class gamma_distribution
{
+ static_assert(std::is_floating_point<_RealType>::value,
+ "template argument not a floating point type");
+
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
@@ -2243,6 +2241,9 @@ namespace std
template<typename _RealType = double>
class chi_squared_distribution
{
+ static_assert(std::is_floating_point<_RealType>::value,
+ "template argument not a floating point type");
+
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
@@ -2378,6 +2379,9 @@ namespace std
template<typename _RealType = double>
class cauchy_distribution
{
+ static_assert(std::is_floating_point<_RealType>::value,
+ "template argument not a floating point type");
+
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
@@ -2519,6 +2523,9 @@ namespace std
template<typename _RealType = double>
class fisher_f_distribution
{
+ static_assert(std::is_floating_point<_RealType>::value,
+ "template argument not a floating point type");
+
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
@@ -2670,6 +2677,9 @@ namespace std
template<typename _RealType = double>
class student_t_distribution
{
+ static_assert(std::is_floating_point<_RealType>::value,
+ "template argument not a floating point type");
+
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
@@ -2972,7 +2982,8 @@ namespace std
template<typename _IntType = int>
class binomial_distribution
{
- __glibcxx_class_requires(_IntType, _IntegerConcept)
+ static_assert(std::is_integral<_IntType>::value,
+ "template argument not an integral type");
public:
/** The type of the range of the distribution. */
@@ -3142,7 +3153,8 @@ namespace std
template<typename _IntType = int>
class geometric_distribution
{
- __glibcxx_class_requires(_IntType, _IntegerConcept)
+ static_assert(std::is_integral<_IntType>::value,
+ "template argument not an integral type");
public:
/** The type of the range of the distribution. */
@@ -3287,7 +3299,8 @@ namespace std
template<typename _IntType = int>
class negative_binomial_distribution
{
- __glibcxx_class_requires(_IntType, _IntegerConcept)
+ static_assert(std::is_integral<_IntType>::value,
+ "template argument not an integral type");
public:
/** The type of the range of the distribution. */
@@ -3439,7 +3452,8 @@ namespace std
template<typename _IntType = int>
class poisson_distribution
{
- __glibcxx_class_requires(_IntType, _IntegerConcept)
+ static_assert(std::is_integral<_IntType>::value,
+ "template argument not an integral type");
public:
/** The type of the range of the distribution. */
@@ -3594,6 +3608,9 @@ namespace std
template<typename _RealType = double>
class exponential_distribution
{
+ static_assert(std::is_floating_point<_RealType>::value,
+ "template argument not a floating point type");
+
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
@@ -3736,6 +3753,9 @@ namespace std
template<typename _RealType = double>
class weibull_distribution
{
+ static_assert(std::is_floating_point<_RealType>::value,
+ "template argument not a floating point type");
+
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
@@ -3879,6 +3899,9 @@ namespace std
template<typename _RealType = double>
class extreme_value_distribution
{
+ static_assert(std::is_floating_point<_RealType>::value,
+ "template argument not a floating point type");
+
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
@@ -4021,7 +4044,8 @@ namespace std
template<typename _IntType = int>
class discrete_distribution
{
- __glibcxx_class_requires(_IntType, _IntegerConcept)
+ static_assert(std::is_integral<_IntType>::value,
+ "template argument not an integral type");
public:
/** The type of the range of the distribution. */
@@ -4185,6 +4209,9 @@ namespace std
template<typename _RealType = double>
class piecewise_constant_distribution
{
+ static_assert(std::is_floating_point<_RealType>::value,
+ "template argument not a floating point type");
+
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
@@ -4363,6 +4390,9 @@ namespace std
template<typename _RealType = double>
class piecewise_linear_distribution
{
+ static_assert(std::is_floating_point<_RealType>::value,
+ "template argument not a floating point type");
+
public:
/** The type of the range of the distribution. */
typedef _RealType result_type;
diff --git a/libstdc++-v3/include/bits/valarray_array.h b/libstdc++-v3/include/bits/valarray_array.h
index 492891bc9d8..a12b3347b9d 100644
--- a/libstdc++-v3/include/bits/valarray_array.h
+++ b/libstdc++-v3/include/bits/valarray_array.h
@@ -1,7 +1,7 @@
// The template and inlines for the -*- C++ -*- internal _Array helper class.
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-// 2006, 2007, 2009
+// 2006, 2007, 2008, 2009
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -73,7 +73,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// Please note that this isn't exception safe. But
// valarrays aren't required to be exception safe.
inline static void
- _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e)
+ _S_do_it(_Tp* __b, _Tp* __e)
{
while (__b != __e)
new(__b++) _Tp();
@@ -85,13 +85,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{
// For fundamental types, it suffices to say 'memset()'
inline static void
- _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e)
+ _S_do_it(_Tp* __b, _Tp* __e)
{ __builtin_memset(__b, 0, (__e - __b) * sizeof(_Tp)); }
};
template<typename _Tp>
inline void
- __valarray_default_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e)
+ __valarray_default_construct(_Tp* __b, _Tp* __e)
{
_Array_default_ctor<_Tp, __is_scalar<_Tp>::__value>::_S_do_it(__b, __e);
}
@@ -105,7 +105,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// Please note that this isn't exception safe. But
// valarrays aren't required to be exception safe.
inline static void
- _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e, const _Tp __t)
+ _S_do_it(_Tp* __b, _Tp* __e, const _Tp __t)
{
while (__b != __e)
new(__b++) _Tp(__t);
@@ -116,7 +116,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
struct _Array_init_ctor<_Tp, true>
{
inline static void
- _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e, const _Tp __t)
+ _S_do_it(_Tp* __b, _Tp* __e, const _Tp __t)
{
while (__b != __e)
*__b++ = __t;
@@ -125,8 +125,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp>
inline void
- __valarray_fill_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e,
- const _Tp __t)
+ __valarray_fill_construct(_Tp* __b, _Tp* __e, const _Tp __t)
{
_Array_init_ctor<_Tp, __is_pod(_Tp)>::_S_do_it(__b, __e, __t);
}
@@ -141,8 +140,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// Please note that this isn't exception safe. But
// valarrays aren't required to be exception safe.
inline static void
- _S_do_it(const _Tp* __restrict__ __b, const _Tp* __restrict__ __e,
- _Tp* __restrict__ __o)
+ _S_do_it(const _Tp* __b, const _Tp* __e, _Tp* __restrict__ __o)
{
while (__b != __e)
new(__o++) _Tp(*__b++);
@@ -153,15 +151,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
struct _Array_copy_ctor<_Tp, true>
{
inline static void
- _S_do_it(const _Tp* __restrict__ __b, const _Tp* __restrict__ __e,
- _Tp* __restrict__ __o)
+ _S_do_it(const _Tp* __b, const _Tp* __e, _Tp* __restrict__ __o)
{ __builtin_memcpy(__o, __b, (__e - __b) * sizeof(_Tp)); }
};
template<typename _Tp>
inline void
- __valarray_copy_construct(const _Tp* __restrict__ __b,
- const _Tp* __restrict__ __e,
+ __valarray_copy_construct(const _Tp* __b, const _Tp* __e,
_Tp* __restrict__ __o)
{
_Array_copy_ctor<_Tp, __is_pod(_Tp)>::_S_do_it(__b, __e, __o);
@@ -205,7 +201,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// Do the necessary cleanup when we're done with arrays.
template<typename _Tp>
inline void
- __valarray_destroy_elements(_Tp* __restrict__ __b, _Tp* __restrict__ __e)
+ __valarray_destroy_elements(_Tp* __b, _Tp* __e)
{
if (!__is_pod(_Tp))
while (__b != __e)
@@ -347,7 +343,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
//
template<typename _Tp>
inline _Tp
- __valarray_sum(const _Tp* __restrict__ __f, const _Tp* __restrict__ __l)
+ __valarray_sum(const _Tp* __f, const _Tp* __l)
{
_Tp __r = _Tp();
while (__f != __l)
@@ -358,8 +354,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// Compute the product of all elements in range [__f, __l)
template<typename _Tp>
inline _Tp
- __valarray_product(const _Tp* __restrict__ __f,
- const _Tp* __restrict__ __l)
+ __valarray_product(const _Tp* __f, const _Tp* __l)
{
_Tp __r = _Tp(1);
while (__f != __l)