2008-11-07 16:44:20 +01:00
|
|
|
// Custom pointer adapter and sample storage policies
|
|
|
|
|
2010-06-06 23:46:38 +02:00
|
|
|
// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
|
2008-11-07 16:44:20 +01: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
|
2009-04-09 17:00:19 +02:00
|
|
|
// Free Software Foundation; either version 3, or (at your option)
|
2008-11-07 16:44:20 +01:00
|
|
|
// 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.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
|
|
// 3.1, as published by the Free Software Foundation.
|
2008-11-07 16:44:20 +01:00
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
/**
|
2010-12-19 10:21:16 +01:00
|
|
|
* @file ext/pointer.h
|
|
|
|
* This file is a GNU extension to the Standard C++ Library.
|
|
|
|
*
|
|
|
|
* @author Bob Walters
|
2008-11-07 16:44:20 +01:00
|
|
|
*
|
|
|
|
* Provides reusable _Pointer_adapter for assisting in the development of
|
2008-11-11 13:15:59 +01:00
|
|
|
* custom pointer types that can be used with the standard containers via
|
2008-11-07 16:44:20 +01:00
|
|
|
* the allocator::pointer and allocator::const_pointer typedefs.
|
|
|
|
*/
|
|
|
|
|
2008-11-11 13:15:59 +01:00
|
|
|
#ifndef _POINTER_H
|
|
|
|
#define _POINTER_H 1
|
2008-11-07 16:44:20 +01:00
|
|
|
|
2009-08-14 18:51:01 +02:00
|
|
|
#pragma GCC system_header
|
|
|
|
|
2008-11-11 13:15:59 +01:00
|
|
|
#include <iosfwd>
|
|
|
|
#include <bits/stl_iterator_base_types.h>
|
2008-11-07 16:44:20 +01:00
|
|
|
#include <ext/cast.h>
|
2009-01-04 20:51:18 +01:00
|
|
|
#include <ext/type_traits.h>
|
2011-06-05 22:28:38 +02:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
# include <bits/ptr_traits.h>
|
|
|
|
#endif
|
2008-11-07 16:44:20 +01:00
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief A storage policy for use with _Pointer_adapter<> which yields a
|
|
|
|
* standard pointer.
|
|
|
|
*
|
|
|
|
* A _Storage_policy is required to provide 4 things:
|
|
|
|
* 1) A get() API for returning the stored pointer value.
|
|
|
|
* 2) An set() API for storing a pointer value.
|
|
|
|
* 3) An element_type typedef to define the type this points to.
|
|
|
|
* 4) An operator<() to support pointer comparison.
|
|
|
|
* 5) An operator==() to support pointer comparison.
|
|
|
|
*/
|
2008-11-11 13:15:59 +01:00
|
|
|
template<typename _Tp>
|
2008-11-07 16:44:20 +01:00
|
|
|
class _Std_pointer_impl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// the type this pointer points to.
|
2008-11-11 13:15:59 +01:00
|
|
|
typedef _Tp element_type;
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
// A method to fetch the pointer value as a standard T* value;
|
2008-11-11 13:15:59 +01:00
|
|
|
inline _Tp*
|
2008-11-07 16:44:20 +01:00
|
|
|
get() const
|
|
|
|
{ return _M_value; }
|
|
|
|
|
|
|
|
// A method to set the pointer value, from a standard T* value;
|
|
|
|
inline void
|
|
|
|
set(element_type* __arg)
|
|
|
|
{ _M_value = __arg; }
|
|
|
|
|
|
|
|
// Comparison of pointers
|
|
|
|
inline bool
|
|
|
|
operator<(const _Std_pointer_impl& __rarg) const
|
|
|
|
{ return (_M_value < __rarg._M_value); }
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
operator==(const _Std_pointer_impl& __rarg) const
|
|
|
|
{ return (_M_value == __rarg._M_value); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
element_type* _M_value;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief A storage policy for use with _Pointer_adapter<> which stores
|
|
|
|
* the pointer's address as an offset value which is relative to
|
|
|
|
* its own address.
|
|
|
|
*
|
2009-08-14 18:51:01 +02:00
|
|
|
* This is intended for pointers within shared memory regions which
|
|
|
|
* might be mapped at different addresses by different processes.
|
|
|
|
* For null pointers, a value of 1 is used. (0 is legitimate
|
|
|
|
* sometimes for nodes in circularly linked lists) This value was
|
|
|
|
* chosen as the least likely to generate an incorrect null, As
|
|
|
|
* there is no reason why any normal pointer would point 1 byte into
|
2008-11-07 16:44:20 +01:00
|
|
|
* its own pointer address.
|
|
|
|
*/
|
2008-11-11 13:15:59 +01:00
|
|
|
template<typename _Tp>
|
2008-11-07 16:44:20 +01:00
|
|
|
class _Relative_pointer_impl
|
|
|
|
{
|
|
|
|
public:
|
2008-11-11 13:15:59 +01:00
|
|
|
typedef _Tp element_type;
|
2008-11-07 16:44:20 +01:00
|
|
|
|
2008-11-11 13:15:59 +01:00
|
|
|
_Tp*
|
2008-11-07 16:44:20 +01:00
|
|
|
get() const
|
|
|
|
{
|
|
|
|
if (_M_diff == 1)
|
2008-11-11 13:15:59 +01:00
|
|
|
return 0;
|
2008-11-07 16:44:20 +01:00
|
|
|
else
|
2009-01-04 20:51:18 +01:00
|
|
|
return reinterpret_cast<_Tp*>(reinterpret_cast<_UIntPtrType>(this)
|
|
|
|
+ _M_diff);
|
2008-11-07 16:44:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-11-11 13:15:59 +01:00
|
|
|
set(_Tp* __arg)
|
2008-11-07 16:44:20 +01:00
|
|
|
{
|
2008-11-11 13:15:59 +01:00
|
|
|
if (!__arg)
|
2008-11-07 16:44:20 +01:00
|
|
|
_M_diff = 1;
|
|
|
|
else
|
2009-01-04 20:51:18 +01:00
|
|
|
_M_diff = reinterpret_cast<_UIntPtrType>(__arg)
|
|
|
|
- reinterpret_cast<_UIntPtrType>(this);
|
2008-11-07 16:44:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Comparison of pointers
|
|
|
|
inline bool
|
|
|
|
operator<(const _Relative_pointer_impl& __rarg) const
|
2009-01-04 20:51:18 +01:00
|
|
|
{ return (reinterpret_cast<_UIntPtrType>(this->get())
|
|
|
|
< reinterpret_cast<_UIntPtrType>(__rarg.get())); }
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
inline bool
|
|
|
|
operator==(const _Relative_pointer_impl& __rarg) const
|
2009-01-04 20:51:18 +01:00
|
|
|
{ return (reinterpret_cast<_UIntPtrType>(this->get())
|
|
|
|
== reinterpret_cast<_UIntPtrType>(__rarg.get())); }
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
private:
|
2009-08-14 18:51:01 +02:00
|
|
|
#ifdef _GLIBCXX_USE_LONG_LONG
|
2009-01-04 20:51:18 +01:00
|
|
|
typedef __gnu_cxx::__conditional_type<
|
|
|
|
(sizeof(unsigned long) >= sizeof(void*)),
|
|
|
|
unsigned long, unsigned long long>::__type _UIntPtrType;
|
2009-08-14 18:51:01 +02:00
|
|
|
#else
|
|
|
|
typedef unsigned long _UIntPtrType;
|
|
|
|
#endif
|
2009-01-04 20:51:18 +01:00
|
|
|
_UIntPtrType _M_diff;
|
2008-11-07 16:44:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Relative_pointer_impl needs a specialization for const T because of
|
|
|
|
* the casting done during pointer arithmetic.
|
|
|
|
*/
|
2008-11-11 13:15:59 +01:00
|
|
|
template<typename _Tp>
|
|
|
|
class _Relative_pointer_impl<const _Tp>
|
2008-11-07 16:44:20 +01:00
|
|
|
{
|
|
|
|
public:
|
2008-11-11 13:15:59 +01:00
|
|
|
typedef const _Tp element_type;
|
2008-11-07 16:44:20 +01:00
|
|
|
|
2008-11-11 13:15:59 +01:00
|
|
|
const _Tp*
|
2008-11-07 16:44:20 +01:00
|
|
|
get() const
|
|
|
|
{
|
|
|
|
if (_M_diff == 1)
|
2008-11-11 13:15:59 +01:00
|
|
|
return 0;
|
2008-11-07 16:44:20 +01:00
|
|
|
else
|
2009-01-04 20:51:18 +01:00
|
|
|
return reinterpret_cast<const _Tp*>
|
|
|
|
(reinterpret_cast<_UIntPtrType>(this) + _M_diff);
|
2008-11-07 16:44:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-11-11 13:15:59 +01:00
|
|
|
set(const _Tp* __arg)
|
2008-11-07 16:44:20 +01:00
|
|
|
{
|
2008-11-11 13:15:59 +01:00
|
|
|
if (!__arg)
|
2008-11-07 16:44:20 +01:00
|
|
|
_M_diff = 1;
|
|
|
|
else
|
2009-01-04 20:51:18 +01:00
|
|
|
_M_diff = reinterpret_cast<_UIntPtrType>(__arg)
|
|
|
|
- reinterpret_cast<_UIntPtrType>(this);
|
2008-11-07 16:44:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Comparison of pointers
|
|
|
|
inline bool
|
|
|
|
operator<(const _Relative_pointer_impl& __rarg) const
|
2009-01-04 20:51:18 +01:00
|
|
|
{ return (reinterpret_cast<_UIntPtrType>(this->get())
|
|
|
|
< reinterpret_cast<_UIntPtrType>(__rarg.get())); }
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
inline bool
|
|
|
|
operator==(const _Relative_pointer_impl& __rarg) const
|
2009-01-04 20:51:18 +01:00
|
|
|
{ return (reinterpret_cast<_UIntPtrType>(this->get())
|
|
|
|
== reinterpret_cast<_UIntPtrType>(__rarg.get())); }
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
private:
|
2009-08-14 18:51:01 +02:00
|
|
|
#ifdef _GLIBCXX_USE_LONG_LONG
|
|
|
|
typedef __gnu_cxx::__conditional_type<
|
|
|
|
(sizeof(unsigned long) >= sizeof(void*)),
|
2009-01-04 20:51:18 +01:00
|
|
|
unsigned long, unsigned long long>::__type _UIntPtrType;
|
2009-08-14 18:51:01 +02:00
|
|
|
#else
|
|
|
|
typedef unsigned long _UIntPtrType;
|
|
|
|
#endif
|
|
|
|
_UIntPtrType _M_diff;
|
2008-11-07 16:44:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The specialization on this type helps resolve the problem of
|
2009-08-14 18:51:01 +02:00
|
|
|
* reference to void, and eliminates the need to specialize
|
|
|
|
* _Pointer_adapter for cases of void*, const void*, and so on.
|
2008-11-07 16:44:20 +01:00
|
|
|
*/
|
|
|
|
struct _Invalid_type { };
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
struct _Reference_type
|
2008-11-11 13:15:59 +01:00
|
|
|
{ typedef _Tp& reference; };
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
template<>
|
|
|
|
struct _Reference_type<void>
|
2008-11-11 13:15:59 +01:00
|
|
|
{ typedef _Invalid_type& reference; };
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
template<>
|
|
|
|
struct _Reference_type<const void>
|
2008-11-11 13:15:59 +01:00
|
|
|
{ typedef const _Invalid_type& reference; };
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
template<>
|
|
|
|
struct _Reference_type<volatile void>
|
2008-11-11 13:15:59 +01:00
|
|
|
{ typedef volatile _Invalid_type& reference; };
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
template<>
|
|
|
|
struct _Reference_type<volatile const void>
|
2008-11-11 13:15:59 +01:00
|
|
|
{ typedef const volatile _Invalid_type& reference; };
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
/**
|
2011-07-09 12:28:56 +02:00
|
|
|
* This structure accommodates the way in which
|
2009-08-14 18:51:01 +02:00
|
|
|
* std::iterator_traits<> is normally specialized for const T*, so
|
|
|
|
* that value_type is still T.
|
2008-11-07 16:44:20 +01:00
|
|
|
*/
|
|
|
|
template<typename _Tp>
|
|
|
|
struct _Unqualified_type
|
2008-11-11 13:15:59 +01:00
|
|
|
{ typedef _Tp type; };
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
struct _Unqualified_type<const _Tp>
|
2008-11-11 13:15:59 +01:00
|
|
|
{ typedef _Tp type; };
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
/**
|
2009-08-14 18:51:01 +02:00
|
|
|
* The following provides an 'alternative pointer' that works with
|
|
|
|
* the containers when specified as the pointer typedef of the
|
|
|
|
* allocator.
|
2008-11-11 13:15:59 +01:00
|
|
|
*
|
2009-08-14 18:51:01 +02:00
|
|
|
* The pointer type used with the containers doesn't have to be this
|
|
|
|
* class, but it must support the implicit conversions, pointer
|
|
|
|
* arithmetic, comparison operators, etc. that are supported by this
|
|
|
|
* class, and avoid raising compile-time ambiguities. Because
|
|
|
|
* creating a working pointer can be challenging, this pointer
|
|
|
|
* template was designed to wrapper an easier storage policy type,
|
|
|
|
* so that it becomes reusable for creating other pointer types.
|
2008-11-07 16:44:20 +01:00
|
|
|
*
|
2009-08-14 18:51:01 +02:00
|
|
|
* A key point of this class is also that it allows container
|
2011-07-09 12:28:56 +02:00
|
|
|
* writers to 'assume' Allocator::pointer is a typedef for a normal
|
2009-08-14 18:51:01 +02:00
|
|
|
* pointer. This class supports most of the conventions of a true
|
|
|
|
* pointer, and can, for instance handle implicit conversion to
|
|
|
|
* const and base class pointer types. The only impositions on
|
|
|
|
* container writers to support extended pointers are: 1) use the
|
|
|
|
* Allocator::pointer typedef appropriately for pointer types. 2)
|
|
|
|
* if you need pointer casting, use the __pointer_cast<> functions
|
|
|
|
* from ext/cast.h. This allows pointer cast operations to be
|
2011-07-09 12:28:56 +02:00
|
|
|
* overloaded as necessary by custom pointers.
|
2008-11-07 16:44:20 +01:00
|
|
|
*
|
2009-08-14 18:51:01 +02:00
|
|
|
* Note: The const qualifier works with this pointer adapter as
|
|
|
|
* follows:
|
2008-11-07 16:44:20 +01:00
|
|
|
*
|
|
|
|
* _Tp* == _Pointer_adapter<_Std_pointer_impl<_Tp> >;
|
|
|
|
* const _Tp* == _Pointer_adapter<_Std_pointer_impl<const _Tp> >;
|
|
|
|
* _Tp* const == const _Pointer_adapter<_Std_pointer_impl<_Tp> >;
|
|
|
|
* const _Tp* const == const _Pointer_adapter<_Std_pointer_impl<const _Tp> >;
|
|
|
|
*/
|
2008-11-11 13:15:59 +01:00
|
|
|
template<typename _Storage_policy>
|
2008-11-07 16:44:20 +01:00
|
|
|
class _Pointer_adapter : public _Storage_policy
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef typename _Storage_policy::element_type element_type;
|
2008-11-11 13:15:59 +01:00
|
|
|
|
2008-11-07 16:44:20 +01:00
|
|
|
// These are needed for iterator_traits
|
|
|
|
typedef std::random_access_iterator_tag iterator_category;
|
|
|
|
typedef typename _Unqualified_type<element_type>::type value_type;
|
2008-11-11 13:15:59 +01:00
|
|
|
typedef std::ptrdiff_t difference_type;
|
2008-11-07 16:44:20 +01:00
|
|
|
typedef _Pointer_adapter pointer;
|
|
|
|
typedef typename _Reference_type<element_type>::reference reference;
|
2008-11-11 13:15:59 +01:00
|
|
|
|
2008-11-07 16:44:20 +01:00
|
|
|
// Reminder: 'const' methods mean that the method is valid when the
|
|
|
|
// pointer is immutable, and has nothing to do with whether the
|
|
|
|
// 'pointee' is const.
|
|
|
|
|
|
|
|
// Default Constructor (Convert from element_type*)
|
2008-11-11 13:15:59 +01:00
|
|
|
_Pointer_adapter(element_type* __arg = 0)
|
2008-11-07 16:44:20 +01:00
|
|
|
{ _Storage_policy::set(__arg); }
|
2008-11-11 13:15:59 +01:00
|
|
|
|
2008-11-07 16:44:20 +01:00
|
|
|
// Copy constructor from _Pointer_adapter of same type.
|
|
|
|
_Pointer_adapter(const _Pointer_adapter& __arg)
|
|
|
|
{ _Storage_policy::set(__arg.get()); }
|
2008-11-11 13:15:59 +01:00
|
|
|
|
2008-11-07 16:44:20 +01:00
|
|
|
// Convert from _Up* if conversion to element_type* is valid.
|
|
|
|
template<typename _Up>
|
2008-11-11 13:15:59 +01:00
|
|
|
_Pointer_adapter(_Up* __arg)
|
|
|
|
{ _Storage_policy::set(__arg); }
|
|
|
|
|
2008-11-07 16:44:20 +01:00
|
|
|
// Conversion from another _Pointer_adapter if _Up if static cast is
|
|
|
|
// valid.
|
|
|
|
template<typename _Up>
|
|
|
|
_Pointer_adapter(const _Pointer_adapter<_Up>& __arg)
|
2008-11-11 13:15:59 +01:00
|
|
|
{ _Storage_policy::set(__arg.get()); }
|
|
|
|
|
2008-11-07 16:44:20 +01:00
|
|
|
// Destructor
|
|
|
|
~_Pointer_adapter() { }
|
|
|
|
|
|
|
|
// Assignment operator
|
|
|
|
_Pointer_adapter&
|
|
|
|
operator=(const _Pointer_adapter& __arg)
|
|
|
|
{
|
|
|
|
_Storage_policy::set(__arg.get());
|
|
|
|
return *this;
|
|
|
|
}
|
2008-11-11 13:15:59 +01:00
|
|
|
|
2008-11-07 16:44:20 +01:00
|
|
|
template<typename _Up>
|
|
|
|
_Pointer_adapter&
|
|
|
|
operator=(const _Pointer_adapter<_Up>& __arg)
|
|
|
|
{
|
|
|
|
_Storage_policy::set(__arg.get());
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _Up>
|
|
|
|
_Pointer_adapter&
|
|
|
|
operator=(_Up* __arg)
|
|
|
|
{
|
|
|
|
_Storage_policy::set(__arg);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Operator*, returns element_type&
|
|
|
|
inline reference
|
|
|
|
operator*() const
|
|
|
|
{ return *(_Storage_policy::get()); }
|
2008-11-11 13:15:59 +01:00
|
|
|
|
2008-11-07 16:44:20 +01:00
|
|
|
// Operator->, returns element_type*
|
|
|
|
inline element_type*
|
|
|
|
operator->() const
|
|
|
|
{ return _Storage_policy::get(); }
|
2008-11-11 13:15:59 +01:00
|
|
|
|
2008-11-07 16:44:20 +01:00
|
|
|
// Operator[], returns a element_type& to the item at that loc.
|
2008-11-11 13:15:59 +01:00
|
|
|
inline reference
|
|
|
|
operator[](std::ptrdiff_t __index) const
|
2008-11-07 16:44:20 +01:00
|
|
|
{ return _Storage_policy::get()[__index]; }
|
2008-11-11 13:15:59 +01:00
|
|
|
|
2008-11-07 16:44:20 +01:00
|
|
|
// To allow implicit conversion to "bool", for "if (ptr)..."
|
|
|
|
private:
|
|
|
|
typedef element_type*(_Pointer_adapter::*__unspecified_bool_type)() const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
operator __unspecified_bool_type() const
|
|
|
|
{
|
|
|
|
return _Storage_policy::get() == 0 ? 0 :
|
|
|
|
&_Pointer_adapter::operator->;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ! operator (for: if (!ptr)...)
|
2008-11-11 13:15:59 +01:00
|
|
|
inline bool
|
2008-11-07 16:44:20 +01:00
|
|
|
operator!() const
|
2008-11-11 13:15:59 +01:00
|
|
|
{ return (_Storage_policy::get() == 0); }
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
// Pointer differences
|
|
|
|
inline friend std::ptrdiff_t
|
|
|
|
operator-(const _Pointer_adapter& __lhs, element_type* __rhs)
|
|
|
|
{ return (__lhs.get() - __rhs); }
|
|
|
|
|
|
|
|
inline friend std::ptrdiff_t
|
|
|
|
operator-(element_type* __lhs, const _Pointer_adapter& __rhs)
|
|
|
|
{ return (__lhs - __rhs.get()); }
|
|
|
|
|
2008-11-11 13:15:59 +01:00
|
|
|
template<typename _Up>
|
2008-11-07 16:44:20 +01:00
|
|
|
inline friend std::ptrdiff_t
|
|
|
|
operator-(const _Pointer_adapter& __lhs, _Up* __rhs)
|
|
|
|
{ return (__lhs.get() - __rhs); }
|
|
|
|
|
2008-11-11 13:15:59 +01:00
|
|
|
template<typename _Up>
|
2008-11-07 16:44:20 +01:00
|
|
|
inline friend std::ptrdiff_t
|
|
|
|
operator-(_Up* __lhs, const _Pointer_adapter& __rhs)
|
|
|
|
{ return (__lhs - __rhs.get()); }
|
|
|
|
|
|
|
|
template<typename _Up>
|
|
|
|
inline std::ptrdiff_t
|
|
|
|
operator-(const _Pointer_adapter<_Up>& __rhs) const
|
|
|
|
{ return (_Storage_policy::get() - __rhs.get()); }
|
|
|
|
|
|
|
|
// Pointer math
|
|
|
|
// Note: There is a reason for all this overloading based on different
|
|
|
|
// integer types. In some libstdc++-v3 test cases, a templated
|
|
|
|
// operator+ is declared which can match any types. This operator
|
|
|
|
// tends to "steal" the recognition of _Pointer_adapter's own operator+
|
|
|
|
// unless the integer type matches perfectly.
|
|
|
|
|
|
|
|
#define _CXX_POINTER_ARITH_OPERATOR_SET(INT_TYPE) \
|
|
|
|
inline friend _Pointer_adapter \
|
|
|
|
operator+(const _Pointer_adapter& __lhs, INT_TYPE __offset) \
|
|
|
|
{ return _Pointer_adapter(__lhs.get() + __offset); } \
|
|
|
|
\
|
|
|
|
inline friend _Pointer_adapter \
|
|
|
|
operator+(INT_TYPE __offset, const _Pointer_adapter& __rhs) \
|
|
|
|
{ return _Pointer_adapter(__rhs.get() + __offset); } \
|
|
|
|
\
|
|
|
|
inline friend _Pointer_adapter \
|
|
|
|
operator-(const _Pointer_adapter& __lhs, INT_TYPE __offset) \
|
|
|
|
{ return _Pointer_adapter(__lhs.get() - __offset); } \
|
|
|
|
\
|
|
|
|
inline _Pointer_adapter& \
|
|
|
|
operator+=(INT_TYPE __offset) \
|
|
|
|
{ \
|
|
|
|
_Storage_policy::set(_Storage_policy::get() + __offset); \
|
|
|
|
return *this; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
inline _Pointer_adapter& \
|
|
|
|
operator-=(INT_TYPE __offset) \
|
|
|
|
{ \
|
|
|
|
_Storage_policy::set(_Storage_policy::get() - __offset); \
|
|
|
|
return *this; \
|
|
|
|
} \
|
|
|
|
// END of _CXX_POINTER_ARITH_OPERATOR_SET macro
|
|
|
|
|
2011-07-09 12:28:56 +02:00
|
|
|
// Expand into the various pointer arithmetic operators needed.
|
2008-11-07 16:44:20 +01:00
|
|
|
_CXX_POINTER_ARITH_OPERATOR_SET(short);
|
|
|
|
_CXX_POINTER_ARITH_OPERATOR_SET(unsigned short);
|
|
|
|
_CXX_POINTER_ARITH_OPERATOR_SET(int);
|
|
|
|
_CXX_POINTER_ARITH_OPERATOR_SET(unsigned int);
|
|
|
|
_CXX_POINTER_ARITH_OPERATOR_SET(long);
|
|
|
|
_CXX_POINTER_ARITH_OPERATOR_SET(unsigned long);
|
|
|
|
|
|
|
|
// Mathematical Manipulators
|
|
|
|
inline _Pointer_adapter&
|
|
|
|
operator++()
|
|
|
|
{
|
|
|
|
_Storage_policy::set(_Storage_policy::get() + 1);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline _Pointer_adapter
|
2010-06-06 23:46:38 +02:00
|
|
|
operator++(int)
|
2008-11-07 16:44:20 +01:00
|
|
|
{
|
|
|
|
_Pointer_adapter tmp(*this);
|
|
|
|
_Storage_policy::set(_Storage_policy::get() + 1);
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline _Pointer_adapter&
|
|
|
|
operator--()
|
|
|
|
{
|
|
|
|
_Storage_policy::set(_Storage_policy::get() - 1);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline _Pointer_adapter
|
2008-11-11 13:15:59 +01:00
|
|
|
operator--(int)
|
2008-11-07 16:44:20 +01:00
|
|
|
{
|
|
|
|
_Pointer_adapter tmp(*this);
|
|
|
|
_Storage_policy::set(_Storage_policy::get() - 1);
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
}; // class _Pointer_adapter
|
|
|
|
|
|
|
|
|
2009-08-14 18:51:01 +02:00
|
|
|
#define _GCC_CXX_POINTER_COMPARISON_OPERATION_SET(OPERATOR) \
|
2008-11-07 16:44:20 +01:00
|
|
|
template<typename _Tp1, typename _Tp2> \
|
|
|
|
inline bool \
|
2009-08-14 18:51:01 +02:00
|
|
|
operator OPERATOR(const _Pointer_adapter<_Tp1>& __lhs, _Tp2 __rhs) \
|
|
|
|
{ return __lhs.get() OPERATOR __rhs; } \
|
2008-11-07 16:44:20 +01:00
|
|
|
\
|
|
|
|
template<typename _Tp1, typename _Tp2> \
|
|
|
|
inline bool \
|
2009-08-14 18:51:01 +02:00
|
|
|
operator OPERATOR(_Tp1 __lhs, const _Pointer_adapter<_Tp2>& __rhs) \
|
|
|
|
{ return __lhs OPERATOR __rhs.get(); } \
|
2008-11-07 16:44:20 +01:00
|
|
|
\
|
|
|
|
template<typename _Tp1, typename _Tp2> \
|
|
|
|
inline bool \
|
2009-08-14 18:51:01 +02:00
|
|
|
operator OPERATOR(const _Pointer_adapter<_Tp1>& __lhs, \
|
2008-11-07 16:44:20 +01:00
|
|
|
const _Pointer_adapter<_Tp2>& __rhs) \
|
2009-08-14 18:51:01 +02:00
|
|
|
{ return __lhs.get() OPERATOR __rhs.get(); } \
|
2008-11-07 16:44:20 +01:00
|
|
|
\
|
|
|
|
// End GCC_CXX_POINTER_COMPARISON_OPERATION_SET Macro
|
|
|
|
|
|
|
|
// Expand into the various comparison operators needed.
|
2009-08-14 18:51:01 +02:00
|
|
|
_GCC_CXX_POINTER_COMPARISON_OPERATION_SET(==)
|
|
|
|
_GCC_CXX_POINTER_COMPARISON_OPERATION_SET(!=)
|
|
|
|
_GCC_CXX_POINTER_COMPARISON_OPERATION_SET(<)
|
|
|
|
_GCC_CXX_POINTER_COMPARISON_OPERATION_SET(<=)
|
|
|
|
_GCC_CXX_POINTER_COMPARISON_OPERATION_SET(>)
|
|
|
|
_GCC_CXX_POINTER_COMPARISON_OPERATION_SET(>=)
|
2008-11-07 16:44:20 +01:00
|
|
|
|
|
|
|
// These are here for expressions like "ptr == 0", "ptr != 0"
|
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator==(const _Pointer_adapter<_Tp>& __lhs, int __rhs)
|
|
|
|
{ return __lhs.get() == reinterpret_cast<void*>(__rhs); }
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator==(int __lhs, const _Pointer_adapter<_Tp>& __rhs)
|
|
|
|
{ return __rhs.get() == reinterpret_cast<void*>(__lhs); }
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator!=(const _Pointer_adapter<_Tp>& __lhs, int __rhs)
|
|
|
|
{ return __lhs.get() != reinterpret_cast<void*>(__rhs); }
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator!=(int __lhs, const _Pointer_adapter<_Tp>& __rhs)
|
|
|
|
{ return __rhs.get() != reinterpret_cast<void*>(__lhs); }
|
|
|
|
|
|
|
|
/**
|
2011-07-09 12:28:56 +02:00
|
|
|
* Comparison operators for _Pointer_adapter defer to the base class'
|
2008-11-07 16:44:20 +01:00
|
|
|
* comparison operators, when possible.
|
|
|
|
*/
|
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator==(const _Pointer_adapter<_Tp>& __lhs,
|
|
|
|
const _Pointer_adapter<_Tp>& __rhs)
|
|
|
|
{ return __lhs._Tp::operator==(__rhs); }
|
2008-11-11 13:15:59 +01:00
|
|
|
|
2008-11-07 16:44:20 +01:00
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator<=(const _Pointer_adapter<_Tp>& __lhs,
|
|
|
|
const _Pointer_adapter<_Tp>& __rhs)
|
|
|
|
{ return __lhs._Tp::operator<(__rhs) || __lhs._Tp::operator==(__rhs); }
|
2008-11-11 13:15:59 +01:00
|
|
|
|
2008-11-07 16:44:20 +01:00
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator!=(const _Pointer_adapter<_Tp>& __lhs,
|
|
|
|
const _Pointer_adapter<_Tp>& __rhs)
|
|
|
|
{ return !(__lhs._Tp::operator==(__rhs)); }
|
2008-11-11 13:15:59 +01:00
|
|
|
|
2008-11-07 16:44:20 +01:00
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator>(const _Pointer_adapter<_Tp>& __lhs,
|
|
|
|
const _Pointer_adapter<_Tp>& __rhs)
|
|
|
|
{ return !(__lhs._Tp::operator<(__rhs) || __lhs._Tp::operator==(__rhs)); }
|
2008-11-11 13:15:59 +01:00
|
|
|
|
2008-11-07 16:44:20 +01:00
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator>=(const _Pointer_adapter<_Tp>& __lhs,
|
|
|
|
const _Pointer_adapter<_Tp>& __rhs)
|
|
|
|
{ return !(__lhs._Tp::operator<(__rhs)); }
|
2008-11-11 13:15:59 +01:00
|
|
|
|
|
|
|
template<typename _CharT, typename _Traits, typename _StoreT>
|
|
|
|
inline std::basic_ostream<_CharT, _Traits>&
|
|
|
|
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
|
2008-11-07 16:44:20 +01:00
|
|
|
const _Pointer_adapter<_StoreT>& __p)
|
2008-11-11 13:15:59 +01:00
|
|
|
{ return (__os << __p.get()); }
|
2008-11-07 16:44:20 +01:00
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
|
|
} // namespace
|
2008-11-07 16:44:20 +01:00
|
|
|
|
2011-06-05 22:28:38 +02:00
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
|
|
|
|
|
|
template<typename _Storage_policy>
|
|
|
|
struct pointer_traits<__gnu_cxx::_Pointer_adapter<_Storage_policy>>
|
|
|
|
{
|
|
|
|
/// The pointer type
|
|
|
|
typedef __gnu_cxx::_Pointer_adapter<_Storage_policy> pointer;
|
|
|
|
/// The type pointed to
|
|
|
|
typedef typename pointer::element_type element_type;
|
|
|
|
/// Type used to represent the difference between two pointers
|
|
|
|
typedef typename pointer::difference_type difference_type;
|
|
|
|
|
|
|
|
/* TODO: replace __rebind<U> with alias template rebind<U> */
|
|
|
|
/*
|
|
|
|
template<typename _Up>
|
|
|
|
using rebind<_Up> = typename __gnu_cxx::_Pointer_adapter<
|
|
|
|
typename pointer_traits<_Storage_policy>::rebind<_Up>>
|
|
|
|
*/
|
|
|
|
template<typename _Up>
|
|
|
|
class __rebind
|
|
|
|
{
|
|
|
|
typedef pointer_traits<_Storage_policy> _Policy_traits;
|
|
|
|
typedef typename _Policy_traits::template __rebind<_Up>::__type
|
|
|
|
_Rebound_policy;
|
|
|
|
public:
|
|
|
|
typedef typename __gnu_cxx::_Pointer_adapter<_Rebound_policy> __type;
|
|
|
|
};
|
2011-07-09 12:28:56 +02:00
|
|
|
|
|
|
|
static pointer pointer_to(typename pointer::reference __r) noexcept
|
|
|
|
{ return pointer(std::addressof(__r)); }
|
2011-06-05 22:28:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
|
|
} // namespace
|
|
|
|
#endif
|
|
|
|
|
2008-11-11 13:15:59 +01:00
|
|
|
#endif // _POINTER_H
|