Commit 9d6a24bd by Phil Edwards

std_bitset.h: Use GLIBCPP in multiple-inclusion guard.

2001-12-06  Phil Edwards  <pme@gcc.gnu.org>

	* include/bits/std_bitset.h:  Use GLIBCPP in multiple-inclusion guard.
	* include/bits/stl_algo.h:  Likewise.
	* include/bits/stl_algobase.h:  Likewise.
	* include/bits/stl_bvector.h:  Likewise.
	* include/bits/stl_deque.h:  Likewise.
	* include/bits/stl_function.h:  Likewise.
	* include/bits/stl_iterator.h:  Likewise.
	* include/bits/stl_iterator_base_funcs.h:  Likewise.
	* include/bits/stl_iterator_base_types.h:  Likewise.
	* include/bits/stl_list.h:  Likewise.
	* include/bits/stl_multimap.h:  Likewise.
	* include/bits/stl_multiset.h:  Likewise.
	* include/bits/stl_pair.h:  Likewise.
	* include/bits/stl_queue.h:  Likewise.
	* include/bits/stl_set.h:  Likewise.
	* include/bits/stl_stack.h:  Likewise.
	* include/bits/stl_tempbuf.h:  Likewise.
	* include/bits/stl_tree.h:  Likewise.
	* include/bits/stl_vector.h:  Likewise.

	* include/bits/stl_alloc.h:  Use our own multiple inclusion guards.
	Doxygenate more comments.  Correct historical artifacts in comments.
	(alloc, single_alloc):  Uglify non-standard names.
	(__default_alloc_template::_NFREELISTS):  Calculate from other
	parameters.
	(__default_alloc_template::_S_free_list):  Remove SunPro workaround.
	(__default_alloc_template::_Lock):  Mark as "unused".
	* include/backward/alloc.h:  Update.
	* include/bits/stl_bvector.h:  Likewise.
	* include/ext/ropeimpl.h:  Likewise.
	* include/ext/stl_hashtable.h:  Likewise.

From-SVN: r47729
parent a5eb2838
2001-12-06 Phil Edwards <pme@gcc.gnu.org>
* include/bits/std_bitset.h: Use GLIBCPP in multiple-inclusion guard.
* include/bits/stl_algo.h: Likewise.
* include/bits/stl_algobase.h: Likewise.
* include/bits/stl_bvector.h: Likewise.
* include/bits/stl_deque.h: Likewise.
* include/bits/stl_function.h: Likewise.
* include/bits/stl_iterator.h: Likewise.
* include/bits/stl_iterator_base_funcs.h: Likewise.
* include/bits/stl_iterator_base_types.h: Likewise.
* include/bits/stl_list.h: Likewise.
* include/bits/stl_multimap.h: Likewise.
* include/bits/stl_multiset.h: Likewise.
* include/bits/stl_pair.h: Likewise.
* include/bits/stl_queue.h: Likewise.
* include/bits/stl_set.h: Likewise.
* include/bits/stl_stack.h: Likewise.
* include/bits/stl_tempbuf.h: Likewise.
* include/bits/stl_tree.h: Likewise.
* include/bits/stl_vector.h: Likewise.
* include/bits/stl_alloc.h: Use our own multiple inclusion guards.
Doxygenate more comments. Correct historical artifacts in comments.
(alloc, single_alloc): Uglify non-standard names.
(__default_alloc_template::_NFREELISTS): Calculate from other
parameters.
(__default_alloc_template::_S_free_list): Remove SunPro workaround.
(__default_alloc_template::_Lock): Mark as "unused".
* include/backward/alloc.h: Update.
* include/bits/stl_bvector.h: Likewise.
* include/ext/ropeimpl.h: Likewise.
* include/ext/stl_hashtable.h: Likewise.
2001-12-05 Benjamin Kosnik <bkoz@redhat.com> 2001-12-05 Benjamin Kosnik <bkoz@redhat.com>
DR/282 DR/282
......
...@@ -50,8 +50,8 @@ ...@@ -50,8 +50,8 @@
using std::__malloc_alloc_template; using std::__malloc_alloc_template;
using std::__simple_alloc; using std::__simple_alloc;
using std::__debug_alloc; using std::__debug_alloc;
using std::alloc; using std::__alloc;
using std::single_client_alloc; using std::__single_client_alloc;
using std::allocator; using std::allocator;
#ifdef __USE_MALLOC #ifdef __USE_MALLOC
using std::malloc_alloc; using std::malloc_alloc;
......
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_BITSET #ifndef __GLIBCPP_BITSET
#define __SGI_STL_BITSET #define __GLIBCPP_BITSET
#pragma GCC system_header #pragma GCC system_header
...@@ -805,7 +805,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Nb>& __x) ...@@ -805,7 +805,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Nb>& __x)
#undef __BITSET_WORDS #undef __BITSET_WORDS
#endif /* __SGI_STL_BITSET */ #endif /* __GLIBCPP_BITSET */
// Local Variables: // Local Variables:
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_ALGO_H #ifndef __GLIBCPP_INTERNAL_ALGO_H
#define __SGI_STL_INTERNAL_ALGO_H #define __GLIBCPP_INTERNAL_ALGO_H
#include <bits/stl_heap.h> #include <bits/stl_heap.h>
...@@ -3601,7 +3601,7 @@ __result, __binary_pred, _IterType()); ...@@ -3601,7 +3601,7 @@ __result, __binary_pred, _IterType());
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_ALGO_H */ #endif /* __GLIBCPP_INTERNAL_ALGO_H */
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_ALGOBASE_H #ifndef __GLIBCPP_INTERNAL_ALGOBASE_H
#define __SGI_STL_INTERNAL_ALGOBASE_H #define __GLIBCPP_INTERNAL_ALGOBASE_H
#include <bits/c++config.h> #include <bits/c++config.h>
#include <bits/stl_pair.h> #include <bits/stl_pair.h>
...@@ -950,7 +950,7 @@ namespace std ...@@ -950,7 +950,7 @@ namespace std
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_ALGOBASE_H */ #endif /* __GLIBCPP_INTERNAL_ALGOBASE_H */
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -45,27 +45,36 @@ ...@@ -45,27 +45,36 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_ALLOC_H #ifndef __GLIBCPP_INTERNAL_ALLOC_H
#define __SGI_STL_INTERNAL_ALLOC_H #define __GLIBCPP_INTERNAL_ALLOC_H
// This header implements some node allocators. These are NOT the same as /**
// allocators in the C++ standard, nor in the original HP STL. They do not * @maint
// encapsulate different pointer types; we assume that there is only one * @addtogroup Allocators
// pointer type. The C++ standard allocators are intended to allocate * stl_alloc.h implements some node allocators. These are NOT the same as
// individual objects, not pools or arenas. * allocators in the C++ standard, nor in the original H-P STL. They do not
// * encapsulate different pointer types; we assume that there is only one
// In this file allocators are of two different styles: "standard" and * pointer type. The C++ standard allocators are intended to allocate
// "SGI" (quotes included). "Standard" allocators conform to 20.4. "SGI" * individual objects, not pools or arenas.
// allocators differ in AT LEAST the following ways (add to this list as you *
// discover them): * In this file allocators are of two different styles: "standard" and
// * "SGI" (quotes included). "Standard" allocators conform to 20.4. "SGI"
// - "Standard" allocate() takes two parameters (n_count,hint=0) but "SGI" * allocators differ in AT LEAST the following ways (add to this list as you
// allocate() takes one paramter (n_size). * discover them):
// - Likewise, "standard" deallocate()'s n is a count, but in "SGI" is a *
// byte size. * - "Standard" allocate() takes two parameters (n_count,hint=0) but "SGI"
// - max_size(), construct(), and destroy() are missing in "SGI" allocators. * allocate() takes one paramter (n_size).
// - reallocate(p,oldsz,newsz) is added in "SGI", and behaves as * - Likewise, "standard" deallocate()'s argument is a count, but in "SGI"
// if p=realloc(p,newsz). * is a byte size.
* - max_size(), construct(), and destroy() are missing in "SGI" allocators.
* - reallocate(p,oldsz,newsz) is added in "SGI", and behaves as
* if p=realloc(p,newsz).
*
* "SGI" allocators may be wrapped in __allocator to convert the interface
* into a "standard" one.
*
* @endmaint
*/
#include <bits/functexcept.h> // for __throw_bad_alloc #include <bits/functexcept.h> // for __throw_bad_alloc
...@@ -82,6 +91,7 @@ namespace std ...@@ -82,6 +91,7 @@ namespace std
* A new-based allocator, as required by the standard. Allocation and * A new-based allocator, as required by the standard. Allocation and
* deallocation forward to global new and delete. "SGI" style, minus * deallocation forward to global new and delete. "SGI" style, minus
* reallocate(). * reallocate().
* (See @link Allocators allocators info @endlink for more.)
* @endmaint * @endmaint
*/ */
class __new_alloc class __new_alloc
...@@ -104,6 +114,7 @@ namespace std ...@@ -104,6 +114,7 @@ namespace std
* storage efficient. The template argument is unused and is only present * storage efficient. The template argument is unused and is only present
* to permit multiple instantiations (but see __default_alloc_template * to permit multiple instantiations (but see __default_alloc_template
* for caveats). "SGI" style, plus __set_malloc_handler for OOM conditions. * for caveats). "SGI" style, plus __set_malloc_handler for OOM conditions.
* (See @link Allocators allocators info @endlink for more.)
* @endmaint * @endmaint
*/ */
template <int __inst> template <int __inst>
...@@ -195,11 +206,14 @@ namespace std ...@@ -195,11 +206,14 @@ namespace std
/** /**
* @maint
* This is used primarily (only?) in _Alloc_traits and other places to * This is used primarily (only?) in _Alloc_traits and other places to
* help provide the _Alloc_type typedef. * help provide the _Alloc_type typedef.
* *
* This is neither "standard"-conforming nor "SGI". The _Alloc parameter * This is neither "standard"-conforming nor "SGI". The _Alloc parameter
* must be "SGI" style. * must be "SGI" style.
* (See @link Allocators allocators info @endlink for more.)
* @endmaint
*/ */
template<class _Tp, class _Alloc> template<class _Tp, class _Alloc>
class __simple_alloc class __simple_alloc
...@@ -220,6 +234,7 @@ namespace std ...@@ -220,6 +234,7 @@ namespace std
/** /**
* @maint
* An adaptor for an underlying allocator (_Alloc) to check the size * An adaptor for an underlying allocator (_Alloc) to check the size
* arguments for debugging. Errors are reported using assert; these * arguments for debugging. Errors are reported using assert; these
* checks can be disabled via NDEBUG, but the space penalty is still * checks can be disabled via NDEBUG, but the space penalty is still
...@@ -229,6 +244,8 @@ namespace std ...@@ -229,6 +244,8 @@ namespace std
* "There is some evidence that this can confuse Purify." - SGI comment * "There is some evidence that this can confuse Purify." - SGI comment
* *
* This adaptor is "SGI" style. The _Alloc parameter must also be "SGI". * This adaptor is "SGI" style. The _Alloc parameter must also be "SGI".
* (See @link Allocators allocators info @endlink for more.)
* @endmaint
*/ */
template <class _Alloc> template <class _Alloc>
class __debug_alloc class __debug_alloc
...@@ -268,19 +285,21 @@ namespace std ...@@ -268,19 +285,21 @@ namespace std
#ifdef __USE_MALLOC #ifdef __USE_MALLOC
typedef __mem_interface alloc; typedef __mem_interface __alloc;
typedef __mem_interface single_client_alloc; typedef __mem_interface __single_client_alloc;
#else #else
/** /**
* @maint * @maint
* Default node allocator. * Default node allocator. "SGI" style. Uses __mem_interface for its
* underlying requests (and makes as few requests as possible).
* **** Currently __mem_interface is always __new_alloc, never __malloc*.
* *
* Important implementation properties: * Important implementation properties:
* 1. If the clients request an object of size > _MAX_BYTES, the resulting * 1. If the clients request an object of size > _MAX_BYTES, the resulting
* object will be obtained directly from malloc. * object will be obtained directly from the underlying __mem_interface.
* 2. In all other cases, we allocate an object of size exactly * 2. In all other cases, we allocate an object of size exactly
* _S_round_up(requested_size). Thus the client has enough size * _S_round_up(requested_size). Thus the client has enough size
* information that we can return the object to the proper free list * information that we can return the object to the proper free list
...@@ -297,6 +316,8 @@ typedef __mem_interface single_client_alloc; ...@@ -297,6 +316,8 @@ typedef __mem_interface single_client_alloc;
* allocator instances have different types, limiting the utility of this * allocator instances have different types, limiting the utility of this
* approach. If you do not wish to share the free lists with the main * approach. If you do not wish to share the free lists with the main
* default_alloc instance, instantiate this with a non-zero __inst. * default_alloc instance, instantiate this with a non-zero __inst.
*
* (See @link Allocators allocators info @endlink for more.)
* @endmaint * @endmaint
*/ */
template <bool __threads, int __inst> template <bool __threads, int __inst>
...@@ -306,7 +327,7 @@ class __default_alloc_template ...@@ -306,7 +327,7 @@ class __default_alloc_template
private: private:
enum {_ALIGN = 8}; enum {_ALIGN = 8};
enum {_MAX_BYTES = 128}; enum {_MAX_BYTES = 128};
enum {_NFREELISTS = 16}; // _MAX_BYTES/_ALIGN enum {_NFREELISTS = _MAX_BYTES / _ALIGN};
static size_t static size_t
_S_round_up(size_t __bytes) _S_round_up(size_t __bytes)
...@@ -334,16 +355,14 @@ private: ...@@ -334,16 +355,14 @@ private:
static _STL_mutex_lock _S_node_allocator_lock; static _STL_mutex_lock _S_node_allocator_lock;
// It would be nice to use _STL_auto_lock here. But we // It would be nice to use _STL_auto_lock here. But we need a test whether
// don't need the NULL check. And we do need a test whether // threads are in use.
// threads have actually been started.
class _Lock;
friend class _Lock;
class _Lock { class _Lock {
public: public:
_Lock() { if (__threads) _S_node_allocator_lock._M_acquire_lock(); } _Lock() { if (__threads) _S_node_allocator_lock._M_acquire_lock(); }
~_Lock() { if (__threads) _S_node_allocator_lock._M_release_lock(); } ~_Lock() { if (__threads) _S_node_allocator_lock._M_release_lock(); }
}; } __attribute__ ((__unused__));
friend class _Lock;
public: public:
...@@ -357,9 +376,8 @@ public: ...@@ -357,9 +376,8 @@ public:
else else
{ {
_Obj* volatile* __my_free_list = _S_free_list + _S_freelist_index(__n); _Obj* volatile* __my_free_list = _S_free_list + _S_freelist_index(__n);
// Acquire the lock here with a constructor call. // Acquire the lock here with a constructor call. This ensures that
// This ensures that it is released in exit or during stack // it is released in exit or during stack unwinding.
// unwinding.
_Lock __lock_instance; _Lock __lock_instance;
_Obj* __restrict__ __result = *__my_free_list; _Obj* __restrict__ __result = *__my_free_list;
if (__result == 0) if (__result == 0)
...@@ -385,11 +403,11 @@ public: ...@@ -385,11 +403,11 @@ public:
= _S_free_list + _S_freelist_index(__n); = _S_free_list + _S_freelist_index(__n);
_Obj* __q = (_Obj*)__p; _Obj* __q = (_Obj*)__p;
// acquire lock // Acquire the lock here with a constructor call. This ensures that
// it is released in exit or during stack unwinding.
_Lock __lock_instance; _Lock __lock_instance;
__q -> _M_free_list_link = *__my_free_list; __q -> _M_free_list_link = *__my_free_list;
*__my_free_list = __q; *__my_free_list = __q;
// lock is released here
} }
} }
...@@ -477,9 +495,8 @@ __default_alloc_template<__threads, __inst>::_S_chunk_alloc(size_t __size, ...@@ -477,9 +495,8 @@ __default_alloc_template<__threads, __inst>::_S_chunk_alloc(size_t __size,
} }
_S_end_free = 0; // In case of exception. _S_end_free = 0; // In case of exception.
_S_start_free = (char*)__mem_interface::allocate(__bytes_to_get); _S_start_free = (char*)__mem_interface::allocate(__bytes_to_get);
// This should either throw an // This should either throw an exception or remedy the situation.
// exception or remedy the situation. Thus we assume it // Thus we assume it succeeded.
// succeeded.
} }
_S_heap_size += __bytes_to_get; _S_heap_size += __bytes_to_get;
_S_end_free = _S_start_free + __bytes_to_get; _S_end_free = _S_start_free + __bytes_to_get;
...@@ -543,9 +560,9 @@ __default_alloc_template<threads, inst>::reallocate(void* __p, ...@@ -543,9 +560,9 @@ __default_alloc_template<threads, inst>::reallocate(void* __p,
} }
template <bool __threads, int __inst> template <bool __threads, int __inst>
_STL_mutex_lock _STL_mutex_lock
__default_alloc_template<__threads, __inst>::_S_node_allocator_lock __default_alloc_template<__threads, __inst>::_S_node_allocator_lock
__STL_MUTEX_INITIALIZER; __STL_MUTEX_INITIALIZER;
template <bool __threads, int __inst> template <bool __threads, int __inst>
char* __default_alloc_template<__threads, __inst>::_S_start_free = 0; char* __default_alloc_template<__threads, __inst>::_S_start_free = 0;
...@@ -559,12 +576,11 @@ size_t __default_alloc_template<__threads, __inst>::_S_heap_size = 0; ...@@ -559,12 +576,11 @@ size_t __default_alloc_template<__threads, __inst>::_S_heap_size = 0;
template <bool __threads, int __inst> template <bool __threads, int __inst>
typename __default_alloc_template<__threads, __inst>::_Obj* volatile typename __default_alloc_template<__threads, __inst>::_Obj* volatile
__default_alloc_template<__threads, __inst> ::_S_free_list[ __default_alloc_template<__threads, __inst> ::_S_free_list[
__default_alloc_template<__threads, __inst>::_NFREELISTS __default_alloc_template<__threads, __inst>::_NFREELISTS ];
] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
typedef __default_alloc_template<true, 0> alloc; typedef __default_alloc_template<true, 0> __alloc;
typedef __default_alloc_template<false, 0> single_client_alloc; typedef __default_alloc_template<false, 0> __single_client_alloc;
#endif /* ! __USE_MALLOC */ #endif /* ! __USE_MALLOC */
...@@ -580,15 +596,16 @@ typedef __default_alloc_template<false, 0> single_client_alloc; ...@@ -580,15 +596,16 @@ typedef __default_alloc_template<false, 0> single_client_alloc;
* - __malloc_alloc_template is used for memory requests * - __malloc_alloc_template is used for memory requests
* - else (the default) * - else (the default)
* - __default_alloc_template is used via two typedefs * - __default_alloc_template is used via two typedefs
* - "single_client_alloc" typedef does no locking for threads * - "__single_client_alloc" typedef does no locking for threads
* - "alloc" typedef is threadsafe via the locks * - "__alloc" typedef is threadsafe via the locks
* - __new_alloc is used for memory requests * - __new_alloc is used for memory requests
* *
* (See @link Allocators allocators info @endlink for more.)
*/ */
template <class _Tp> template <class _Tp>
class allocator class allocator
{ {
typedef alloc _Alloc; // The underlying allocator. typedef __alloc _Alloc; // The underlying allocator.
public: public:
typedef size_t size_type; typedef size_t size_type;
typedef ptrdiff_t difference_type; typedef ptrdiff_t difference_type;
...@@ -657,12 +674,13 @@ inline bool operator!=(const allocator<_T1>&, const allocator<_T2>&) ...@@ -657,12 +674,13 @@ inline bool operator!=(const allocator<_T1>&, const allocator<_T2>&)
/** /**
* Allocator adaptor to turn an "SGI" style allocator (e.g. alloc, * Allocator adaptor to turn an "SGI" style allocator (e.g., __alloc,
* __malloc_alloc_template) into a "standard" conformaing allocator. Note * __malloc_alloc_template) into a "standard" conforming allocator. Note
* that this adaptor does *not* assume that all objects of the underlying * that this adaptor does *not* assume that all objects of the underlying
* alloc class are identical, nor does it assume that all of the underlying * alloc class are identical, nor does it assume that all of the underlying
* alloc's member functions are static member functions. Note, also, that * alloc's member functions are static member functions. Note, also, that
* __allocator<_Tp, alloc> is essentially the same thing as allocator<_Tp>. * __allocator<_Tp, __alloc> is essentially the same thing as allocator<_Tp>.
* (See @link Allocators allocators info @endlink for more.)
*/ */
template <class _Tp, class _Alloc> template <class _Tp, class _Alloc>
struct __allocator struct __allocator
...@@ -738,10 +756,11 @@ inline bool operator!=(const __allocator<_Tp, _Alloc>& __a1, ...@@ -738,10 +756,11 @@ inline bool operator!=(const __allocator<_Tp, _Alloc>& __a1,
} }
// Comparison operators for all of the predifined SGI-style allocators. //@{
// This ensures that __allocator<malloc_alloc> (for example) will /** Comparison operators for all of the predifined SGI-style allocators.
// work correctly. * This ensures that __allocator<malloc_alloc> (for example) will work
* correctly. As required, all allocators compare equal.
*/
template <int inst> template <int inst>
inline bool operator==(const __malloc_alloc_template<inst>&, inline bool operator==(const __malloc_alloc_template<inst>&,
const __malloc_alloc_template<inst>&) const __malloc_alloc_template<inst>&)
...@@ -767,36 +786,46 @@ inline bool operator!=(const __debug_alloc<_Alloc>&, ...@@ -767,36 +786,46 @@ inline bool operator!=(const __debug_alloc<_Alloc>&,
const __debug_alloc<_Alloc>&) { const __debug_alloc<_Alloc>&) {
return false; return false;
} }
//@}
// Another allocator adaptor: _Alloc_traits. This serves two /**
// purposes. First, make it possible to write containers that can use * @maint
// either SGI-style allocators or standard-conforming allocator. * Another allocator adaptor: _Alloc_traits. This serves two purposes.
// Second, provide a mechanism so that containers can query whether or * First, make it possible to write containers that can use either "SGI"
// not the allocator has distinct instances. If not, the container * style allocators or "standard" allocators. Second, provide a mechanism
// can avoid wasting a word of memory to store an empty object. * so that containers can query whether or not the allocator has distinct
* instances. If not, the container can avoid wasting a word of memory to
// This adaptor uses partial specialization. The general case of * store an empty object. For examples of use, see stl_vector.h, etc, or
// _Alloc_traits<_Tp, _Alloc> assumes that _Alloc is a * any of the other classes derived from this one.
// standard-conforming allocator, possibly with non-equal instances *
// and non-static members. (It still behaves correctly even if _Alloc * This adaptor uses partial specialization. The general case of
// has static member and if all instances are equal. Refinements * _Alloc_traits<_Tp, _Alloc> assumes that _Alloc is a
// affect performance, not correctness.) * standard-conforming allocator, possibly with non-equal instances and
* non-static members. (It still behaves correctly even if _Alloc has
// There are always two members: allocator_type, which is a standard- * static member and if all instances are equal. Refinements affect
// conforming allocator type for allocating objects of type _Tp, and * performance, not correctness.)
// _S_instanceless, a static const member of type bool. If *
// _S_instanceless is true, this means that there is no difference * There are always two members: allocator_type, which is a standard-
// between any two instances of type allocator_type. Furthermore, if * conforming allocator type for allocating objects of type _Tp, and
// _S_instanceless is true, then _Alloc_traits has one additional * _S_instanceless, a static const member of type bool. If
// member: _Alloc_type. This type encapsulates allocation and * _S_instanceless is true, this means that there is no difference
// deallocation of objects of type _Tp through a static interface; it * between any two instances of type allocator_type. Furthermore, if
// has two member functions, whose signatures are * _S_instanceless is true, then _Alloc_traits has one additional
// static _Tp* allocate(size_t) * member: _Alloc_type. This type encapsulates allocation and
// static void deallocate(_Tp*, size_t) * deallocation of objects of type _Tp through a static interface; it
* has two member functions, whose signatures are
*
* - static _Tp* allocate(size_t)
* - static void deallocate(_Tp*, size_t)
*
* The size_t parameters are "standard" style (see top of stl_alloc.h) in
* that they take counts, not sizes.
*
* (See @link Allocators allocators info @endlink for more.)
* @endmaint
*/
// The fully general version. // The fully general version.
template <class _Tp, class _Allocator> template <class _Tp, class _Allocator>
struct _Alloc_traits struct _Alloc_traits
{ {
...@@ -807,18 +836,17 @@ struct _Alloc_traits ...@@ -807,18 +836,17 @@ struct _Alloc_traits
template <class _Tp, class _Allocator> template <class _Tp, class _Allocator>
const bool _Alloc_traits<_Tp, _Allocator>::_S_instanceless; const bool _Alloc_traits<_Tp, _Allocator>::_S_instanceless;
// The version for the default allocator. /// The version for the default allocator.
template <class _Tp, class _Tp1> template <class _Tp, class _Tp1>
struct _Alloc_traits<_Tp, allocator<_Tp1> > struct _Alloc_traits<_Tp, allocator<_Tp1> >
{ {
static const bool _S_instanceless = true; static const bool _S_instanceless = true;
typedef __simple_alloc<_Tp, alloc> _Alloc_type; typedef __simple_alloc<_Tp, __alloc> _Alloc_type;
typedef allocator<_Tp> allocator_type; typedef allocator<_Tp> allocator_type;
}; };
// Versions for the predefined SGI-style allocators. //@{
/// Versions for the predefined "SGI" style allocators.
template <class _Tp, int __inst> template <class _Tp, int __inst>
struct _Alloc_traits<_Tp, __malloc_alloc_template<__inst> > struct _Alloc_traits<_Tp, __malloc_alloc_template<__inst> >
{ {
...@@ -846,10 +874,10 @@ struct _Alloc_traits<_Tp, __debug_alloc<_Alloc> > ...@@ -846,10 +874,10 @@ struct _Alloc_traits<_Tp, __debug_alloc<_Alloc> >
typedef __simple_alloc<_Tp, __debug_alloc<_Alloc> > _Alloc_type; typedef __simple_alloc<_Tp, __debug_alloc<_Alloc> > _Alloc_type;
typedef __allocator<_Tp, __debug_alloc<_Alloc> > allocator_type; typedef __allocator<_Tp, __debug_alloc<_Alloc> > allocator_type;
}; };
//@}
// Versions for the __allocator adaptor used with the predefined //@{
// SGI-style allocators. /// Versions for the __allocator adaptor used with the predefined "SGI" style allocators.
template <class _Tp, class _Tp1, int __inst> template <class _Tp, class _Tp1, int __inst>
struct _Alloc_traits<_Tp, struct _Alloc_traits<_Tp,
__allocator<_Tp1, __malloc_alloc_template<__inst> > > __allocator<_Tp1, __malloc_alloc_template<__inst> > >
...@@ -880,10 +908,11 @@ struct _Alloc_traits<_Tp, __allocator<_Tp1, __debug_alloc<_Alloc> > > ...@@ -880,10 +908,11 @@ struct _Alloc_traits<_Tp, __allocator<_Tp1, __debug_alloc<_Alloc> > >
typedef __simple_alloc<_Tp, __debug_alloc<_Alloc> > _Alloc_type; typedef __simple_alloc<_Tp, __debug_alloc<_Alloc> > _Alloc_type;
typedef __allocator<_Tp, __debug_alloc<_Alloc> > allocator_type; typedef __allocator<_Tp, __debug_alloc<_Alloc> > allocator_type;
}; };
//@}
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_ALLOC_H */ #endif /* __GLIBCPP_INTERNAL_ALLOC_H */
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_BVECTOR_H #ifndef __GLIBCPP_INTERNAL_BVECTOR_H
#define __SGI_STL_INTERNAL_BVECTOR_H #define __GLIBCPP_INTERNAL_BVECTOR_H
namespace std namespace std
{ {
...@@ -717,11 +717,11 @@ template <typename _Alloc> ...@@ -717,11 +717,11 @@ template <typename _Alloc>
}; };
// This typedef is non-standard. It is provided for backward compatibility. // This typedef is non-standard. It is provided for backward compatibility.
typedef vector<bool, alloc> bit_vector; typedef vector<bool, __alloc> bit_vector;
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_BVECTOR_H */ #endif /* __GLIBCPP_INTERNAL_BVECTOR_H */
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -62,8 +62,8 @@ ...@@ -62,8 +62,8 @@
#include <bits/stl_iterator_base_types.h> #include <bits/stl_iterator_base_types.h>
#include <bits/stl_iterator_base_funcs.h> #include <bits/stl_iterator_base_funcs.h>
#ifndef __SGI_STL_INTERNAL_DEQUE_H #ifndef __GLIBCPP_INTERNAL_DEQUE_H
#define __SGI_STL_INTERNAL_DEQUE_H #define __GLIBCPP_INTERNAL_DEQUE_H
/* Class invariants: /* Class invariants:
* For any nonsingular iterator i: * For any nonsingular iterator i:
...@@ -1447,7 +1447,7 @@ inline void swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y) { ...@@ -1447,7 +1447,7 @@ inline void swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y) {
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_DEQUE_H */ #endif /* __GLIBCPP_INTERNAL_DEQUE_H */
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_FUNCTION_H #ifndef __GLIBCPP_INTERNAL_FUNCTION_H
#define __SGI_STL_INTERNAL_FUNCTION_H #define __GLIBCPP_INTERNAL_FUNCTION_H
namespace std namespace std
{ {
...@@ -1046,7 +1046,7 @@ mem_fun1_ref(_Ret (_Tp::*__f)(_Arg) const) ...@@ -1046,7 +1046,7 @@ mem_fun1_ref(_Ret (_Tp::*__f)(_Arg) const)
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_FUNCTION_H */ #endif /* __GLIBCPP_INTERNAL_FUNCTION_H */
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_ITERATOR_H #ifndef __GLIBCPP_INTERNAL_ITERATOR_H
#define __SGI_STL_INTERNAL_ITERATOR_H #define __GLIBCPP_INTERNAL_ITERATOR_H
namespace std namespace std
{ {
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_ITERATOR_BASE_FUNCS_H #ifndef __GLIBCPP_INTERNAL_ITERATOR_BASE_FUNCS_H
#define __SGI_STL_INTERNAL_ITERATOR_BASE_FUNCS_H #define __GLIBCPP_INTERNAL_ITERATOR_BASE_FUNCS_H
// This file contains all of the general iterator-related utility // This file contains all of the general iterator-related utility
// functions, such as distance() and advance(). // functions, such as distance() and advance().
...@@ -176,7 +176,7 @@ namespace std ...@@ -176,7 +176,7 @@ namespace std
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_ITERATOR_BASE_FUNCS_H */ #endif /* __GLIBCPP_INTERNAL_ITERATOR_BASE_FUNCS_H */
// Local Variables: // Local Variables:
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_ITERATOR_BASE_TYPES_H #ifndef __GLIBCPP_INTERNAL_ITERATOR_BASE_TYPES_H
#define __SGI_STL_INTERNAL_ITERATOR_BASE_TYPES_H #define __GLIBCPP_INTERNAL_ITERATOR_BASE_TYPES_H
// This file contains all of the general iterator-related utility // This file contains all of the general iterator-related utility
// types, such as iterator_traits and struct iterator. // types, such as iterator_traits and struct iterator.
...@@ -173,7 +173,7 @@ namespace std ...@@ -173,7 +173,7 @@ namespace std
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_ITERATOR_BASE_TYPES_H */ #endif /* __GLIBCPP_INTERNAL_ITERATOR_BASE_TYPES_H */
// Local Variables: // Local Variables:
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_LIST_H #ifndef __GLIBCPP_INTERNAL_LIST_H
#define __SGI_STL_INTERNAL_LIST_H #define __GLIBCPP_INTERNAL_LIST_H
#include <bits/concept_check.h> #include <bits/concept_check.h>
...@@ -969,7 +969,7 @@ namespace std ...@@ -969,7 +969,7 @@ namespace std
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_LIST_H */ #endif /* __GLIBCPP_INTERNAL_LIST_H */
// vi:set ts=2 sw=2: // vi:set ts=2 sw=2:
// Local Variables: // Local Variables:
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_MULTIMAP_H #ifndef __GLIBCPP_INTERNAL_MULTIMAP_H
#define __SGI_STL_INTERNAL_MULTIMAP_H #define __GLIBCPP_INTERNAL_MULTIMAP_H
#include <bits/concept_check.h> #include <bits/concept_check.h>
...@@ -258,7 +258,7 @@ inline void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x, ...@@ -258,7 +258,7 @@ inline void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x,
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_MULTIMAP_H */ #endif /* __GLIBCPP_INTERNAL_MULTIMAP_H */
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_MULTISET_H #ifndef __GLIBCPP_INTERNAL_MULTISET_H
#define __SGI_STL_INTERNAL_MULTISET_H #define __GLIBCPP_INTERNAL_MULTISET_H
#include <bits/concept_check.h> #include <bits/concept_check.h>
...@@ -270,7 +270,7 @@ inline void swap(multiset<_Key,_Compare,_Alloc>& __x, ...@@ -270,7 +270,7 @@ inline void swap(multiset<_Key,_Compare,_Alloc>& __x,
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_MULTISET_H */ #endif /* __GLIBCPP_INTERNAL_MULTISET_H */
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_PAIR_H #ifndef __GLIBCPP_INTERNAL_PAIR_H
#define __SGI_STL_INTERNAL_PAIR_H #define __GLIBCPP_INTERNAL_PAIR_H
namespace std namespace std
{ {
...@@ -150,7 +150,7 @@ inline pair<_T1, _T2> make_pair(const _T1& __x, const _T2& __y) ...@@ -150,7 +150,7 @@ inline pair<_T1, _T2> make_pair(const _T1& __x, const _T2& __y)
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_PAIR_H */ #endif /* __GLIBCPP_INTERNAL_PAIR_H */
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_QUEUE_H #ifndef __GLIBCPP_INTERNAL_QUEUE_H
#define __SGI_STL_INTERNAL_QUEUE_H #define __GLIBCPP_INTERNAL_QUEUE_H
#include <bits/concept_check.h> #include <bits/concept_check.h>
...@@ -237,7 +237,7 @@ public: ...@@ -237,7 +237,7 @@ public:
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_QUEUE_H */ #endif /* __GLIBCPP_INTERNAL_QUEUE_H */
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_SET_H #ifndef __GLIBCPP_INTERNAL_SET_H
#define __SGI_STL_INTERNAL_SET_H #define __GLIBCPP_INTERNAL_SET_H
#include <bits/concept_check.h> #include <bits/concept_check.h>
...@@ -267,7 +267,7 @@ inline void swap(set<_Key,_Compare,_Alloc>& __x, ...@@ -267,7 +267,7 @@ inline void swap(set<_Key,_Compare,_Alloc>& __x,
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_SET_H */ #endif /* __GLIBCPP_INTERNAL_SET_H */
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_STACK_H #ifndef __GLIBCPP_INTERNAL_STACK_H
#define __SGI_STL_INTERNAL_STACK_H #define __GLIBCPP_INTERNAL_STACK_H
#include <bits/concept_check.h> #include <bits/concept_check.h>
...@@ -153,7 +153,7 @@ bool operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) ...@@ -153,7 +153,7 @@ bool operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_STACK_H */ #endif /* __GLIBCPP_INTERNAL_STACK_H */
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_TEMPBUF_H #ifndef __GLIBCPP_INTERNAL_TEMPBUF_H
#define __SGI_STL_INTERNAL_TEMPBUF_H #define __GLIBCPP_INTERNAL_TEMPBUF_H
namespace std namespace std
{ {
...@@ -181,7 +181,7 @@ struct temporary_buffer : public _Temporary_buffer<_ForwardIterator, _Tp> ...@@ -181,7 +181,7 @@ struct temporary_buffer : public _Temporary_buffer<_ForwardIterator, _Tp>
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_TEMPBUF_H */ #endif /* __GLIBCPP_INTERNAL_TEMPBUF_H */
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -60,8 +60,8 @@ ...@@ -60,8 +60,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_TREE_H #ifndef __GLIBCPP_INTERNAL_TREE_H
#define __SGI_STL_INTERNAL_TREE_H #define __GLIBCPP_INTERNAL_TREE_H
/* /*
...@@ -1309,7 +1309,7 @@ struct rb_tree : public _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> ...@@ -1309,7 +1309,7 @@ struct rb_tree : public _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc>
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_TREE_H */ #endif /* __GLIBCPP_INTERNAL_TREE_H */
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef __SGI_STL_INTERNAL_VECTOR_H #ifndef __GLIBCPP_INTERNAL_VECTOR_H
#define __SGI_STL_INTERNAL_VECTOR_H #define __GLIBCPP_INTERNAL_VECTOR_H
#include <bits/stl_iterator_base_funcs.h> #include <bits/stl_iterator_base_funcs.h>
#include <bits/functexcept.h> #include <bits/functexcept.h>
...@@ -802,7 +802,7 @@ vector<_Tp, _Alloc>::_M_range_insert(iterator __position, ...@@ -802,7 +802,7 @@ vector<_Tp, _Alloc>::_M_range_insert(iterator __position,
} // namespace std } // namespace std
#endif /* __SGI_STL_INTERNAL_VECTOR_H */ #endif /* __GLIBCPP_INTERNAL_VECTOR_H */
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -863,15 +863,15 @@ bool rope<_CharT, _Alloc>::_S_apply_to_pieces( ...@@ -863,15 +863,15 @@ bool rope<_CharT, _Alloc>::_S_apply_to_pieces(
size_t __len = __end - __begin; size_t __len = __end - __begin;
bool __result; bool __result;
_CharT* __buffer = _CharT* __buffer =
(_CharT*)alloc::allocate(__len * sizeof(_CharT)); (_CharT*)__alloc::allocate(__len * sizeof(_CharT));
try { try {
(*(__f->_M_fn))(__begin, __len, __buffer); (*(__f->_M_fn))(__begin, __len, __buffer);
__result = __c(__buffer, __len); __result = __c(__buffer, __len);
alloc::deallocate(__buffer, __len * sizeof(_CharT)); __alloc::deallocate(__buffer, __len * sizeof(_CharT));
} }
catch(...) catch(...)
{ {
alloc::deallocate(__buffer, __len * sizeof(_CharT)); __alloc::deallocate(__buffer, __len * sizeof(_CharT));
__throw_exception_again; __throw_exception_again;
} }
return __result; return __result;
......
...@@ -85,7 +85,7 @@ struct _Hashtable_node ...@@ -85,7 +85,7 @@ struct _Hashtable_node
}; };
template <class _Val, class _Key, class _HashFcn, template <class _Val, class _Key, class _HashFcn,
class _ExtractKey, class _EqualKey, class _Alloc = alloc> class _ExtractKey, class _EqualKey, class _Alloc = __alloc>
class hashtable; class hashtable;
template <class _Val, class _Key, class _HashFcn, template <class _Val, class _Key, class _HashFcn,
......
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