Commit ff89096a by Paolo Carlini Committed by Paolo Carlini

cpp_type_traits.h: Move the additions to namespace __gnu_internal outside of namespace std...

2004-06-28  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/cpp_type_traits.h: Move the additions to
	namespace __gnu_internal outside of namespace std; trivial
	formatting fixes.

From-SVN: r83806
parent 4723805a
2004-06-28 Paolo Carlini <pcarlini@suse.de>
* include/bits/cpp_type_traits.h: Move the additions to
namespace __gnu_internal outside of namespace std; trivial
formatting fixes.
2004-06-28 Benjamin Kosnik <bkoz@redhat.com> 2004-06-28 Benjamin Kosnik <bkoz@redhat.com>
* include/debug/safe_base.h (__gnu_debug::_Safe_sequence_base): * include/debug/safe_base.h (__gnu_debug::_Safe_sequence_base):
......
// The -*- C++ -*- type traits classes for internal use in libstdc++ // The -*- C++ -*- type traits classes for internal use in libstdc++
// Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. // Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -64,6 +64,19 @@ ...@@ -64,6 +64,19 @@
// -- Gaby (dosreis@cmla.ens-cachan.fr) 2000-03-06. // -- Gaby (dosreis@cmla.ens-cachan.fr) 2000-03-06.
// //
// NB: g++ can not compile these if declared within the class
// __is_pod itself.
namespace __gnu_internal
{
typedef char __one;
typedef char __two[2];
template <typename _Tp>
__one __test_type (int _Tp::*);
template <typename _Tp>
__two& __test_type (...);
} // namespace __gnu_internal
namespace std namespace std
{ {
// Compare for equality of types. // Compare for equality of types.
...@@ -71,18 +84,18 @@ namespace std ...@@ -71,18 +84,18 @@ namespace std
struct __are_same struct __are_same
{ {
enum enum
{ {
_M_type = 0 _M_type = 0
}; };
}; };
template<typename _Tp> template<typename _Tp>
struct __are_same<_Tp, _Tp> struct __are_same<_Tp, _Tp>
{ {
enum enum
{ {
_M_type = 1 _M_type = 1
}; };
}; };
// Define a nested type if some predicate holds. // Define a nested type if some predicate holds.
...@@ -92,7 +105,7 @@ namespace std ...@@ -92,7 +105,7 @@ namespace std
}; };
template<typename _Tp> template<typename _Tp>
struct __enable_if<_Tp, true> struct __enable_if<_Tp, true>
{ {
typedef _Tp _M_type; typedef _Tp _M_type;
}; };
...@@ -102,18 +115,18 @@ namespace std ...@@ -102,18 +115,18 @@ namespace std
struct __is_void struct __is_void
{ {
enum enum
{ {
_M_type = 0 _M_type = 0
}; };
}; };
template<> template<>
struct __is_void<void> struct __is_void<void>
{ {
enum enum
{ {
_M_type = 1 _M_type = 1
}; };
}; };
// //
...@@ -123,9 +136,9 @@ namespace std ...@@ -123,9 +136,9 @@ namespace std
struct __is_integer struct __is_integer
{ {
enum enum
{ {
_M_type = 0 _M_type = 0
}; };
}; };
// Thirteen specializations (yes there are eleven standard integer // Thirteen specializations (yes there are eleven standard integer
...@@ -135,213 +148,198 @@ namespace std ...@@ -135,213 +148,198 @@ namespace std
struct __is_integer<bool> struct __is_integer<bool>
{ {
enum enum
{ {
_M_type = 1 _M_type = 1
}; };
}; };
template<> template<>
struct __is_integer<char> struct __is_integer<char>
{ {
enum enum
{ {
_M_type = 1 _M_type = 1
}; };
}; };
template<> template<>
struct __is_integer<signed char> struct __is_integer<signed char>
{ {
enum enum
{ {
_M_type = 1 _M_type = 1
}; };
}; };
template<> template<>
struct __is_integer<unsigned char> struct __is_integer<unsigned char>
{
enum
{ {
_M_type = 1 enum
{
_M_type = 1
};
}; };
};
# ifdef _GLIBCXX_USE_WCHAR_T # ifdef _GLIBCXX_USE_WCHAR_T
template<> template<>
struct __is_integer<wchar_t> struct __is_integer<wchar_t>
{
enum
{ {
_M_type = 1 enum
{
_M_type = 1
};
}; };
};
# endif # endif
template<> template<>
struct __is_integer<short> struct __is_integer<short>
{
enum
{ {
_M_type = 1 enum
{
_M_type = 1
};
}; };
};
template<> template<>
struct __is_integer<unsigned short> struct __is_integer<unsigned short>
{
enum
{ {
_M_type = 1 enum
{
_M_type = 1
};
}; };
};
template<> template<>
struct __is_integer<int> struct __is_integer<int>
{
enum
{ {
_M_type = 1 enum
{
_M_type = 1
};
}; };
};
template<> template<>
struct __is_integer<unsigned int> struct __is_integer<unsigned int>
{
enum
{ {
_M_type = 1 enum
{
_M_type = 1
};
}; };
};
template<> template<>
struct __is_integer<long> struct __is_integer<long>
{
enum
{ {
_M_type = 1 enum
{
_M_type = 1
};
}; };
};
template<> template<>
struct __is_integer<unsigned long> struct __is_integer<unsigned long>
{
enum
{ {
_M_type = 1 enum
{
_M_type = 1
};
}; };
};
template<> template<>
struct __is_integer<long long> struct __is_integer<long long>
{
enum
{ {
_M_type = 1 enum
{
_M_type = 1
};
}; };
};
template<> template<>
struct __is_integer<unsigned long long> struct __is_integer<unsigned long long>
{
enum
{ {
_M_type = 1 enum
{
_M_type = 1
};
}; };
};
// //
// Floating point types // Floating point types
// //
template<typename _Tp> template<typename _Tp>
struct __is_floating struct __is_floating
{
enum
{ {
_M_type = 0 enum
{
_M_type = 0
};
}; };
};
// three specializations (float, double and 'long double') // three specializations (float, double and 'long double')
template<> template<>
struct __is_floating<float> struct __is_floating<float>
{
enum
{ {
_M_type = 1 enum
{
_M_type = 1
};
}; };
};
template<> template<>
struct __is_floating<double> struct __is_floating<double>
{
enum
{ {
_M_type = 1 enum
{
_M_type = 1
};
}; };
};
template<> template<>
struct __is_floating<long double> struct __is_floating<long double>
{
enum
{ {
_M_type = 1 enum
{
_M_type = 1
};
}; };
};
// //
// An arithmetic type is an integer type or a floating point type // An arithmetic type is an integer type or a floating point type
// //
template<typename _Tp> template<typename _Tp>
struct __is_arithmetic struct __is_arithmetic
{
enum
{ {
_M_type = __is_integer<_Tp>::_M_type || __is_floating<_Tp>::_M_type enum
{
_M_type = __is_integer<_Tp>::_M_type || __is_floating<_Tp>::_M_type
};
}; };
};
// //
// A fundamental type is `void' or and arithmetic type // A fundamental type is `void' or and arithmetic type
// //
template<typename _Tp> template<typename _Tp>
struct __is_fundamental struct __is_fundamental
{
enum
{ {
_M_type = __is_void<_Tp>::_M_type || __is_arithmetic<_Tp>::_M_type enum
{
_M_type = __is_void<_Tp>::_M_type || __is_arithmetic<_Tp>::_M_type
};
}; };
};
// //
// For the immediate use, the following is a good approximation // For the immediate use, the following is a good approximation
// //
// NB: g++ can not compile these if declared within the class
// __is_pod itself.
namespace __gnu_internal
{
typedef char __one;
typedef char __two[2];
template <typename _Tp>
__one __test_type (int _Tp::*);
template <typename _Tp>
__two& __test_type (...);
}
template<typename _Tp> template<typename _Tp>
struct __is_pod struct __is_pod
{
enum
{ {
_M_type = (sizeof(__gnu_internal::__test_type<_Tp>(0)) != sizeof(__gnu_internal::__one)) enum
{
_M_type = (sizeof(__gnu_internal::__test_type<_Tp>(0))
!= sizeof(__gnu_internal::__one))
};
}; };
};
} // namespace std } // namespace std
#endif //_CPP_TYPE_TRAITS_H #endif //_CPP_TYPE_TRAITS_H
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