Commit 46db4159 by Benjamin Kosnik Committed by Benjamin Kosnik

re PR libstdc++/28514 (libstdc++ vs. anonymous namespaces)

2006-10-17  Benjamin Kosnik  <bkoz@redhat.com>

	PR libstdc++/28514 
	* include/bits/cpp_type_traits.h (__detail): Uglify namespace.
	* include/ext/rope: Remove global-scope anonymous namespace, use
	nested __detail. Fixup resulting formatting issues.
	* include/ext/ropeimpl.h: Same.
	* include/tr1/hashtable_policy.h: Remove anonymous namespace
	nesting for __detail.
	* include/tr1/random: Revert anonymous namespace to nested
	__detail namespace.
	* include/tr1/random.tcc: Same.
	* src/ext-inst.cc: Fixups for above.

From-SVN: r117824
parent e4fd3c84
2006-10-17 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/28514
* include/bits/cpp_type_traits.h (__detail): Uglify namespace.
* include/ext/rope: Remove global-scope anonymous namespace, use
nested __detail. Fixup resulting formatting issues.
* include/ext/ropeimpl.h: Same.
* include/tr1/hashtable_policy.h: Remove anonymous namespace
nesting for __detail.
* include/tr1/random: Revert anonymous namespace to nested
__detail namespace.
* include/tr1/random.tcc: Same.
* src/ext-inst.cc: Fixups for above.
2006-10-16 Douglas Gregor <doug.gregor@gmail.com> 2006-10-16 Douglas Gregor <doug.gregor@gmail.com>
* include/Makefile.am (tr1_headers): Add new tuple_defs.h. * include/Makefile.am (tr1_headers): Add new tuple_defs.h.
......
...@@ -83,7 +83,7 @@ struct __false_type { }; ...@@ -83,7 +83,7 @@ struct __false_type { };
_GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_BEGIN_NAMESPACE(std)
namespace detail namespace __detail
{ {
// NB: g++ can not compile these if declared within the class // NB: g++ can not compile these if declared within the class
// __is_pod itself. // __is_pod itself.
...@@ -94,7 +94,7 @@ namespace detail ...@@ -94,7 +94,7 @@ namespace detail
__one __test_type(int _Tp::*); __one __test_type(int _Tp::*);
template<typename _Tp> template<typename _Tp>
__two& __test_type(...); __two& __test_type(...);
} // namespace detail } // namespace __detail
template<bool> template<bool>
struct __truth_type struct __truth_type
...@@ -346,8 +346,8 @@ namespace detail ...@@ -346,8 +346,8 @@ namespace detail
{ {
enum enum
{ {
__value = (sizeof(detail::__test_type<_Tp>(0)) __value = (sizeof(__detail::__test_type<_Tp>(0))
!= sizeof(detail::__one)) != sizeof(__detail::__one))
}; };
}; };
......
...@@ -43,8 +43,6 @@ namespace std ...@@ -43,8 +43,6 @@ namespace std
_GLIBCXX_BEGIN_NAMESPACE(tr1) _GLIBCXX_BEGIN_NAMESPACE(tr1)
namespace __detail namespace __detail
{ {
namespace
{
// Helper function: return distance(first, last) for forward // Helper function: return distance(first, last) for forward
// iterators, or 0 for input iterators. // iterators, or 0 for input iterators.
template<class _Iterator> template<class _Iterator>
...@@ -168,7 +166,6 @@ namespace ...@@ -168,7 +166,6 @@ namespace
(unsigned long)18446744073709551557ull, (unsigned long)18446744073709551557ull,
(unsigned long)18446744073709551557ull (unsigned long)18446744073709551557ull
}; };
} // anonymous namespace
// Auxiliary types used for all instantiations of _Hashtable: nodes // Auxiliary types used for all instantiations of _Hashtable: nodes
// and iterators. // and iterators.
......
...@@ -62,7 +62,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -62,7 +62,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
/* /*
* Implementation-space details. * Implementation-space details.
*/ */
namespace namespace __detail
{ {
template<typename _UIntType, int __w, template<typename _UIntType, int __w,
bool = __w < std::numeric_limits<_UIntType>::digits> bool = __w < std::numeric_limits<_UIntType>::digits>
...@@ -85,7 +85,6 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -85,7 +85,6 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
typedef __gnu_cxx::__conditional_type<(sizeof(unsigned) == 4), typedef __gnu_cxx::__conditional_type<(sizeof(unsigned) == 4),
unsigned, unsigned long>::__type _UInt32Type; unsigned, unsigned long>::__type _UInt32Type;
} // anonymous namespace
/* /*
* An adaptor class for converting the output of any Generator into * An adaptor class for converting the output of any Generator into
...@@ -158,7 +157,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -158,7 +157,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
/ result_type(_M_g.max() - _M_g.min()); / result_type(_M_g.max() - _M_g.min());
return __return_value; return __return_value;
} }
} // namespace __detail
/** /**
* Produces random numbers on a given disribution function using a un uniform * Produces random numbers on a given disribution function using a un uniform
...@@ -176,7 +175,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -176,7 +175,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
public: public:
typedef _Engine engine_type; typedef _Engine engine_type;
typedef _Adaptor<_Engine, _Dist> engine_value_type; typedef __detail::_Adaptor<_Engine, _Dist> engine_value_type;
typedef _Dist distribution_type; typedef _Dist distribution_type;
typedef typename _Dist::result_type result_type; typedef typename _Dist::result_type result_type;
...@@ -184,7 +183,6 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -184,7 +183,6 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
typedef typename __gnu_cxx::__enable_if< typedef typename __gnu_cxx::__enable_if<
is_arithmetic<result_type>::value, result_type>::__type _IsValidType; is_arithmetic<result_type>::value, result_type>::__type _IsValidType;
public:
/** /**
* Constructs a variate generator with the uniform random number * Constructs a variate generator with the uniform random number
* generator @p __eng for the random distribution @p __dist. * generator @p __eng for the random distribution @p __dist.
...@@ -360,7 +358,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -360,7 +358,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
*/ */
result_type result_type
min() const min() const
{ return (__mod<_UIntType, 1, 0, __m>(__c) == 0) ? 1 : 0; } { return (__detail::__mod<_UIntType, 1, 0, __m>(__c) == 0) ? 1 : 0; }
/** /**
* Gets the largest possible value in the output range. * Gets the largest possible value in the output range.
...@@ -448,7 +446,6 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -448,7 +446,6 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
void void
seed(_Gen& __g, false_type); seed(_Gen& __g, false_type);
private:
_UIntType _M_x; _UIntType _M_x;
}; };
...@@ -542,7 +539,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -542,7 +539,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
result_type result_type
max() const max() const
{ return _Shift<_UIntType, __w>::__value - 1; } { return __detail::_Shift<_UIntType, __w>::__value - 1; }
result_type result_type
operator()(); operator()();
...@@ -625,7 +622,6 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -625,7 +622,6 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
void void
seed(_Gen& __g, false_type); seed(_Gen& __g, false_type);
private:
_UIntType _M_x[state_size]; _UIntType _M_x[state_size];
int _M_p; int _M_p;
}; };
...@@ -682,7 +678,6 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -682,7 +678,6 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
static const int long_lag = __r; static const int long_lag = __r;
static const int short_lag = __s; static const int short_lag = __s;
public:
/** /**
* Constructs a default-initialized % subtract_with_carry random number * Constructs a default-initialized % subtract_with_carry random number
* generator. * generator.
...@@ -826,7 +821,6 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -826,7 +821,6 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
void void
seed(_Gen& __g, false_type); seed(_Gen& __g, false_type);
private:
typedef typename __gnu_cxx::__add_unsigned<_IntType>::__type _UIntType; typedef typename __gnu_cxx::__add_unsigned<_IntType>::__type _UIntType;
_UIntType _M_x[long_lag]; _UIntType _M_x[long_lag];
...@@ -857,7 +851,6 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -857,7 +851,6 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
static const int long_lag = __r; static const int long_lag = __r;
static const int short_lag = __s; static const int short_lag = __s;
public:
/** /**
* Constructs a default-initialized % subtract_with_carry_01 random * Constructs a default-initialized % subtract_with_carry_01 random
* number generator. * number generator.
...@@ -1011,12 +1004,12 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -1011,12 +1004,12 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
void void
seed(_Gen& __g, false_type); seed(_Gen& __g, false_type);
private:
void void
_M_initialize_npows(); _M_initialize_npows();
static const int __n = (__w + 31) / 32; static const int __n = (__w + 31) / 32;
typedef __detail::_UInt32Type _UInt32Type;
_UInt32Type _M_x[long_lag][__n]; _UInt32Type _M_x[long_lag][__n];
_RealType _M_npows[__n]; _RealType _M_npows[__n];
_UInt32Type _M_carry; _UInt32Type _M_carry;
......
...@@ -34,7 +34,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -34,7 +34,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
/* /*
* (Further) implementation-space details. * (Further) implementation-space details.
*/ */
namespace namespace __detail
{ {
// General case for x = (ax + c) mod m -- use Schrage's algorithm to avoid // General case for x = (ax + c) mod m -- use Schrage's algorithm to avoid
// integer overflow. // integer overflow.
...@@ -86,8 +86,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -86,8 +86,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
__calc(_Tp __x) __calc(_Tp __x)
{ return __a * __x + __c; } { return __a * __x + __c; }
}; };
} // anonymous namespace } // namespace __detail
/** /**
* Seeds the LCR with integral value @p __x0, adjusted so that the * Seeds the LCR with integral value @p __x0, adjusted so that the
...@@ -98,11 +97,11 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -98,11 +97,11 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
linear_congruential<_UIntType, __a, __c, __m>:: linear_congruential<_UIntType, __a, __c, __m>::
seed(unsigned long __x0) seed(unsigned long __x0)
{ {
if ((__mod<_UIntType, 1, 0, __m>(__c) == 0) if ((__detail::__mod<_UIntType, 1, 0, __m>(__c) == 0)
&& (__mod<_UIntType, 1, 0, __m>(__x0) == 0)) && (__detail::__mod<_UIntType, 1, 0, __m>(__x0) == 0))
_M_x = __mod<_UIntType, 1, 0, __m>(1); _M_x = __detail::__mod<_UIntType, 1, 0, __m>(1);
else else
_M_x = __mod<_UIntType, 1, 0, __m>(__x0); _M_x = __detail::__mod<_UIntType, 1, 0, __m>(__x0);
} }
/** /**
...@@ -115,11 +114,11 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -115,11 +114,11 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
seed(_Gen& __g, false_type) seed(_Gen& __g, false_type)
{ {
_UIntType __x0 = __g(); _UIntType __x0 = __g();
if ((__mod<_UIntType, 1, 0, __m>(__c) == 0) if ((__detail::__mod<_UIntType, 1, 0, __m>(__c) == 0)
&& (__mod<_UIntType, 1, 0, __m>(__x0) == 0)) && (__detail::__mod<_UIntType, 1, 0, __m>(__x0) == 0))
_M_x = __mod<_UIntType, 1, 0, __m>(1); _M_x = __detail::__mod<_UIntType, 1, 0, __m>(1);
else else
_M_x = __mod<_UIntType, 1, 0, __m>(__x0); _M_x = __detail::__mod<_UIntType, 1, 0, __m>(__x0);
} }
/** /**
...@@ -130,7 +129,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -130,7 +129,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
linear_congruential<_UIntType, __a, __c, __m>:: linear_congruential<_UIntType, __a, __c, __m>::
operator()() operator()()
{ {
_M_x = __mod<_UIntType, __a, __c, __m>(_M_x); _M_x = __detail::__mod<_UIntType, __a, __c, __m>(_M_x);
return _M_x; return _M_x;
} }
...@@ -177,8 +176,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -177,8 +176,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
__b, __t, __c, __l>:: __b, __t, __c, __l>::
seed(unsigned long __value) seed(unsigned long __value)
{ {
_M_x[0] = __mod<_UIntType, 1, 0, _M_x[0] = __detail::__mod<_UIntType, 1, 0,
_Shift<_UIntType, __w>::__value>(__value); __detail::_Shift<_UIntType, __w>::__value>(__value);
for (int __i = 1; __i < state_size; ++__i) for (int __i = 1; __i < state_size; ++__i)
{ {
...@@ -186,8 +185,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -186,8 +185,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
__x ^= __x >> (__w - 2); __x ^= __x >> (__w - 2);
__x *= 1812433253ul; __x *= 1812433253ul;
__x += __i; __x += __i;
_M_x[__i] = __mod<_UIntType, 1, 0, _M_x[__i] = __detail::__mod<_UIntType, 1, 0,
_Shift<_UIntType, __w>::__value>(__x); __detail::_Shift<_UIntType, __w>::__value>(__x);
} }
_M_p = state_size; _M_p = state_size;
} }
...@@ -202,8 +201,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -202,8 +201,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
seed(_Gen& __gen, false_type) seed(_Gen& __gen, false_type)
{ {
for (int __i = 0; __i < state_size; ++__i) for (int __i = 0; __i < state_size; ++__i)
_M_x[__i] = __mod<_UIntType, 1, 0, _M_x[__i] = __detail::__mod<_UIntType, 1, 0,
_Shift<_UIntType, __w>::__value>(__gen()); __detail::_Shift<_UIntType, __w>::__value>(__gen());
_M_p = state_size; _M_p = state_size;
} }
...@@ -313,7 +312,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -313,7 +312,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
__lcg(__value); __lcg(__value);
for (int __i = 0; __i < long_lag; ++__i) for (int __i = 0; __i < long_lag; ++__i)
_M_x[__i] = __mod<_UIntType, 1, 0, modulus>(__lcg()); _M_x[__i] = __detail::__mod<_UIntType, 1, 0, modulus>(__lcg());
_M_carry = (_M_x[long_lag - 1] == 0) ? 1 : 0; _M_carry = (_M_x[long_lag - 1] == 0) ? 1 : 0;
_M_p = 0; _M_p = 0;
...@@ -333,10 +332,10 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -333,10 +332,10 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
_UIntType __factor = 1; _UIntType __factor = 1;
for (int __j = 0; __j < __n; ++__j) for (int __j = 0; __j < __n; ++__j)
{ {
__tmp += __mod<_UInt32Type, 1, 0, 0>(__gen()) * __factor; __tmp += __detail::__mod<__detail::_UInt32Type, 1, 0, 0>(__gen()) * __factor;
__factor *= _Shift<_UIntType, 32>::__value; __factor *= __detail::_Shift<_UIntType, 32>::__value;
} }
_M_x[__i] = __mod<_UIntType, 1, 0, modulus>(__tmp); _M_x[__i] = __detail::__mod<_UIntType, 1, 0, modulus>(__tmp);
} }
_M_carry = (_M_x[long_lag - 1] == 0) ? 1 : 0; _M_carry = (_M_x[long_lag - 1] == 0) ? 1 : 0;
_M_p = 0; _M_p = 0;
...@@ -453,9 +452,9 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -453,9 +452,9 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
for (int __i = 0; __i < long_lag; ++__i) for (int __i = 0; __i < long_lag; ++__i)
{ {
for (int __j = 0; __j < __n - 1; ++__j) for (int __j = 0; __j < __n - 1; ++__j)
_M_x[__i][__j] = __mod<_UInt32Type, 1, 0, 0>(__gen()); _M_x[__i][__j] = __detail::__mod<_UInt32Type, 1, 0, 0>(__gen());
_M_x[__i][__n - 1] = __mod<_UInt32Type, 1, 0, _M_x[__i][__n - 1] = __detail::__mod<_UInt32Type, 1, 0,
_Shift<_UInt32Type, __w % 32>::__value>(__gen()); __detail::_Shift<_UInt32Type, __w % 32>::__value>(__gen());
} }
_M_carry = 1; _M_carry = 1;
...@@ -498,8 +497,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -498,8 +497,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
else else
__new_carry = 1; __new_carry = 1;
_M_x[_M_p][__n - 1] = __mod<_UInt32Type, 1, 0, _M_x[_M_p][__n - 1] = __detail::__mod<_UInt32Type, 1, 0,
_Shift<_UInt32Type, __w % 32>::__value> __detail::_Shift<_UInt32Type, __w % 32>::__value>
(_M_x[__ps][__n - 1] - _M_x[_M_p][__n - 1] - _M_carry); (_M_x[__ps][__n - 1] - _M_x[_M_p][__n - 1] - _M_carry);
_M_carry = __new_carry; _M_carry = __new_carry;
...@@ -623,11 +622,11 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) ...@@ -623,11 +622,11 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
const result_type __m1 = const result_type __m1 =
std::min(result_type(_M_b1.max() - _M_b1.min()), std::min(result_type(_M_b1.max() - _M_b1.min()),
_Shift<result_type, __w - __s1>::__value - 1); __detail::_Shift<result_type, __w - __s1>::__value - 1);
const result_type __m2 = const result_type __m2 =
std::min(result_type(_M_b2.max() - _M_b2.min()), std::min(result_type(_M_b2.max() - _M_b2.min()),
_Shift<result_type, __w - __s2>::__value - 1); __detail::_Shift<result_type, __w - __s2>::__value - 1);
// NB: In TR1 s1 is not required to be >= s2. // NB: In TR1 s1 is not required to be >= s2.
if (__s1 < __s2) if (__s1 < __s2)
......
...@@ -34,13 +34,13 @@ ...@@ -34,13 +34,13 @@
#include <ext/rope> #include <ext/rope>
#include <ext/stdio_filebuf.h> #include <ext/stdio_filebuf.h>
namespace
{
const int min_len = _S_max_rope_depth + 1;
}
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
namespace
{
const int min_len = __detail::_S_max_rope_depth + 1;
}
template template
const unsigned long const unsigned long
rope<char, std::allocator<char> >::_S_min_len[min_len]; rope<char, std::allocator<char> >::_S_min_len[min_len];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment