Commit 54a3a087 by Benjamin Kosnik Committed by Benjamin Kosnik

Update to SGI STL 3.3


2000-06-27  Benjamin Kosnik  <bkoz@purist.soma.redhat.com>

	Update to SGI STL 3.3
	* ext/hash_map, ext/hash_set, ext/slist, ext/stl_bvector.h,
	ext/stl_rope.h, ext/ropeimpl.h: Update.
	* bits/std_bitset.h, bits/std_map, bits/std_memory.h,
	bits/stl_algo.h, bits/stl_algobase.h, bits/stl_alloc.h,
	bits/stl_config.h, bits/stl_construct.h, bits/stl_deque.h,
	bits/stl_function.h, bits/stl_heap.h, bits/stl_iterator.h,
	bits/stl_iterator_base.h, bits/stl_list.h, bits/stl_map.h,
	bits/stl_multimap.h, bits/stl_multiset.h, bits/stl_numeric.h,
	bits/stl_queue.h, bits/stl_set.h, bits/stl_stack.h,
	bits/stl_string_fwd.h, bits/stl_threads.h, bits/stl_three.h,
	bits/stl_uninitialized.h, bits/stl_vectory.h: Update.

	* src/Makefile.am (headers): Add new files.
	* src/Makefile.in: Regenerate.
	* src/stl-inst.cc (std): Add instantiation for __sink_unused_warning.
	* bits/concept_checks.h: New file.
	* bits/container_concepts.h: New file.
	* bits/sequence_concepts.h: New file.

From-SVN: r34743
parent adae082f
2000-06-26 Benjamin Kosnik <bkoz@purist.soma.redhat.com> 2000-06-27 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
Update to SGI STL 3.3 Update to SGI STL 3.3
* bits/stl_algo.h: Update. * ext/hash_map, ext/hash_set, ext/slist, ext/stl_bvector.h,
* ext/ropeimpl.h: Update. ext/stl_rope.h, ext/ropeimpl.h: Update.
* bits/std_memory.h: Update. * bits/std_bitset.h, bits/std_map, bits/std_memory.h,
* bits/std_bitset.h: Update. bits/stl_algo.h, bits/stl_algobase.h, bits/stl_alloc.h,
bits/stl_config.h, bits/stl_construct.h, bits/stl_deque.h,
bits/stl_function.h, bits/stl_heap.h, bits/stl_iterator.h,
bits/stl_iterator_base.h, bits/stl_list.h, bits/stl_map.h,
bits/stl_multimap.h, bits/stl_multiset.h, bits/stl_numeric.h,
bits/stl_queue.h, bits/stl_set.h, bits/stl_stack.h,
bits/stl_string_fwd.h, bits/stl_threads.h, bits/stl_three.h,
bits/stl_uninitialized.h, bits/stl_vectory.h: Update.
* src/Makefile.am (headers): Add new files. * src/Makefile.am (headers): Add new files.
* src/Makefile.in: Regenerate. * src/Makefile.in: Regenerate.
* src/stl-inst.cc (std): Add instantiation for __sink_unused_warning.
* bits/concept_checks.h: New file. * bits/concept_checks.h: New file.
* bits/container_concepts.h: New file. * bits/container_concepts.h: New file.
* bits/sequence_concepts.h: New file. * bits/sequence_concepts.h: New file.
* src/stl-inst.cc (std): Add instantiation for __sink_unused_warning.
2000-06-27 H.J. Lu <hjl@gnu.org> 2000-06-27 H.J. Lu <hjl@gnu.org>
Loren J. Rittle <ljrittle@acm.org> Loren J. Rittle <ljrittle@acm.org>
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#ifndef _CPP_MAP #ifndef _CPP_MAP
#define _CPP_MAP 1 #define _CPP_MAP 1
#ifndef _CPP_BITS_STL_TREE_H /* XXX is this guard necessary? */ #ifndef _CPP_BITS_STL_TREE_H
#include <bits/stl_tree.h> #include <bits/stl_tree.h>
#endif #endif
#include <bits/stl_map.h> #include <bits/stl_map.h>
......
...@@ -62,9 +62,13 @@ public: ...@@ -62,9 +62,13 @@ public:
return *this; return *this;
} }
#endif /* __STL_MEMBER_TEMPLATES */ #endif /* __STL_MEMBER_TEMPLATES */
~auto_ptr() __STL_NOTHROW { delete _M_ptr; } // Note: The C++ standard says there is supposed to be an empty throw
// specification here, but omitting it is standard conforming. Its
// presence can be detected only if _Tp::~_Tp() throws, but (17.4.3.6/2)
// this is prohibited.
~auto_ptr() { delete _M_ptr; }
_Tp& operator*() const __STL_NOTHROW { _Tp& operator*() const __STL_NOTHROW {
return *_M_ptr; return *_M_ptr;
} }
......
...@@ -49,10 +49,6 @@ ...@@ -49,10 +49,6 @@
# endif # endif
#endif #endif
#ifdef __STL_WIN32THREADS
# include <windows.h>
#endif
#include <bits/std_cstddef.h> #include <bits/std_cstddef.h>
#include <bits/std_cstdlib.h> #include <bits/std_cstdlib.h>
#include <bits/std_cstring.h> #include <bits/std_cstring.h>
...@@ -281,7 +277,8 @@ typedef malloc_alloc single_client_alloc; ...@@ -281,7 +277,8 @@ typedef malloc_alloc single_client_alloc;
// creation of multiple default_alloc instances. // creation of multiple default_alloc instances.
// Node that containers built on different allocator instances have // Node that containers built on different allocator instances have
// different types, limiting the utility of this approach. // different types, limiting the utility of this approach.
#ifdef __SUNPRO_CC
#if defined(__SUNPRO_CC) || defined(__GNUC__)
// breaks if we make these template class members: // breaks if we make these template class members:
enum {_ALIGN = 8}; enum {_ALIGN = 8};
enum {_MAX_BYTES = 128}; enum {_MAX_BYTES = 128};
...@@ -294,7 +291,7 @@ class __default_alloc_template { ...@@ -294,7 +291,7 @@ class __default_alloc_template {
private: private:
// Really we should use static const int x = N // Really we should use static const int x = N
// instead of enum { x = N }, but few compilers accept the former. // instead of enum { x = N }, but few compilers accept the former.
# ifndef __SUNPRO_CC #if ! (defined(__SUNPRO_CC) || defined(__GNUC__))
enum {_ALIGN = 8}; enum {_ALIGN = 8};
enum {_MAX_BYTES = 128}; enum {_MAX_BYTES = 128};
enum {_NFREELISTS = 16}; // _MAX_BYTES/_ALIGN enum {_NFREELISTS = 16}; // _MAX_BYTES/_ALIGN
...@@ -309,7 +306,7 @@ __PRIVATE: ...@@ -309,7 +306,7 @@ __PRIVATE:
char _M_client_data[1]; /* The client sees this. */ char _M_client_data[1]; /* The client sees this. */
}; };
private: private:
# ifdef __SUNPRO_CC # if defined(__SUNPRO_CC) || defined(__GNUC__) || defined(__HP_aCC)
static _Obj* __STL_VOLATILE _S_free_list[]; static _Obj* __STL_VOLATILE _S_free_list[];
// Specifying a size results in duplicate def for 4.1 // Specifying a size results in duplicate def for 4.1
# else # else
...@@ -405,6 +402,22 @@ public: ...@@ -405,6 +402,22 @@ public:
typedef __default_alloc_template<__NODE_ALLOCATOR_THREADS, 0> alloc; typedef __default_alloc_template<__NODE_ALLOCATOR_THREADS, 0> alloc;
typedef __default_alloc_template<false, 0> single_client_alloc; typedef __default_alloc_template<false, 0> single_client_alloc;
template <bool __threads, int __inst>
inline bool operator==(const __default_alloc_template<__threads, __inst>&,
const __default_alloc_template<__threads, __inst>&)
{
return true;
}
# ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
template <bool __threads, int __inst>
inline bool operator!=(const __default_alloc_template<__threads, __inst>&,
const __default_alloc_template<__threads, __inst>&)
{
return false;
}
# endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
/* We allocate memory in large chunks in order to avoid fragmenting */ /* We allocate memory in large chunks in order to avoid fragmenting */
...@@ -548,9 +561,9 @@ template <bool __threads, int __inst> ...@@ -548,9 +561,9 @@ template <bool __threads, int __inst>
size_t __default_alloc_template<__threads, __inst>::_S_heap_size = 0; size_t __default_alloc_template<__threads, __inst>::_S_heap_size = 0;
template <bool __threads, int __inst> template <bool __threads, int __inst>
__default_alloc_template<__threads, __inst>::_Obj* __STL_VOLATILE typename __default_alloc_template<__threads, __inst>::_Obj* __STL_VOLATILE
__default_alloc_template<__threads, __inst> ::_S_free_list[ __default_alloc_template<__threads, __inst> ::_S_free_list[
# ifdef __SUNPRO_CC # if defined(__SUNPRO_CC) || defined(__GNUC__) || defined(__HP_aCC)
_NFREELISTS _NFREELISTS
# else # else
__default_alloc_template<__threads, __inst>::_NFREELISTS __default_alloc_template<__threads, __inst>::_NFREELISTS
...@@ -742,24 +755,6 @@ inline bool operator!=(const __malloc_alloc_template<__inst>&, ...@@ -742,24 +755,6 @@ inline bool operator!=(const __malloc_alloc_template<__inst>&,
} }
#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
#ifndef __USE_MALLOC
template <bool __threads, int __inst>
inline bool operator==(const __default_alloc_template<__threads, __inst>&,
const __default_alloc_template<__threads, __inst>&)
{
return true;
}
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
template <bool __threads, int __inst>
inline bool operator!=(const __default_alloc_template<__threads, __inst>&,
const __default_alloc_template<__threads, __inst>&)
{
return false;
}
#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
#endif
template <class _Alloc> template <class _Alloc>
inline bool operator==(const debug_alloc<_Alloc>&, inline bool operator==(const debug_alloc<_Alloc>&,
const debug_alloc<_Alloc>&) { const debug_alloc<_Alloc>&) {
......
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
// member functions of classes. // member functions of classes.
// * __STL_MEMBER_TEMPLATE_CLASSES: defined if the compiler supports // * __STL_MEMBER_TEMPLATE_CLASSES: defined if the compiler supports
// nested classes that are member templates of other classes. // nested classes that are member templates of other classes.
// * __STL_TEMPLATE_FRIENDS: defined if the compiler supports templatized
// friend declarations.
// * __STL_EXPLICIT_FUNCTION_TMPL_ARGS: defined if the compiler // * __STL_EXPLICIT_FUNCTION_TMPL_ARGS: defined if the compiler
// supports calling a function template by providing its template // supports calling a function template by providing its template
// arguments explicitly. // arguments explicitly.
...@@ -86,8 +88,23 @@ ...@@ -86,8 +88,23 @@
// types. (They're not in the C++ standard, but they are expected to be // types. (They're not in the C++ standard, but they are expected to be
// included in the forthcoming C9X standard.) // included in the forthcoming C9X standard.)
// * __STL_THREADS is defined if thread safety is needed. // * __STL_THREADS is defined if thread safety is needed.
// * __STL_VOLATILE is deifined to be "volatile" if threads are being // * __STL_VOLATILE is defined to be "volatile" if threads are being
// used, and the empty string otherwise. // used, and the empty string otherwise.
// * __STL_USE_CONCEPT_CHECKS enables some extra compile-time error
// checking to make sure that user-defined template arguments satisfy
// all of the appropriate requirements. This may result in more
// comprehensible error messages. It incurs no runtime overhead. This
// feature requires member templates and partial specialization.
// * __STL_NO_USING_CLAUSE_IN_CLASS: The compiler does not handle "using"
// clauses inside of class definitions.
// * __STL_NO_FRIEND_TEMPLATE_CLASS: The compiler does not handle friend
// declaractions where the friend is a template class.
// * __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE: The compiler does not
// support the use of a function pointer type as the argument
// for a template.
// * __STL_MEMBER_TEMPLATE_KEYWORD: standard C++ requires the template
// keyword in a few new places (14.2.4). This flag is set for
// compilers that support (and require) this usage.
// User-settable macros that control compilation: // User-settable macros that control compilation:
...@@ -107,6 +124,8 @@ ...@@ -107,6 +124,8 @@
// * _UITHREADS:if defined, use SCO/Solaris/UI threads for multithreading // * _UITHREADS:if defined, use SCO/Solaris/UI threads for multithreading
// support // support
// * _NOTHREADS: if defined, don't use any multithreading support. // * _NOTHREADS: if defined, don't use any multithreading support.
// * _STL_NO_CONCEPT_CHECKS: if defined, disables the error checking that
// we get from __STL_USE_CONCEPT_CHECKS.
// * __STL_USE_NEW_IOSTREAMS: if defined, then the STL will use new, // * __STL_USE_NEW_IOSTREAMS: if defined, then the STL will use new,
// standard-conforming iostreams (e.g. the <iosfwd> header). If not // standard-conforming iostreams (e.g. the <iosfwd> header). If not
// defined, the STL will use old cfront-style iostreams (e.g. the // defined, the STL will use old cfront-style iostreams (e.g. the
...@@ -152,6 +171,7 @@ ...@@ -152,6 +171,7 @@
# endif # endif
# ifdef _MEMBER_TEMPLATES # ifdef _MEMBER_TEMPLATES
# define __STL_MEMBER_TEMPLATES # define __STL_MEMBER_TEMPLATES
# define __STL_TEMPLATE_FRIENDS
# define __STL_MEMBER_TEMPLATE_CLASSES # define __STL_MEMBER_TEMPLATE_CLASSES
# endif # endif
# if defined(_MEMBER_TEMPLATE_KEYWORD) # if defined(_MEMBER_TEMPLATE_KEYWORD)
...@@ -163,7 +183,7 @@ ...@@ -163,7 +183,7 @@
# if (_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32 # if (_COMPILER_VERSION >= 730) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32
# define __STL_MEMBER_TEMPLATE_KEYWORD # define __STL_MEMBER_TEMPLATE_KEYWORD
# endif # endif
# if defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32 # if COMPILER_VERSION < 720 || (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32)
# define __STL_DEFAULT_CONSTRUCTOR_BUG # define __STL_DEFAULT_CONSTRUCTOR_BUG
# endif # endif
# if !defined(_EXPLICIT_IS_KEYWORD) # if !defined(_EXPLICIT_IS_KEYWORD)
...@@ -175,7 +195,8 @@ ...@@ -175,7 +195,8 @@
# if (_COMPILER_VERSION >= 721) && defined(_NAMESPACES) # if (_COMPILER_VERSION >= 721) && defined(_NAMESPACES)
# define __STL_HAS_NAMESPACES # define __STL_HAS_NAMESPACES
# endif # endif
# if (_COMPILER_VERSION < 721) # if (_COMPILER_VERSION < 721) || \
!defined(__STL_HAS_NAMESPACES) || defined(__STL_NO_NAMESPACES)
# define __STL_NO_EXCEPTION_HEADER # define __STL_NO_EXCEPTION_HEADER
# endif # endif
# if _COMPILER_VERSION < 730 || !defined(_STANDARD_C_PLUS_PLUS) || \ # if _COMPILER_VERSION < 730 || !defined(_STANDARD_C_PLUS_PLUS) || \
...@@ -236,6 +257,7 @@ ...@@ -236,6 +257,7 @@
# define __STL_HAS_WCHAR_T # define __STL_HAS_WCHAR_T
# define __STL_MEMBER_TEMPLATES # define __STL_MEMBER_TEMPLATES
# define __STL_MEMBER_TEMPLATE_CLASSES # define __STL_MEMBER_TEMPLATE_CLASSES
# define __STL_TEMPLATE_FRIENDS
# define __STL_CLASS_PARTIAL_SPECIALIZATION # define __STL_CLASS_PARTIAL_SPECIALIZATION
# define __STL_PARTIAL_SPECIALIZATION_SYNTAX # define __STL_PARTIAL_SPECIALIZATION_SYNTAX
# define __STL_FUNCTION_TMPL_PARTIAL_ORDER # define __STL_FUNCTION_TMPL_PARTIAL_ORDER
...@@ -257,6 +279,9 @@ ...@@ -257,6 +279,9 @@
# ifndef __STRICT_ANSI__ # ifndef __STRICT_ANSI__
# define __STL_LONG_LONG # define __STL_LONG_LONG
# endif # endif
# if (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR__ < 95)
# define __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE
# endif
# endif # endif
# if defined(__SUNPRO_CC) # if defined(__SUNPRO_CC)
...@@ -276,6 +301,7 @@ ...@@ -276,6 +301,7 @@
# if defined(__COMO__) # if defined(__COMO__)
# define __STL_MEMBER_TEMPLATES # define __STL_MEMBER_TEMPLATES
# define __STL_MEMBER_TEMPLATE_CLASSES # define __STL_MEMBER_TEMPLATE_CLASSES
# define __STL_TEMPLATE_FRIENDS
# define __STL_CLASS_PARTIAL_SPECIALIZATION # define __STL_CLASS_PARTIAL_SPECIALIZATION
# define __STL_USE_EXCEPTIONS # define __STL_USE_EXCEPTIONS
# define __STL_HAS_NAMESPACES # define __STL_HAS_NAMESPACES
...@@ -286,6 +312,7 @@ ...@@ -286,6 +312,7 @@
# define __STL_LONG_LONG # define __STL_LONG_LONG
# define __STL_MEMBER_TEMPLATES # define __STL_MEMBER_TEMPLATES
# define __STL_MEMBER_TEMPLATE_CLASSES # define __STL_MEMBER_TEMPLATE_CLASSES
# define __STL_TEMPLATE_FRIENDS
# define __STL_FUNCTION_TMPL_PARTIAL_ORDER # define __STL_FUNCTION_TMPL_PARTIAL_ORDER
# define __STL_CLASS_PARTIAL_SPECIALIZATION # define __STL_CLASS_PARTIAL_SPECIALIZATION
# define __STL_NO_DRAND48 # define __STL_NO_DRAND48
...@@ -300,19 +327,32 @@ ...@@ -300,19 +327,32 @@
# endif # endif
# endif # endif
// Mingw32, EGCS compiler using the Microsoft C runtime // Mingw32, egcs compiler using the Microsoft C runtime
# if defined(__MINGW32__) # if defined(__MINGW32__)
# define __STL_NO_DRAND48 # define __STL_NO_DRAND48
# ifdef _MT
# define __STL_WIN32THREADS
# endif
# endif # endif
// Cygwin32, egcs compiler on MS Windows
# if defined(__CYGWIN__)
# define __STL_NO_DRAND48
# endif
// Microsoft compiler. // Microsoft compiler.
# if defined(_MSC_VER) && !defined(__ICL) # if defined(_MSC_VER) && !defined(__ICL) && !defined(__MWERKS__)
# define __STL_NO_DRAND48 # define __STL_NO_DRAND48
# define __STL_STATIC_CONST_INIT_BUG # define __STL_STATIC_CONST_INIT_BUG
# define __STL_NEED_TYPENAME # define __STL_NEED_TYPENAME
# define __STL_NO_USING_CLAUSE_IN_CLASS
# define __STL_NO_FRIEND_TEMPLATE_CLASS
# if _MSC_VER < 1100 /* 1000 is version 4.0, 1100 is 5.0, 1200 is 6.0. */ # if _MSC_VER < 1100 /* 1000 is version 4.0, 1100 is 5.0, 1200 is 6.0. */
# define __STL_NEED_EXPLICIT # define __STL_NEED_EXPLICIT
# define __STL_NO_BOOL # define __STL_NO_BOOL
# define __STL_NO_BAD_ALLOC
# endif # endif
# if _MSC_VER > 1000 # if _MSC_VER > 1000
# include <yvals.h> # include <yvals.h>
...@@ -330,8 +370,16 @@ ...@@ -330,8 +370,16 @@
# if _MSC_VER >= 1200 # if _MSC_VER >= 1200
# define __STL_PARTIAL_SPECIALIZATION_SYNTAX # define __STL_PARTIAL_SPECIALIZATION_SYNTAX
# define __STL_HAS_NAMESPACES # define __STL_HAS_NAMESPACES
# define __STL_NO_NAMESPACES
# define __STL_CAN_THROW_RANGE_ERRORS # define __STL_CAN_THROW_RANGE_ERRORS
# define NOMINMAX
# undef min
# undef max
// disable warning 'initializers put in unrecognized initialization area'
# pragma warning ( disable : 4075 )
// disable warning 'empty controlled statement found'
# pragma warning ( disable : 4390 )
// disable warning 'debug symbol greater than 255 chars'
# pragma warning ( disable : 4786 )
# endif # endif
# if _MSC_VER < 1100 # if _MSC_VER < 1100
# define __STL_NO_EXCEPTION_HEADER # define __STL_NO_EXCEPTION_HEADER
...@@ -343,13 +391,21 @@ ...@@ -343,13 +391,21 @@
# endif # endif
# if defined(__BORLANDC__) # if defined(__BORLANDC__)
# define __STL_NO_BAD_ALLOC # define __STL_NO_BAD_ALLOC
# define __STL_NO_DRAND48 # define __STL_NO_DRAND48
# define __STL_NEED_TYPENAME # define __STL_DEFAULT_CONSTRUCTOR_BUG
# define __STL_LIMITED_DEFAULT_TEMPLATES # if __BORLANDC__ >= 0x540 /* C++ Builder 4.0 */
# define __SGI_STL_NO_ARROW_OPERATOR # define __STL_CLASS_PARTIAL_SPECIALIZATION
# define __STL_DEFAULT_CONSTRUCTOR_BUG # define __STL_FUNCTION_TMPL_PARTIAL_ORDER
# define __STL_NON_TYPE_TMPL_PARAM_BUG # define __STL_EXPLICIT_FUNCTION_TMPL_ARGS
# define __STL_MEMBER_TEMPLATES
# define __STL_TEMPLATE_FRIENDS
# else
# define __STL_NEED_TYPENAME
# define __STL_LIMITED_DEFAULT_TEMPLATES
# define __SGI_STL_NO_ARROW_OPERATOR
# define __STL_NON_TYPE_TMPL_PARAM_BUG
# endif
# ifdef _CPPUNWIND # ifdef _CPPUNWIND
# define __STL_USE_EXCEPTIONS # define __STL_USE_EXCEPTIONS
# endif # endif
...@@ -368,6 +424,12 @@ ...@@ -368,6 +424,12 @@
# define typename # define typename
# endif # endif
# ifdef __STL_LIMITED_DEFAULT_TEMPLATES
# define __STL_DEPENDENT_DEFAULT_TMPL(_Tp)
# else
# define __STL_DEPENDENT_DEFAULT_TMPL(_Tp) = _Tp
# endif
# ifdef __STL_MEMBER_TEMPLATE_KEYWORD # ifdef __STL_MEMBER_TEMPLATE_KEYWORD
# define __STL_TEMPLATE template # define __STL_TEMPLATE template
# else # else
...@@ -405,6 +467,14 @@ ...@@ -405,6 +467,14 @@
# define __STL_USE_STD_ALLOCATORS # define __STL_USE_STD_ALLOCATORS
# endif # endif
# ifndef __STL_DEFAULT_ALLOCATOR
# ifdef __STL_USE_STD_ALLOCATORS
# define __STL_DEFAULT_ALLOCATOR(T) allocator< T >
# else
# define __STL_DEFAULT_ALLOCATOR(T) alloc
# endif
# endif
// __STL_NO_NAMESPACES is a hook so that users can disable namespaces // __STL_NO_NAMESPACES is a hook so that users can disable namespaces
// without having to edit library headers. __STL_NO_RELOPS_NAMESPACE is // without having to edit library headers. __STL_NO_RELOPS_NAMESPACE is
// a hook so that users can disable the std::rel_ops namespace, keeping // a hook so that users can disable the std::rel_ops namespace, keeping
...@@ -475,7 +545,7 @@ ...@@ -475,7 +545,7 @@
# define __stl_assert(expr) # define __stl_assert(expr)
#endif #endif
#if defined(__STL_WIN32THREADS) || defined(STL_SGI_THREADS) \ #if defined(__STL_WIN32THREADS) || defined(__STL_SGI_THREADS) \
|| defined(__STL_PTHREADS) || defined(__STL_UITHREADS) || defined(__STL_PTHREADS) || defined(__STL_UITHREADS)
# define __STL_THREADS # define __STL_THREADS
# define __STL_VOLATILE volatile # define __STL_VOLATILE volatile
...@@ -483,6 +553,13 @@ ...@@ -483,6 +553,13 @@
# define __STL_VOLATILE # define __STL_VOLATILE
#endif #endif
#if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) \
&& defined(__STL_MEMBER_TEMPLATES) \
&& !defined(_STL_NO_CONCEPT_CHECKS)
# define __STL_USE_CONCEPT_CHECKS
#endif
#endif /* __STL_CONFIG_H */ #endif /* __STL_CONFIG_H */
// Local Variables: // Local Variables:
......
...@@ -36,23 +36,28 @@ ...@@ -36,23 +36,28 @@
__STL_BEGIN_NAMESPACE __STL_BEGIN_NAMESPACE
// construct and destroy. These functions are not part of the C++ standard, // construct and destroy. These functions are not part of the C++ standard,
// and are provided for backward compatibility with the HP STL. // and are provided for backward compatibility with the HP STL. We also
// provide internal names _Construct and _Destroy that can be used within
// the library, so that standard-conforming pieces don't have to rely on
// non-standard extensions.
template <class _Tp> // Internal names
inline void destroy(_Tp* __pointer) {
__pointer->_Tp::~_Tp();
}
template <class _Tp1, class _Tp2> template <class _T1, class _T2>
inline void construct(_Tp1* __p, const _Tp2& __value) { inline void _Construct(_T1* __p, const _T2& __value) {
new (__p) _Tp1(__value); new ((void*) __p) _T1(__value);
} }
template <class _Tp1> template <class _T1>
inline void construct(_Tp1* __p) { inline void _Construct(_T1* __p) {
new (__p) _Tp1(); new ((void*) __p) _T1();
} }
template <class _Tp>
inline void _Destroy(_Tp* __pointer) {
__pointer->~_Tp();
}
template <class _ForwardIterator> template <class _ForwardIterator>
void void
__destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type) __destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type)
...@@ -74,12 +79,41 @@ __destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*) ...@@ -74,12 +79,41 @@ __destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*)
} }
template <class _ForwardIterator> template <class _ForwardIterator>
inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { inline void _Destroy(_ForwardIterator __first, _ForwardIterator __last) {
__destroy(__first, __last, __VALUE_TYPE(__first)); __destroy(__first, __last, __VALUE_TYPE(__first));
} }
inline void destroy(char*, char*) {} inline void _Destroy(char*, char*) {}
inline void destroy(wchar_t*, wchar_t*) {} inline void _Destroy(int*, int*) {}
inline void _Destroy(long*, long*) {}
inline void _Destroy(float*, float*) {}
inline void _Destroy(double*, double*) {}
#ifdef __STL_HAS_WCHAR_T
inline void _Destroy(wchar_t*, wchar_t*) {}
#endif /* __STL_HAS_WCHAR_T */
// --------------------------------------------------
// Old names from the HP STL.
template <class _T1, class _T2>
inline void construct(_T1* __p, const _T2& __value) {
_Construct(__p, __value);
}
template <class _T1>
inline void construct(_T1* __p) {
_Construct(__p);
}
template <class _Tp>
inline void destroy(_Tp* __pointer) {
_Destroy(__pointer);
}
template <class _ForwardIterator>
inline void destroy(_ForwardIterator __first, _ForwardIterator __last) {
_Destroy(__first, __last);
}
__STL_END_NAMESPACE __STL_END_NAMESPACE
......
...@@ -411,7 +411,7 @@ struct _Constant_binary_fun { ...@@ -411,7 +411,7 @@ struct _Constant_binary_fun {
template <class _Result> template <class _Result>
struct constant_void_fun : public _Constant_void_fun<_Result> { struct constant_void_fun : public _Constant_void_fun<_Result> {
constant_void_fun(const _Result& __v) : _Constant_void_fun<_Result>(_v) {} constant_void_fun(const _Result& __v) : _Constant_void_fun<_Result>(__v) {}
}; };
......
...@@ -65,6 +65,9 @@ template <class _RandomAccessIterator> ...@@ -65,6 +65,9 @@ template <class _RandomAccessIterator>
inline void inline void
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{ {
__STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);
__STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type,
_LessThanComparable);
__push_heap_aux(__first, __last, __push_heap_aux(__first, __last,
__DISTANCE_TYPE(__first), __VALUE_TYPE(__first)); __DISTANCE_TYPE(__first), __VALUE_TYPE(__first));
} }
...@@ -100,6 +103,7 @@ inline void ...@@ -100,6 +103,7 @@ inline void
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
_Compare __comp) _Compare __comp)
{ {
__STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);
__push_heap_aux(__first, __last, __comp, __push_heap_aux(__first, __last, __comp,
__DISTANCE_TYPE(__first), __VALUE_TYPE(__first)); __DISTANCE_TYPE(__first), __VALUE_TYPE(__first));
} }
...@@ -147,6 +151,9 @@ template <class _RandomAccessIterator> ...@@ -147,6 +151,9 @@ template <class _RandomAccessIterator>
inline void pop_heap(_RandomAccessIterator __first, inline void pop_heap(_RandomAccessIterator __first,
_RandomAccessIterator __last) _RandomAccessIterator __last)
{ {
__STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);
__STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type,
_LessThanComparable);
__pop_heap_aux(__first, __last, __VALUE_TYPE(__first)); __pop_heap_aux(__first, __last, __VALUE_TYPE(__first));
} }
...@@ -198,7 +205,8 @@ inline void ...@@ -198,7 +205,8 @@ inline void
pop_heap(_RandomAccessIterator __first, pop_heap(_RandomAccessIterator __first,
_RandomAccessIterator __last, _Compare __comp) _RandomAccessIterator __last, _Compare __comp)
{ {
__pop_heap_aux(__first, __last, __VALUE_TYPE(__first), __comp); __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);
__pop_heap_aux(__first, __last, __VALUE_TYPE(__first), __comp);
} }
template <class _RandomAccessIterator, class _Tp, class _Distance> template <class _RandomAccessIterator, class _Tp, class _Distance>
...@@ -221,6 +229,9 @@ template <class _RandomAccessIterator> ...@@ -221,6 +229,9 @@ template <class _RandomAccessIterator>
inline void inline void
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{ {
__STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);
__STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type,
_LessThanComparable);
__make_heap(__first, __last, __make_heap(__first, __last,
__VALUE_TYPE(__first), __DISTANCE_TYPE(__first)); __VALUE_TYPE(__first), __DISTANCE_TYPE(__first));
} }
...@@ -248,6 +259,7 @@ inline void ...@@ -248,6 +259,7 @@ inline void
make_heap(_RandomAccessIterator __first, make_heap(_RandomAccessIterator __first,
_RandomAccessIterator __last, _Compare __comp) _RandomAccessIterator __last, _Compare __comp)
{ {
__STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);
__make_heap(__first, __last, __comp, __make_heap(__first, __last, __comp,
__VALUE_TYPE(__first), __DISTANCE_TYPE(__first)); __VALUE_TYPE(__first), __DISTANCE_TYPE(__first));
} }
...@@ -255,6 +267,9 @@ make_heap(_RandomAccessIterator __first, ...@@ -255,6 +267,9 @@ make_heap(_RandomAccessIterator __first,
template <class _RandomAccessIterator> template <class _RandomAccessIterator>
void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{ {
__STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);
__STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type,
_LessThanComparable);
while (__last - __first > 1) while (__last - __first > 1)
pop_heap(__first, __last--); pop_heap(__first, __last--);
} }
...@@ -264,6 +279,7 @@ void ...@@ -264,6 +279,7 @@ void
sort_heap(_RandomAccessIterator __first, sort_heap(_RandomAccessIterator __first,
_RandomAccessIterator __last, _Compare __comp) _RandomAccessIterator __last, _Compare __comp)
{ {
__STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator);
while (__last - __first > 1) while (__last - __first > 1)
pop_heap(__first, __last--, __comp); pop_heap(__first, __last--, __comp);
} }
......
...@@ -513,7 +513,7 @@ operator!=(const reverse_iterator<_RandomAccessIterator, _Tp, ...@@ -513,7 +513,7 @@ operator!=(const reverse_iterator<_RandomAccessIterator, _Tp,
_Reference, _Distance>& __x, _Reference, _Distance>& __x,
const reverse_iterator<_RandomAccessIterator, _Tp, const reverse_iterator<_RandomAccessIterator, _Tp,
_Reference, _Distance>& __y) { _Reference, _Distance>& __y) {
return !(__x == __y); } return !(__x == __y);
} }
template <class _RandomAccessIterator, class _Tp, template <class _RandomAccessIterator, class _Tp,
...@@ -679,6 +679,8 @@ private: ...@@ -679,6 +679,8 @@ private:
// operator* or operator++ has been called, _M_is_initialized is false. // operator* or operator++ has been called, _M_is_initialized is false.
template<class _CharT, class _Traits> template<class _CharT, class _Traits>
class istreambuf_iterator class istreambuf_iterator
: public iterator<input_iterator_tag, _CharT,
typename _Traits::off_type, _CharT*, _CharT&>
{ {
public: public:
typedef _CharT char_type; typedef _CharT char_type;
...@@ -687,12 +689,6 @@ public: ...@@ -687,12 +689,6 @@ public:
typedef basic_streambuf<_CharT, _Traits> streambuf_type; typedef basic_streambuf<_CharT, _Traits> streambuf_type;
typedef basic_istream<_CharT, _Traits> istream_type; typedef basic_istream<_CharT, _Traits> istream_type;
typedef input_iterator_tag iterator_category;
typedef _CharT value_type;
typedef typename _Traits::off_type difference_type;
typedef const _CharT* pointer;
typedef const _CharT& reference;
public: public:
istreambuf_iterator(streambuf_type* __p = 0) { this->_M_init(__p); } istreambuf_iterator(streambuf_type* __p = 0) { this->_M_init(__p); }
istreambuf_iterator(istream_type& __is) { this->_M_init(__is.rdbuf()); } istreambuf_iterator(istream_type& __is) { this->_M_init(__is.rdbuf()); }
...@@ -791,6 +787,7 @@ inline bool operator!=(const istreambuf_iterator<_CharT, _Traits>& __x, ...@@ -791,6 +787,7 @@ inline bool operator!=(const istreambuf_iterator<_CharT, _Traits>& __x,
// The default template argument is declared in iosfwd // The default template argument is declared in iosfwd
template<class _CharT, class _Traits> template<class _CharT, class _Traits>
class ostreambuf_iterator class ostreambuf_iterator
: public iterator<output_iterator_tag, void, void, void, void>
{ {
public: public:
typedef _CharT char_type; typedef _CharT char_type;
...@@ -799,16 +796,10 @@ public: ...@@ -799,16 +796,10 @@ public:
typedef basic_streambuf<_CharT, _Traits> streambuf_type; typedef basic_streambuf<_CharT, _Traits> streambuf_type;
typedef basic_ostream<_CharT, _Traits> ostream_type; typedef basic_ostream<_CharT, _Traits> ostream_type;
typedef output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
public: public:
ostreambuf_iterator(streambuf_type* __buf) : _M_buf(__buf), _M_ok(__buf) {} ostreambuf_iterator(streambuf_type* __buf) : _M_buf(__buf), _M_ok(__buf) {}
ostreambuf_iterator(ostream_type& __o) ostreambuf_iterator(ostream_type& __o)
: _M_buf(__o.rdbuf()), _M_ok(__o.rdbuf()) {} : _M_buf(__o.rdbuf()), _M_ok(__o.rdbuf() != 0) {}
ostreambuf_iterator& operator=(char_type __c) { ostreambuf_iterator& operator=(char_type __c) {
_M_ok = _M_ok && !traits_type::eq_int_type(_M_buf->sputc(__c), _M_ok = _M_ok && !traits_type::eq_int_type(_M_buf->sputc(__c),
...@@ -837,15 +828,15 @@ inline bool operator==(const istream_iterator<_Tp, _Dist>&, ...@@ -837,15 +828,15 @@ inline bool operator==(const istream_iterator<_Tp, _Dist>&,
template <class _Tp, class _Dist> template <class _Tp, class _Dist>
class istream_iterator { class istream_iterator {
#ifdef __STL_MEMBER_TEMPLATES #ifdef __STL_TEMPLATE_FRIENDS
template <class _T1, class _D1> template <class _T1, class _D1>
friend bool operator==(const istream_iterator<_T1, _D1>&, friend bool operator==(const istream_iterator<_T1, _D1>&,
const istream_iterator<_T1, _D1>&); const istream_iterator<_T1, _D1>&);
#else /* __STL_MEMBER_TEMPLATES */ #else /* __STL_TEMPLATE_FRIENDS */
friend bool __STD_QUALIFIER friend bool __STD_QUALIFIER
operator== __STL_NULL_TMPL_ARGS (const istream_iterator&, operator== __STL_NULL_TMPL_ARGS (const istream_iterator&,
const istream_iterator&); const istream_iterator&);
#endif /* __STL_MEMBER_TEMPLATES */ #endif /* __STL_TEMPLATE_FRIENDS */
protected: protected:
istream* _M_stream; istream* _M_stream;
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
// The internal file stl_iterator.h contains predefined iterators, // The internal file stl_iterator.h contains predefined iterators,
// such as front_insert_iterator and istream_iterator. // such as front_insert_iterator and istream_iterator.
#include <bits/concept_checks.h>
__STL_BEGIN_NAMESPACE __STL_BEGIN_NAMESPACE
struct input_iterator_tag {}; struct input_iterator_tag {};
...@@ -274,6 +276,7 @@ inline void __distance(_RandomAccessIterator __first, ...@@ -274,6 +276,7 @@ inline void __distance(_RandomAccessIterator __first,
_RandomAccessIterator __last, _RandomAccessIterator __last,
_Distance& __n, random_access_iterator_tag) _Distance& __n, random_access_iterator_tag)
{ {
__STL_REQUIRES(_RandomAccessIterator, _RandomAccessIterator);
__n += __last - __first; __n += __last - __first;
} }
...@@ -281,6 +284,7 @@ template <class _InputIterator, class _Distance> ...@@ -281,6 +284,7 @@ template <class _InputIterator, class _Distance>
inline void distance(_InputIterator __first, inline void distance(_InputIterator __first,
_InputIterator __last, _Distance& __n) _InputIterator __last, _Distance& __n)
{ {
__STL_REQUIRES(_InputIterator, _InputIterator);
__distance(__first, __last, __n, iterator_category(__first)); __distance(__first, __last, __n, iterator_category(__first));
} }
...@@ -301,6 +305,7 @@ template <class _RandomAccessIterator> ...@@ -301,6 +305,7 @@ template <class _RandomAccessIterator>
inline typename iterator_traits<_RandomAccessIterator>::difference_type inline typename iterator_traits<_RandomAccessIterator>::difference_type
__distance(_RandomAccessIterator __first, _RandomAccessIterator __last, __distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
random_access_iterator_tag) { random_access_iterator_tag) {
__STL_REQUIRES(_RandomAccessIterator, _RandomAccessIterator);
return __last - __first; return __last - __first;
} }
...@@ -309,6 +314,7 @@ inline typename iterator_traits<_InputIterator>::difference_type ...@@ -309,6 +314,7 @@ inline typename iterator_traits<_InputIterator>::difference_type
distance(_InputIterator __first, _InputIterator __last) { distance(_InputIterator __first, _InputIterator __last) {
typedef typename iterator_traits<_InputIterator>::iterator_category typedef typename iterator_traits<_InputIterator>::iterator_category
_Category; _Category;
__STL_REQUIRES(_InputIterator, _InputIterator);
return __distance(__first, __last, _Category()); return __distance(__first, __last, _Category());
} }
...@@ -326,6 +332,7 @@ inline void __advance(_InputIter& __i, _Distance __n, input_iterator_tag) { ...@@ -326,6 +332,7 @@ inline void __advance(_InputIter& __i, _Distance __n, input_iterator_tag) {
template <class _BidirectionalIterator, class _Distance> template <class _BidirectionalIterator, class _Distance>
inline void __advance(_BidirectionalIterator& __i, _Distance __n, inline void __advance(_BidirectionalIterator& __i, _Distance __n,
bidirectional_iterator_tag) { bidirectional_iterator_tag) {
__STL_REQUIRES(_BidirectionalIterator, _BidirectionalIterator);
if (__n >= 0) if (__n >= 0)
while (__n--) ++__i; while (__n--) ++__i;
else else
...@@ -339,11 +346,13 @@ inline void __advance(_BidirectionalIterator& __i, _Distance __n, ...@@ -339,11 +346,13 @@ inline void __advance(_BidirectionalIterator& __i, _Distance __n,
template <class _RandomAccessIterator, class _Distance> template <class _RandomAccessIterator, class _Distance>
inline void __advance(_RandomAccessIterator& __i, _Distance __n, inline void __advance(_RandomAccessIterator& __i, _Distance __n,
random_access_iterator_tag) { random_access_iterator_tag) {
__STL_REQUIRES(_RandomAccessIterator, _RandomAccessIterator);
__i += __n; __i += __n;
} }
template <class _InputIterator, class _Distance> template <class _InputIterator, class _Distance>
inline void advance(_InputIterator& __i, _Distance __n) { inline void advance(_InputIterator& __i, _Distance __n) {
__STL_REQUIRES(_InputIterator, _InputIterator);
__advance(__i, __n, iterator_category(__i)); __advance(__i, __n, iterator_category(__i));
} }
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#ifndef _CPP_BITS_STL_MAP_H #ifndef _CPP_BITS_STL_MAP_H
#define _CPP_BITS_STL_MAP_H 1 #define _CPP_BITS_STL_MAP_H 1
#include <bits/concept_checks.h>
__STL_BEGIN_NAMESPACE __STL_BEGIN_NAMESPACE
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
...@@ -43,6 +45,11 @@ template <class _Key, class _Tp, class _Compare = less<_Key>, ...@@ -43,6 +45,11 @@ template <class _Key, class _Tp, class _Compare = less<_Key>,
class map { class map {
public: public:
// requirements:
__STL_CLASS_REQUIRES(_Tp, _Assignable);
__STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key);
// typedefs: // typedefs:
typedef _Key key_type; typedef _Key key_type;
...@@ -181,7 +188,9 @@ public: ...@@ -181,7 +188,9 @@ public:
iterator find(const key_type& __x) { return _M_t.find(__x); } iterator find(const key_type& __x) { return _M_t.find(__x); }
const_iterator find(const key_type& __x) const { return _M_t.find(__x); } const_iterator find(const key_type& __x) const { return _M_t.find(__x); }
size_type count(const key_type& __x) const { return _M_t.count(__x); } size_type count(const key_type& __x) const {
return _M_t.find(__x) == _M_t.end() ? 0 : 1;
}
iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); } iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); }
const_iterator lower_bound(const key_type& __x) const { const_iterator lower_bound(const key_type& __x) const {
return _M_t.lower_bound(__x); return _M_t.lower_bound(__x);
...@@ -198,19 +207,19 @@ public: ...@@ -198,19 +207,19 @@ public:
return _M_t.equal_range(__x); return _M_t.equal_range(__x);
} }
#ifdef __STL_MEMBER_TEMPLATES #ifdef __STL_TEMPLATE_FRIENDS
template <class _K1, class _T1, class _C1, class _A1> template <class _K1, class _T1, class _C1, class _A1>
friend bool operator== (const map<_K1, _T1, _C1, _A1>&, friend bool operator== (const map<_K1, _T1, _C1, _A1>&,
const map<_K1, _T1, _C1, _A1>&); const map<_K1, _T1, _C1, _A1>&);
template <class _K1, class _T1, class _C1, class _A1> template <class _K1, class _T1, class _C1, class _A1>
friend bool operator< (const map<_K1, _T1, _C1, _A1>&, friend bool operator< (const map<_K1, _T1, _C1, _A1>&,
const map<_K1, _T1, _C1, _A1>&); const map<_K1, _T1, _C1, _A1>&);
#else /* __STL_MEMBER_TEMPLATES */ #else /* __STL_TEMPLATE_FRIENDS */
friend bool __STD_QUALIFIER friend bool __STD_QUALIFIER
operator== __STL_NULL_TMPL_ARGS (const map&, const map&); operator== __STL_NULL_TMPL_ARGS (const map&, const map&);
friend bool __STD_QUALIFIER friend bool __STD_QUALIFIER
operator< __STL_NULL_TMPL_ARGS (const map&, const map&); operator< __STL_NULL_TMPL_ARGS (const map&, const map&);
#endif /* __STL_MEMBER_TEMPLATES */ #endif /* __STL_TEMPLATE_FRIENDS */
}; };
template <class _Key, class _Tp, class _Compare, class _Alloc> template <class _Key, class _Tp, class _Compare, class _Alloc>
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#ifndef __SGI_STL_INTERNAL_MULTIMAP_H #ifndef __SGI_STL_INTERNAL_MULTIMAP_H
#define __SGI_STL_INTERNAL_MULTIMAP_H #define __SGI_STL_INTERNAL_MULTIMAP_H
#include <bits/concept_checks.h>
__STL_BEGIN_NAMESPACE __STL_BEGIN_NAMESPACE
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
...@@ -55,6 +57,11 @@ inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, ...@@ -55,6 +57,11 @@ inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
template <class _Key, class _Tp, class _Compare, class _Alloc> template <class _Key, class _Tp, class _Compare, class _Alloc>
class multimap { class multimap {
// requirements:
__STL_CLASS_REQUIRES(_Tp, _Assignable);
__STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key);
public: public:
// typedefs: // typedefs:
...@@ -200,19 +207,19 @@ public: ...@@ -200,19 +207,19 @@ public:
return _M_t.equal_range(__x); return _M_t.equal_range(__x);
} }
#ifdef __STL_MEMBER_TEMPLATES #ifdef __STL_TEMPLATE_FRIENDS
template <class _K1, class _T1, class _C1, class _A1> template <class _K1, class _T1, class _C1, class _A1>
friend bool operator== (const multimap<_K1, _T1, _C1, _A1>&, friend bool operator== (const multimap<_K1, _T1, _C1, _A1>&,
const multimap<_K1, _T1, _C1, _A1>&); const multimap<_K1, _T1, _C1, _A1>&);
template <class _K1, class _T1, class _C1, class _A1> template <class _K1, class _T1, class _C1, class _A1>
friend bool operator< (const multimap<_K1, _T1, _C1, _A1>&, friend bool operator< (const multimap<_K1, _T1, _C1, _A1>&,
const multimap<_K1, _T1, _C1, _A1>&); const multimap<_K1, _T1, _C1, _A1>&);
#else /* __STL_MEMBER_TEMPLATES */ #else /* __STL_TEMPLATE_FRIENDS */
friend bool __STD_QUALIFIER friend bool __STD_QUALIFIER
operator== __STL_NULL_TMPL_ARGS (const multimap&, const multimap&); operator== __STL_NULL_TMPL_ARGS (const multimap&, const multimap&);
friend bool __STD_QUALIFIER friend bool __STD_QUALIFIER
operator< __STL_NULL_TMPL_ARGS (const multimap&, const multimap&); operator< __STL_NULL_TMPL_ARGS (const multimap&, const multimap&);
#endif /* __STL_MEMBER_TEMPLATES */ #endif /* __STL_TEMPLATE_FRIENDS */
}; };
template <class _Key, class _Tp, class _Compare, class _Alloc> template <class _Key, class _Tp, class _Compare, class _Alloc>
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#ifndef __SGI_STL_INTERNAL_MULTISET_H #ifndef __SGI_STL_INTERNAL_MULTISET_H
#define __SGI_STL_INTERNAL_MULTISET_H #define __SGI_STL_INTERNAL_MULTISET_H
#include <bits/concept_checks.h>
__STL_BEGIN_NAMESPACE __STL_BEGIN_NAMESPACE
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
...@@ -54,7 +56,13 @@ inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x, ...@@ -54,7 +56,13 @@ inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x,
template <class _Key, class _Compare, class _Alloc> template <class _Key, class _Compare, class _Alloc>
class multiset { class multiset {
// requirements:
__STL_CLASS_REQUIRES(_Key, _Assignable);
__STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key);
public: public:
// typedefs: // typedefs:
typedef _Key key_type; typedef _Key key_type;
...@@ -191,19 +199,19 @@ public: ...@@ -191,19 +199,19 @@ public:
return _M_t.equal_range(__x); return _M_t.equal_range(__x);
} }
#ifdef __STL_MEMBER_TEMPLATES #ifdef __STL_TEMPLATE_FRIENDS
template <class _K1, class _C1, class _A1> template <class _K1, class _C1, class _A1>
friend bool operator== (const multiset<_K1,_C1,_A1>&, friend bool operator== (const multiset<_K1,_C1,_A1>&,
const multiset<_K1,_C1,_A1>&); const multiset<_K1,_C1,_A1>&);
template <class _K1, class _C1, class _A1> template <class _K1, class _C1, class _A1>
friend bool operator< (const multiset<_K1,_C1,_A1>&, friend bool operator< (const multiset<_K1,_C1,_A1>&,
const multiset<_K1,_C1,_A1>&); const multiset<_K1,_C1,_A1>&);
#else /* __STL_MEMBER_TEMPLATES */ #else /* __STL_TEMPLATE_FRIENDS */
friend bool __STD_QUALIFIER friend bool __STD_QUALIFIER
operator== __STL_NULL_TMPL_ARGS (const multiset&, const multiset&); operator== __STL_NULL_TMPL_ARGS (const multiset&, const multiset&);
friend bool __STD_QUALIFIER friend bool __STD_QUALIFIER
operator< __STL_NULL_TMPL_ARGS (const multiset&, const multiset&); operator< __STL_NULL_TMPL_ARGS (const multiset&, const multiset&);
#endif /* __STL_MEMBER_TEMPLATES */ #endif /* __STL_TEMPLATE_FRIENDS */
}; };
template <class _Key, class _Compare, class _Alloc> template <class _Key, class _Compare, class _Alloc>
......
...@@ -37,6 +37,7 @@ __STL_BEGIN_NAMESPACE ...@@ -37,6 +37,7 @@ __STL_BEGIN_NAMESPACE
template <class _InputIterator, class _Tp> template <class _InputIterator, class _Tp>
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) _Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
{ {
__STL_REQUIRES(_InputIterator, _InputIterator);
for ( ; __first != __last; ++__first) for ( ; __first != __last; ++__first)
__init = __init + *__first; __init = __init + *__first;
return __init; return __init;
...@@ -46,6 +47,7 @@ template <class _InputIterator, class _Tp, class _BinaryOperation> ...@@ -46,6 +47,7 @@ template <class _InputIterator, class _Tp, class _BinaryOperation>
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
_BinaryOperation __binary_op) _BinaryOperation __binary_op)
{ {
__STL_REQUIRES(_InputIterator, _InputIterator);
for ( ; __first != __last; ++__first) for ( ; __first != __last; ++__first)
__init = __binary_op(__init, *__first); __init = __binary_op(__init, *__first);
return __init; return __init;
...@@ -55,6 +57,8 @@ template <class _InputIterator1, class _InputIterator2, class _Tp> ...@@ -55,6 +57,8 @@ template <class _InputIterator1, class _InputIterator2, class _Tp>
_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _Tp __init) _InputIterator2 __first2, _Tp __init)
{ {
__STL_REQUIRES(_InputIterator2, _InputIterator);
__STL_REQUIRES(_InputIterator2, _InputIterator);
for ( ; __first1 != __last1; ++__first1, ++__first2) for ( ; __first1 != __last1; ++__first1, ++__first2)
__init = __init + (*__first1 * *__first2); __init = __init + (*__first1 * *__first2);
return __init; return __init;
...@@ -67,6 +71,8 @@ _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, ...@@ -67,6 +71,8 @@ _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
_BinaryOperation1 __binary_op1, _BinaryOperation1 __binary_op1,
_BinaryOperation2 __binary_op2) _BinaryOperation2 __binary_op2)
{ {
__STL_REQUIRES(_InputIterator2, _InputIterator);
__STL_REQUIRES(_InputIterator2, _InputIterator);
for ( ; __first1 != __last1; ++__first1, ++__first2) for ( ; __first1 != __last1; ++__first1, ++__first2)
__init = __binary_op1(__init, __binary_op2(*__first1, *__first2)); __init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
return __init; return __init;
...@@ -90,6 +96,8 @@ _OutputIterator ...@@ -90,6 +96,8 @@ _OutputIterator
partial_sum(_InputIterator __first, _InputIterator __last, partial_sum(_InputIterator __first, _InputIterator __last,
_OutputIterator __result) _OutputIterator __result)
{ {
__STL_REQUIRES(_InputIterator, _InputIterator);
__STL_REQUIRES(_OutputIterator, _OutputIterator);
if (__first == __last) return __result; if (__first == __last) return __result;
*__result = *__first; *__result = *__first;
return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first)); return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first));
...@@ -114,6 +122,8 @@ _OutputIterator ...@@ -114,6 +122,8 @@ _OutputIterator
partial_sum(_InputIterator __first, _InputIterator __last, partial_sum(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOperation __binary_op) _OutputIterator __result, _BinaryOperation __binary_op)
{ {
__STL_REQUIRES(_InputIterator, _InputIterator);
__STL_REQUIRES(_OutputIterator, _OutputIterator);
if (__first == __last) return __result; if (__first == __last) return __result;
*__result = *__first; *__result = *__first;
return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first), return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first),
...@@ -139,6 +149,8 @@ _OutputIterator ...@@ -139,6 +149,8 @@ _OutputIterator
adjacent_difference(_InputIterator __first, adjacent_difference(_InputIterator __first,
_InputIterator __last, _OutputIterator __result) _InputIterator __last, _OutputIterator __result)
{ {
__STL_REQUIRES(_InputIterator, _InputIterator);
__STL_REQUIRES(_OutputIterator, _OutputIterator);
if (__first == __last) return __result; if (__first == __last) return __result;
*__result = *__first; *__result = *__first;
return __adjacent_difference(__first, __last, __result, return __adjacent_difference(__first, __last, __result,
...@@ -165,6 +177,8 @@ _OutputIterator ...@@ -165,6 +177,8 @@ _OutputIterator
adjacent_difference(_InputIterator __first, _InputIterator __last, adjacent_difference(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOperation __binary_op) _OutputIterator __result, _BinaryOperation __binary_op)
{ {
__STL_REQUIRES(_InputIterator, _InputIterator);
__STL_REQUIRES(_OutputIterator, _OutputIterator);
if (__first == __last) return __result; if (__first == __last) return __result;
*__result = *__first; *__result = *__first;
return __adjacent_difference(__first, __last, __result, return __adjacent_difference(__first, __last, __result,
...@@ -222,10 +236,12 @@ inline _Tp power(_Tp __x, _Integer __n) ...@@ -222,10 +236,12 @@ inline _Tp power(_Tp __x, _Integer __n)
// iota is not part of the C++ standard. It is an extension. // iota is not part of the C++ standard. It is an extension.
template <class _ForwardIterator, class _Tp> template <class _ForwardIter, class _Tp>
void void
iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value) iota(_ForwardIter __first, _ForwardIter __last, _Tp __value)
{ {
__STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator);
__STL_CONVERTIBLE(_Tp, typename iterator_traits<_ForwardIter>::value_type);
while (__first != __last) while (__first != __last)
*__first++ = __value++; *__first++ = __value++;
} }
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#ifndef __SGI_STL_INTERNAL_QUEUE_H #ifndef __SGI_STL_INTERNAL_QUEUE_H
#define __SGI_STL_INTERNAL_QUEUE_H #define __SGI_STL_INTERNAL_QUEUE_H
#include <bits/sequence_concepts.h>
__STL_BEGIN_NAMESPACE __STL_BEGIN_NAMESPACE
// Forward declarations of operators < and ==, needed for friend declaration. // Forward declarations of operators < and ==, needed for friend declaration.
...@@ -49,6 +51,15 @@ inline bool operator<(const queue<_Tp, _Seq>&, const queue<_Tp, _Seq>&); ...@@ -49,6 +51,15 @@ inline bool operator<(const queue<_Tp, _Seq>&, const queue<_Tp, _Seq>&);
template <class _Tp, class _Sequence> template <class _Tp, class _Sequence>
class queue { class queue {
// requirements:
__STL_CLASS_REQUIRES(_Tp, _Assignable);
__STL_CLASS_REQUIRES(_Sequence, _FrontInsertionSequence);
__STL_CLASS_REQUIRES(_Sequence, _BackInsertionSequence);
typedef typename _Sequence::value_type _Sequence_value_type;
__STL_CLASS_REQUIRES_SAME_TYPE(_Tp, _Sequence_value_type);
#ifdef __STL_MEMBER_TEMPLATES #ifdef __STL_MEMBER_TEMPLATES
template <class _Tp1, class _Seq1> template <class _Tp1, class _Seq1>
friend bool operator== (const queue<_Tp1, _Seq1>&, friend bool operator== (const queue<_Tp1, _Seq1>&,
...@@ -133,10 +144,20 @@ operator>=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) ...@@ -133,10 +144,20 @@ operator>=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y)
#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
template <class _Tp, template <class _Tp,
class _Sequence = vector<_Tp>, class _Sequence __STL_DEPENDENT_DEFAULT_TMPL(vector<_Tp>),
class _Compare = less<typename _Sequence::value_type> > class _Compare
__STL_DEPENDENT_DEFAULT_TMPL(less<typename _Sequence::value_type>) >
class priority_queue { class priority_queue {
public: public:
// requirements:
__STL_CLASS_REQUIRES(_Tp, _Assignable);
__STL_CLASS_REQUIRES(_Sequence, _Sequence);
__STL_CLASS_REQUIRES(_Sequence, _RandomAccessContainer);
typedef typename _Sequence::value_type _Sequence_value_type;
__STL_CLASS_REQUIRES_SAME_TYPE(_Tp, _Sequence_value_type);
__STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Tp, _Tp);
typedef typename _Sequence::value_type value_type; typedef typename _Sequence::value_type value_type;
typedef typename _Sequence::size_type size_type; typedef typename _Sequence::size_type size_type;
typedef _Sequence container_type; typedef _Sequence container_type;
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#ifndef __SGI_STL_INTERNAL_SET_H #ifndef __SGI_STL_INTERNAL_SET_H
#define __SGI_STL_INTERNAL_SET_H #define __SGI_STL_INTERNAL_SET_H
#include <bits/concept_checks.h>
__STL_BEGIN_NAMESPACE __STL_BEGIN_NAMESPACE
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
...@@ -55,6 +57,11 @@ inline bool operator<(const set<_Key,_Compare,_Alloc>& __x, ...@@ -55,6 +57,11 @@ inline bool operator<(const set<_Key,_Compare,_Alloc>& __x,
template <class _Key, class _Compare, class _Alloc> template <class _Key, class _Compare, class _Alloc>
class set { class set {
// requirements:
__STL_CLASS_REQUIRES(_Key, _Assignable);
__STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key);
public: public:
// typedefs: // typedefs:
...@@ -175,7 +182,9 @@ public: ...@@ -175,7 +182,9 @@ public:
// set operations: // set operations:
iterator find(const key_type& __x) const { return _M_t.find(__x); } iterator find(const key_type& __x) const { return _M_t.find(__x); }
size_type count(const key_type& __x) const { return _M_t.count(__x); } size_type count(const key_type& __x) const {
return _M_t.find(__x) == _M_t.end() ? 0 : 1;
}
iterator lower_bound(const key_type& __x) const { iterator lower_bound(const key_type& __x) const {
return _M_t.lower_bound(__x); return _M_t.lower_bound(__x);
} }
...@@ -186,17 +195,17 @@ public: ...@@ -186,17 +195,17 @@ public:
return _M_t.equal_range(__x); return _M_t.equal_range(__x);
} }
#ifdef __STL_MEMBER_TEMPLATES #ifdef __STL_TEMPLATE_FRIENDS
template <class _K1, class _C1, class _A1> template <class _K1, class _C1, class _A1>
friend bool operator== (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&); friend bool operator== (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&);
template <class _K1, class _C1, class _A1> template <class _K1, class _C1, class _A1>
friend bool operator< (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&); friend bool operator< (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&);
#else /* __STL_MEMBER_TEMPLATES */ #else /* __STL_TEMPLATE_FRIENDS */
friend bool __STD_QUALIFIER friend bool __STD_QUALIFIER
operator== __STL_NULL_TMPL_ARGS (const set&, const set&); operator== __STL_NULL_TMPL_ARGS (const set&, const set&);
friend bool __STD_QUALIFIER friend bool __STD_QUALIFIER
operator< __STL_NULL_TMPL_ARGS (const set&, const set&); operator< __STL_NULL_TMPL_ARGS (const set&, const set&);
#endif /* __STL_MEMBER_TEMPLATES */ #endif /* __STL_TEMPLATE_FRIENDS */
}; };
template <class _Key, class _Compare, class _Alloc> template <class _Key, class _Compare, class _Alloc>
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#ifndef __SGI_STL_INTERNAL_STACK_H #ifndef __SGI_STL_INTERNAL_STACK_H
#define __SGI_STL_INTERNAL_STACK_H #define __SGI_STL_INTERNAL_STACK_H
#include <bits/sequence_concepts.h>
__STL_BEGIN_NAMESPACE __STL_BEGIN_NAMESPACE
// Forward declarations of operators == and <, needed for friend declaration. // Forward declarations of operators == and <, needed for friend declaration.
...@@ -49,6 +51,14 @@ bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y); ...@@ -49,6 +51,14 @@ bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y);
template <class _Tp, class _Sequence> template <class _Tp, class _Sequence>
class stack { class stack {
// requirements:
__STL_CLASS_REQUIRES(_Tp, _Assignable);
__STL_CLASS_REQUIRES(_Sequence, _BackInsertionSequence);
typedef typename _Sequence::value_type _Sequence_value_type;
__STL_CLASS_REQUIRES_SAME_TYPE(_Tp, _Sequence_value_type);
#ifdef __STL_MEMBER_TEMPLATES #ifdef __STL_MEMBER_TEMPLATES
template <class _Tp1, class _Seq1> template <class _Tp1, class _Seq1>
friend bool operator== (const stack<_Tp1, _Seq1>&, friend bool operator== (const stack<_Tp1, _Seq1>&,
......
...@@ -15,12 +15,11 @@ ...@@ -15,12 +15,11 @@
#define __SGI_STL_STRING_FWD_H #define __SGI_STL_STRING_FWD_H
#include <bits/stl_config.h> #include <bits/stl_config.h>
//#include <bits/std_cstddef.h>
#include <bits/stl_alloc.h> #include <bits/stl_alloc.h>
#include <bits/char_traits.h>
__STL_BEGIN_NAMESPACE __STL_BEGIN_NAMESPACE
template <class _CharT> struct char_traits;
template <class _CharT, template <class _CharT,
class _Traits = char_traits<_CharT>, class _Traits = char_traits<_CharT>,
class _Alloc = allocator<_CharT> > class _Alloc = allocator<_CharT> >
......
...@@ -119,7 +119,7 @@ struct _Refcount_Base ...@@ -119,7 +119,7 @@ struct _Refcount_Base
// In some cases the operation is emulated with a lock. // In some cases the operation is emulated with a lock.
# ifdef __STL_SGI_THREADS # ifdef __STL_SGI_THREADS
inline unsigned long _Atomic_swap(unsigned long * __p, unsigned long __q) { inline unsigned long _Atomic_swap(unsigned long * __p, unsigned long __q) {
# if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) # if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64))
return test_and_set(__p, __q); return test_and_set(__p, __q);
# else # else
return __test_and_set(__p, (unsigned long)__q); return __test_and_set(__p, (unsigned long)__q);
...@@ -133,7 +133,7 @@ struct _Refcount_Base ...@@ -133,7 +133,7 @@ struct _Refcount_Base
// We use a template here only to get a unique initialized instance. // We use a template here only to get a unique initialized instance.
template<int __dummy> template<int __dummy>
struct _Swap_lock_struct { struct _Swap_lock_struct {
static pthread_mutex_t _S_swap_lock; static pthread_mutex_t _S_swap_lock;
}; };
template<int __dummy> template<int __dummy>
...@@ -154,7 +154,7 @@ struct _Refcount_Base ...@@ -154,7 +154,7 @@ struct _Refcount_Base
// We use a template here only to get a unique initialized instance. // We use a template here only to get a unique initialized instance.
template<int __dummy> template<int __dummy>
struct _Swap_lock_struct { struct _Swap_lock_struct {
static mutex_t _S_swap_lock; static mutex_t _S_swap_lock;
}; };
template<int __dummy> template<int __dummy>
...@@ -176,7 +176,7 @@ struct _Refcount_Base ...@@ -176,7 +176,7 @@ struct _Refcount_Base
// We use a template here only to get a unique initialized instance. // We use a template here only to get a unique initialized instance.
template<int __dummy> template<int __dummy>
struct _Swap_lock_struct { struct _Swap_lock_struct {
static mutex_t _S_swap_lock; static mutex_t _S_swap_lock;
}; };
# if ( __STL_STATIC_TEMPLATE_DATA > 0 ) # if ( __STL_STATIC_TEMPLATE_DATA > 0 )
...@@ -185,7 +185,7 @@ struct _Refcount_Base ...@@ -185,7 +185,7 @@ struct _Refcount_Base
_Swap_lock_struct<__dummy>::_S_swap_lock = DEFAULTMUTEX; _Swap_lock_struct<__dummy>::_S_swap_lock = DEFAULTMUTEX;
# else # else
__DECLARE_INSTANCE(mutex_t, _Swap_lock_struct<__dummy>::_S_swap_lock, __DECLARE_INSTANCE(mutex_t, _Swap_lock_struct<__dummy>::_S_swap_lock,
=DEFAULTMUTEX); =DEFAULTMUTEX);
# endif /* ( __STL_STATIC_TEMPLATE_DATA > 0 ) */ # endif /* ( __STL_STATIC_TEMPLATE_DATA > 0 ) */
// This should be portable, but performance is expected // This should be portable, but performance is expected
...@@ -218,6 +218,23 @@ struct _Refcount_Base ...@@ -218,6 +218,23 @@ struct _Refcount_Base
// constructors, no base classes, no virtual functions, and no private or // constructors, no base classes, no virtual functions, and no private or
// protected members. // protected members.
// Helper struct. This is a workaround for various compilers that don't
// handle static variables in inline functions properly.
template <int __inst>
struct _STL_mutex_spin {
enum { __low_max = 30, __high_max = 1000 };
// Low if we suspect uniprocessor, high for multiprocessor.
static unsigned __max;
static unsigned __last;
};
template <int __inst>
unsigned _STL_mutex_spin<__inst>::__max = _STL_mutex_spin<__inst>::__low_max;
template <int __inst>
unsigned _STL_mutex_spin<__inst>::__last = 0;
struct _STL_mutex_lock struct _STL_mutex_lock
{ {
#if defined(__STL_SGI_THREADS) || defined(__STL_WIN32THREADS) #if defined(__STL_SGI_THREADS) || defined(__STL_WIN32THREADS)
...@@ -232,32 +249,25 @@ struct _STL_mutex_lock ...@@ -232,32 +249,25 @@ struct _STL_mutex_lock
__ts.tv_nsec = 1 << __log_nsec; __ts.tv_nsec = 1 << __log_nsec;
nanosleep(&__ts, 0); nanosleep(&__ts, 0);
# elif defined(__STL_WIN32THREADS) # elif defined(__STL_WIN32THREADS)
if (__log_nsec <= 20) { if (__log_nsec <= 20) {
Sleep(0); Sleep(0);
} else { } else {
Sleep(1 << (__log_nsec - 20)); Sleep(1 << (__log_nsec - 20));
} }
# else # else
# error unimplemented # error unimplemented
# endif # endif
} }
void _M_acquire_lock() { void _M_acquire_lock() {
const unsigned __low_spin_max = 30; // spins if we suspect uniprocessor
const unsigned __high_spin_max = 1000; // spins for multiprocessor
static unsigned __spin_max = __low_spin_max;
unsigned __my_spin_max;
static unsigned __last_spins = 0;
unsigned __my_last_spins;
volatile unsigned __junk;
int __i;
volatile unsigned long* __lock = &this->_M_lock; volatile unsigned long* __lock = &this->_M_lock;
if (!_Atomic_swap((unsigned long*)__lock, 1)) { if (!_Atomic_swap((unsigned long*)__lock, 1)) {
return; return;
} }
__my_spin_max = __spin_max; unsigned __my_spin_max = _STL_mutex_spin<0>::__max;
__my_last_spins = __last_spins; unsigned __my_last_spins = _STL_mutex_spin<0>::__last;
__junk = 17; // Value doesn't matter. volatile unsigned __junk = 17; // Value doesn't matter.
unsigned __i;
for (__i = 0; __i < __my_spin_max; __i++) { for (__i = 0; __i < __my_spin_max; __i++) {
if (__i < __my_last_spins/2 || *__lock) { if (__i < __my_last_spins/2 || *__lock) {
__junk *= __junk; __junk *= __junk; __junk *= __junk; __junk *= __junk;
...@@ -269,13 +279,13 @@ struct _STL_mutex_lock ...@@ -269,13 +279,13 @@ struct _STL_mutex_lock
// Spinning worked. Thus we're probably not being scheduled // Spinning worked. Thus we're probably not being scheduled
// against the other process with which we were contending. // against the other process with which we were contending.
// Thus it makes sense to spin longer the next time. // Thus it makes sense to spin longer the next time.
__last_spins = __i; _STL_mutex_spin<0>::__last = __i;
__spin_max = __high_spin_max; _STL_mutex_spin<0>::__max = _STL_mutex_spin<0>::__high_max;
return; return;
} }
} }
// We are probably being scheduled against the other process. Sleep. // We are probably being scheduled against the other process. Sleep.
__spin_max = __low_spin_max; _STL_mutex_spin<0>::__max = _STL_mutex_spin<0>::__low_max;
for (__i = 0 ;; ++__i) { for (__i = 0 ;; ++__i) {
int __log_nsec = __i + 6; int __log_nsec = __i + 6;
...@@ -292,7 +302,7 @@ struct _STL_mutex_lock ...@@ -292,7 +302,7 @@ struct _STL_mutex_lock
asm("sync"); asm("sync");
*__lock = 0; *__lock = 0;
# elif defined(__STL_SGI_THREADS) && __mips >= 3 \ # elif defined(__STL_SGI_THREADS) && __mips >= 3 \
&& (defined (_ABIN32) || defined(_ABI64)) && (defined (_ABIN32) || defined(_ABI64))
__lock_release(__lock); __lock_release(__lock);
# else # else
*__lock = 0; *__lock = 0;
......
...@@ -970,7 +970,7 @@ _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc> ...@@ -970,7 +970,7 @@ _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>
{ {
if (__position._M_node == _M_header->_M_left) { // begin() if (__position._M_node == _M_header->_M_left) { // begin()
if (size() > 0 && if (size() > 0 &&
! _M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__v))) !_M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__v)))
return _M_insert(__position._M_node, __position._M_node, __v); return _M_insert(__position._M_node, __position._M_node, __v);
// first argument just needs to be non-null // first argument just needs to be non-null
else else
......
...@@ -57,10 +57,10 @@ __uninitialized_copy_aux(_InputIter __first, _InputIter __last, ...@@ -57,10 +57,10 @@ __uninitialized_copy_aux(_InputIter __first, _InputIter __last,
_ForwardIter __cur = __result; _ForwardIter __cur = __result;
__STL_TRY { __STL_TRY {
for ( ; __first != __last; ++__first, ++__cur) for ( ; __first != __last; ++__first, ++__cur)
construct(&*__cur, *__first); _Construct(&*__cur, *__first);
return __cur; return __cur;
} }
__STL_UNWIND(destroy(__result, __cur)); __STL_UNWIND(_Destroy(__result, __cur));
} }
...@@ -107,10 +107,10 @@ __uninitialized_copy_n(_InputIter __first, _Size __count, ...@@ -107,10 +107,10 @@ __uninitialized_copy_n(_InputIter __first, _Size __count,
_ForwardIter __cur = __result; _ForwardIter __cur = __result;
__STL_TRY { __STL_TRY {
for ( ; __count > 0 ; --__count, ++__first, ++__cur) for ( ; __count > 0 ; --__count, ++__first, ++__cur)
construct(&*__cur, *__first); _Construct(&*__cur, *__first);
return pair<_InputIter, _ForwardIter>(__first, __cur); return pair<_InputIter, _ForwardIter>(__first, __cur);
} }
__STL_UNWIND(destroy(__result, __cur)); __STL_UNWIND(_Destroy(__result, __cur));
} }
template <class _RandomAccessIter, class _Size, class _ForwardIter> template <class _RandomAccessIter, class _Size, class _ForwardIter>
...@@ -158,9 +158,9 @@ __uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last, ...@@ -158,9 +158,9 @@ __uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last,
_ForwardIter __cur = __first; _ForwardIter __cur = __first;
__STL_TRY { __STL_TRY {
for ( ; __cur != __last; ++__cur) for ( ; __cur != __last; ++__cur)
construct(&*__cur, __x); _Construct(&*__cur, __x);
} }
__STL_UNWIND(destroy(__first, __cur)); __STL_UNWIND(_Destroy(__first, __cur));
} }
template <class _ForwardIter, class _Tp, class _Tp1> template <class _ForwardIter, class _Tp, class _Tp1>
...@@ -198,10 +198,10 @@ __uninitialized_fill_n_aux(_ForwardIter __first, _Size __n, ...@@ -198,10 +198,10 @@ __uninitialized_fill_n_aux(_ForwardIter __first, _Size __n,
_ForwardIter __cur = __first; _ForwardIter __cur = __first;
__STL_TRY { __STL_TRY {
for ( ; __n > 0; --__n, ++__cur) for ( ; __n > 0; --__n, ++__cur)
construct(&*__cur, __x); _Construct(&*__cur, __x);
return __cur; return __cur;
} }
__STL_UNWIND(destroy(__first, __cur)); __STL_UNWIND(_Destroy(__first, __cur));
} }
template <class _ForwardIter, class _Size, class _Tp, class _Tp1> template <class _ForwardIter, class _Size, class _Tp, class _Tp1>
...@@ -237,7 +237,7 @@ __uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1, ...@@ -237,7 +237,7 @@ __uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1,
__STL_TRY { __STL_TRY {
return uninitialized_copy(__first2, __last2, __mid); return uninitialized_copy(__first2, __last2, __mid);
} }
__STL_UNWIND(destroy(__result, __mid)); __STL_UNWIND(_Destroy(__result, __mid));
} }
// __uninitialized_fill_copy // __uninitialized_fill_copy
...@@ -253,7 +253,7 @@ __uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid, ...@@ -253,7 +253,7 @@ __uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid,
__STL_TRY { __STL_TRY {
return uninitialized_copy(__first, __last, __mid); return uninitialized_copy(__first, __last, __mid);
} }
__STL_UNWIND(destroy(__result, __mid)); __STL_UNWIND(_Destroy(__result, __mid));
} }
// __uninitialized_copy_fill // __uninitialized_copy_fill
...@@ -269,7 +269,7 @@ __uninitialized_copy_fill(_InputIter __first1, _InputIter __last1, ...@@ -269,7 +269,7 @@ __uninitialized_copy_fill(_InputIter __first1, _InputIter __last1,
__STL_TRY { __STL_TRY {
uninitialized_fill(__mid2, __last2, __x); uninitialized_fill(__mid2, __last2, __x);
} }
__STL_UNWIND(destroy(__first2, __mid2)); __STL_UNWIND(_Destroy(__first2, __mid2));
} }
__STL_END_NAMESPACE __STL_END_NAMESPACE
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include <bits/exception_support.h> #include <bits/exception_support.h>
#include <bits/concept_checks.h>
__STL_BEGIN_NAMESPACE __STL_BEGIN_NAMESPACE
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
...@@ -154,6 +156,10 @@ protected: ...@@ -154,6 +156,10 @@ protected:
template <class _Tp, class _Alloc = allocator<_Tp> > template <class _Tp, class _Alloc = allocator<_Tp> >
class vector : protected _Vector_base<_Tp, _Alloc> class vector : protected _Vector_base<_Tp, _Alloc>
{ {
// requirements:
__STL_CLASS_REQUIRES(_Tp, _Assignable);
private: private:
typedef _Vector_base<_Tp, _Alloc> _Base; typedef _Vector_base<_Tp, _Alloc> _Base;
typedef vector<_Tp, _Alloc> vector_type; typedef vector<_Tp, _Alloc> vector_type;
......
...@@ -165,6 +165,7 @@ public: ...@@ -165,6 +165,7 @@ public:
operator== __STL_NULL_TMPL_ARGS (const hash_map&, const hash_map&); operator== __STL_NULL_TMPL_ARGS (const hash_map&, const hash_map&);
#endif /* __STL_MEMBER_TEMPLATES */ #endif /* __STL_MEMBER_TEMPLATES */
#include <bits/concept_checks.h>
iterator begin() { return _M_ht.begin(); } iterator begin() { return _M_ht.begin(); }
iterator end() { return _M_ht.end(); } iterator end() { return _M_ht.end(); }
...@@ -260,6 +261,20 @@ template <class _Key, class _Tp, class _HashFcn, class _EqualKey, ...@@ -260,6 +261,20 @@ template <class _Key, class _Tp, class _HashFcn, class _EqualKey,
class _Alloc> class _Alloc>
class hash_multimap class hash_multimap
{ {
// requirements:
__STL_CLASS_REQUIRES(_Key, _Assignable);
__STL_CLASS_REQUIRES(_Tp, _Assignable);
__STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Key);
__STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Key, _Key);
// requirements:
__STL_CLASS_REQUIRES(_Key, _Assignable);
__STL_CLASS_REQUIRES(_Tp, _Assignable);
__STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Key);
__STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Key, _Key);
private: private:
typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFcn, typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFcn,
_Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc> _Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc>
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include <ext/stl_hashtable.h> #include <ext/stl_hashtable.h>
#include <bits/concept_checks.h>
__STL_BEGIN_NAMESPACE __STL_BEGIN_NAMESPACE
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
...@@ -56,6 +58,12 @@ operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1, ...@@ -56,6 +58,12 @@ operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1,
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
class hash_set class hash_set
{ {
// requirements:
__STL_CLASS_REQUIRES(_Value, _Assignable);
__STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Value);
__STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Value, _Value);
private: private:
typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
_EqualKey, _Alloc> _Ht; _EqualKey, _Alloc> _Ht;
...@@ -254,6 +262,12 @@ operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, ...@@ -254,6 +262,12 @@ operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
class hash_multiset class hash_multiset
{ {
// requirements:
__STL_CLASS_REQUIRES(_Value, _Assignable);
__STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Value);
__STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Value, _Value);
private: private:
typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
_EqualKey, _Alloc> _Ht; _EqualKey, _Alloc> _Ht;
......
...@@ -1525,35 +1525,36 @@ const _CharT* rope<_CharT,_Alloc>::replace_with_c_str() { ...@@ -1525,35 +1525,36 @@ const _CharT* rope<_CharT,_Alloc>::replace_with_c_str() {
// Algorithm specializations. More should be added. // Algorithm specializations. More should be added.
#ifndef _MSC_VER template<class _Rope_iterator> // was templated on CharT and Alloc
// I couldn't get this to work with VC++ void // VC++ workaround
template<class _CharT,class _Alloc> _Rope_rotate(_Rope_iterator __first,
void _Rope_iterator __middle,
_Rope_rotate(_Rope_iterator<_CharT,_Alloc> __first, _Rope_iterator __last)
_Rope_iterator<_CharT,_Alloc> __middle,
_Rope_iterator<_CharT,_Alloc> __last)
{ {
__stl_assert(__first.container() == __middle.container() typedef typename _Rope_iterator::value_type _CharT;
&& __middle.container() == __last.container()); typedef typename _Rope_iterator::_allocator_type _Alloc;
rope<_CharT,_Alloc>& __r(__first.container());
rope<_CharT,_Alloc> __prefix = __r.substr(0, __first.index()); __stl_assert(__first.container() == __middle.container()
rope<_CharT,_Alloc> __suffix = && __middle.container() == __last.container());
__r.substr(__last.index(), __r.size() - __last.index()); rope<_CharT,_Alloc>& __r(__first.container());
rope<_CharT,_Alloc> __part1 = rope<_CharT,_Alloc> __prefix = __r.substr(0, __first.index());
__r.substr(__middle.index(), __last.index() - __middle.index()); rope<_CharT,_Alloc> __suffix =
rope<_CharT,_Alloc> __part2 = __r.substr(__last.index(), __r.size() - __last.index());
__r.substr(__first.index(), __middle.index() - __first.index()); rope<_CharT,_Alloc> __part1 =
__r = __prefix; __r.substr(__middle.index(), __last.index() - __middle.index());
__r += __part1; rope<_CharT,_Alloc> __part2 =
__r += __part2; __r.substr(__first.index(), __middle.index() - __first.index());
__r += __suffix; __r = __prefix;
__r += __part1;
__r += __part2;
__r += __suffix;
} }
#if !defined(__GNUC__) #if !defined(__GNUC__)
// Appears to confuse g++ // Appears to confuse g++
inline void rotate(_Rope_iterator<char,allocator<char> > __first, inline void rotate(_Rope_iterator<char,__STL_DEFAULT_ALLOCATOR(char)> __first,
_Rope_iterator<char,allocator<char> > __middle, _Rope_iterator<char,__STL_DEFAULT_ALLOCATOR(char)> __middle,
_Rope_iterator<char,allocator<char> > __last) { _Rope_iterator<char,__STL_DEFAULT_ALLOCATOR(char)> __last) {
_Rope_rotate(__first, __middle, __last); _Rope_rotate(__first, __middle, __last);
} }
#endif #endif
...@@ -1567,13 +1568,13 @@ inline void rotate(_Rope_iterator<char,allocator<char> > __first, ...@@ -1567,13 +1568,13 @@ inline void rotate(_Rope_iterator<char,allocator<char> > __first,
// for unicode strings. Unsigned short may be a better character // for unicode strings. Unsigned short may be a better character
// type. // type.
inline void rotate( inline void rotate(
_Rope_iterator<wchar_t, allocator<char> > __first, _Rope_iterator<wchar_t,__STL_DEFAULT_ALLOCATOR(char)> __first,
_Rope_iterator<wchar_t, allocator<char> > __middle, _Rope_iterator<wchar_t,__STL_DEFAULT_ALLOCATOR(char)> __middle,
_Rope_iterator<wchar_t, allocator<char> > __last) { _Rope_iterator<wchar_t,__STL_DEFAULT_ALLOCATOR(char)> __last) {
_Rope_rotate(__first, __middle, __last); _Rope_rotate(__first, __middle, __last);
} }
# endif # endif
#endif /* _MSC_VER */
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
#pragma reset woff 1174 #pragma reset woff 1174
......
...@@ -140,7 +140,8 @@ headers = \ ...@@ -140,7 +140,8 @@ headers = \
bits/stl_stack.h bits/stl_string_fwd.h bits/stl_tempbuf.h \ bits/stl_stack.h bits/stl_string_fwd.h bits/stl_tempbuf.h \
bits/stl_tree.h bits/stl_uninitialized.h bits/stl_vector.h \ bits/stl_tree.h bits/stl_uninitialized.h bits/stl_vector.h \
bits/type_traits.h bits/stl_range_errors.h bits/std_algorithm.h \ bits/type_traits.h bits/stl_range_errors.h bits/std_algorithm.h \
bits/std_strstream.h \ bits/concept_checks.h bits/container_concepts.h \
bits/sequence_concepts.h bits/std_strstream.h \
ext/ropeimpl.h ext/stl_rope.h \ ext/ropeimpl.h ext/stl_rope.h \
ext/stl_bvector.h bits/stl_config.h bits/stl_construct.h \ ext/stl_bvector.h bits/stl_config.h bits/stl_construct.h \
ext/stl_hashtable.h ext/stl_hash_fun.h \ ext/stl_hashtable.h ext/stl_hash_fun.h \
......
...@@ -220,7 +220,8 @@ headers = \ ...@@ -220,7 +220,8 @@ headers = \
bits/stl_stack.h bits/stl_string_fwd.h bits/stl_tempbuf.h \ bits/stl_stack.h bits/stl_string_fwd.h bits/stl_tempbuf.h \
bits/stl_tree.h bits/stl_uninitialized.h bits/stl_vector.h \ bits/stl_tree.h bits/stl_uninitialized.h bits/stl_vector.h \
bits/type_traits.h bits/stl_range_errors.h bits/std_algorithm.h \ bits/type_traits.h bits/stl_range_errors.h bits/std_algorithm.h \
bits/std_strstream.h \ bits/concept_checks.h bits/container_concepts.h \
bits/sequence_concepts.h bits/std_strstream.h \
ext/ropeimpl.h ext/stl_rope.h \ ext/ropeimpl.h ext/stl_rope.h \
ext/stl_bvector.h bits/stl_config.h bits/stl_construct.h \ ext/stl_bvector.h bits/stl_config.h bits/stl_construct.h \
ext/stl_hashtable.h ext/stl_hash_fun.h \ ext/stl_hashtable.h ext/stl_hash_fun.h \
......
...@@ -49,4 +49,8 @@ namespace std { ...@@ -49,4 +49,8 @@ namespace std {
vector<unsigned int>:: vector<unsigned int>::
_M_insert_aux(vector<unsigned int>::iterator, unsigned int const &); _M_insert_aux(vector<unsigned int>::iterator, unsigned int const &);
template
void
__sink_unused_warning<size_t>(size_t);
} //std } //std
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