first commit
This commit is contained in:
77
extern/STLport/5.2.1/stlport/stl/_abbrevs.h
vendored
Normal file
77
extern/STLport/5.2.1/stlport/stl/_abbrevs.h
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_ABBREVS_H
|
||||
# define _STLP_INTERNAL_ABBREVS_H
|
||||
|
||||
// ugliness is intentional - to reduce conflicts
|
||||
# define input_iterator_tag _In__ItT
|
||||
# define output_iterator_tag _Ou__ItT
|
||||
# define bidirectional_iterator_tag _Bd__ItT
|
||||
# define random_access_iterator_tag _Ra__ItT
|
||||
# define input_iterator _In__It
|
||||
# define output_iterator _Ou__It
|
||||
# define bidirectional_iterator _Bd__It
|
||||
# define random_access_iterator _Ra__It
|
||||
# define reverse_bidirectional_iterator _rBd__It
|
||||
# define reverse_iterator _r__It
|
||||
# define back_insert_iterator _bI__It
|
||||
# define front_insert_iterator _fI__It
|
||||
# define raw_storage_iterator _rS__It
|
||||
# define _Const_traits _C_Tr
|
||||
# define _Const_Const_traits _CC_Tr
|
||||
# define _Nonconst_traits _N_Tr
|
||||
# define _Nonconst_Const_traits _NC_Tr
|
||||
|
||||
// ugliness is intentional - to reduce conflicts probability
|
||||
# define __malloc_alloc M__A
|
||||
# define __node_alloc D__A
|
||||
# define __new_alloc N__A
|
||||
# define __debug_alloc G__A
|
||||
# define _STLP_alloc_proxy P__A
|
||||
|
||||
# define _Deque_iterator_base _Dq__ItB
|
||||
# define _Deque_iterator _Dq__It
|
||||
|
||||
# define _Select1st _S1st
|
||||
# define _Select2nd _S2nd
|
||||
# define __move_source __m_s
|
||||
# define _Vector_nonconst_traits _V_nct
|
||||
|
||||
# define _Ht_iterator _Ht_It
|
||||
|
||||
# define _List_node_base _L__NB
|
||||
# define _List_iterator_base _L__ItB
|
||||
# define _List_iterator _L__It
|
||||
|
||||
# define _Slist_iterator_base _SL__ItB
|
||||
# define _Slist_iterator _SL__It
|
||||
|
||||
# define _Rb_tree_node_base _rbT__NB
|
||||
# define _Rb_tree_node _rbT__N
|
||||
# define _Rb_tree_base_iterator _rbT__It
|
||||
# define _Rb_tree_base _rbT__B
|
||||
|
||||
# if defined (__DMC__) && defined (_STLP_DEBUG)
|
||||
# define _NonDbg_hashtable _Nd_Ht
|
||||
# define _DBG_iter _d__It
|
||||
# endif
|
||||
#endif
|
||||
|
||||
2028
extern/STLport/5.2.1/stlport/stl/_algo.c
vendored
Normal file
2028
extern/STLport/5.2.1/stlport/stl/_algo.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
745
extern/STLport/5.2.1/stlport/stl/_algo.h
vendored
Normal file
745
extern/STLport/5.2.1/stlport/stl/_algo.h
vendored
Normal file
@@ -0,0 +1,745 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALGO_H
|
||||
#define _STLP_INTERNAL_ALGO_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALGOBASE_H
|
||||
# include <stl/_algobase.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_HEAP_H
|
||||
# include <stl/_heap.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_H
|
||||
# include <stl/_iterator.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
|
||||
# include <stl/_function_base.h>
|
||||
#endif
|
||||
|
||||
#if defined (__SUNPRO_CC) && !defined (_STLP_INTERNAL_CSTDIO)
|
||||
// remove() conflict
|
||||
# include <stl/_cstdio.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
// for_each. Apply a function to every element of a range.
|
||||
template <class _InputIter, class _Function>
|
||||
_STLP_INLINE_LOOP _Function
|
||||
for_each(_InputIter __first, _InputIter __last, _Function __f) {
|
||||
for ( ; __first != __last; ++__first)
|
||||
__f(*__first);
|
||||
return __f;
|
||||
}
|
||||
|
||||
// count_if
|
||||
template <class _InputIter, class _Predicate>
|
||||
_STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_InputIter)
|
||||
count_if(_InputIter __first, _InputIter __last, _Predicate __pred) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_STLP_DIFFERENCE_TYPE(_InputIter) __n = 0;
|
||||
for ( ; __first != __last; ++__first) {
|
||||
if (__pred(*__first))
|
||||
++__n;
|
||||
}
|
||||
return __n;
|
||||
}
|
||||
|
||||
// adjacent_find.
|
||||
|
||||
template <class _ForwardIter, class _BinaryPredicate>
|
||||
_STLP_INLINE_LOOP _ForwardIter
|
||||
adjacent_find(_ForwardIter __first, _ForwardIter __last,
|
||||
_BinaryPredicate __binary_pred) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
if (__first == __last)
|
||||
return __last;
|
||||
_ForwardIter __next = __first;
|
||||
while(++__next != __last) {
|
||||
if (__binary_pred(*__first, *__next))
|
||||
return __first;
|
||||
__first = __next;
|
||||
}
|
||||
return __last;
|
||||
}
|
||||
|
||||
template <class _ForwardIter>
|
||||
_STLP_INLINE_LOOP _ForwardIter
|
||||
adjacent_find(_ForwardIter __first, _ForwardIter __last) {
|
||||
return adjacent_find(__first, __last,
|
||||
_STLP_PRIV __equal_to(_STLP_VALUE_TYPE(__first, _ForwardIter)));
|
||||
}
|
||||
|
||||
#if !defined (_STLP_NO_ANACHRONISMS)
|
||||
template <class _InputIter, class _Tp, class _Size>
|
||||
_STLP_INLINE_LOOP void
|
||||
count(_InputIter __first, _InputIter __last, const _Tp& __val, _Size& __n) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
for ( ; __first != __last; ++__first)
|
||||
if (*__first == __val)
|
||||
++__n;
|
||||
}
|
||||
|
||||
template <class _InputIter, class _Predicate, class _Size>
|
||||
_STLP_INLINE_LOOP void
|
||||
count_if(_InputIter __first, _InputIter __last, _Predicate __pred, _Size& __n) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
for ( ; __first != __last; ++__first)
|
||||
if (__pred(*__first))
|
||||
++__n;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _ForwardIter1, class _ForwardIter2>
|
||||
_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1,
|
||||
_ForwardIter2 __first2, _ForwardIter2 __last2);
|
||||
|
||||
// search_n. Search for __count consecutive copies of __val.
|
||||
template <class _ForwardIter, class _Integer, class _Tp>
|
||||
_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last,
|
||||
_Integer __count, const _Tp& __val);
|
||||
template <class _ForwardIter, class _Integer, class _Tp, class _BinaryPred>
|
||||
_ForwardIter search_n(_ForwardIter __first, _ForwardIter __last,
|
||||
_Integer __count, const _Tp& __val, _BinaryPred __binary_pred);
|
||||
|
||||
template <class _InputIter, class _ForwardIter>
|
||||
inline _InputIter find_first_of(_InputIter __first1, _InputIter __last1,
|
||||
_ForwardIter __first2, _ForwardIter __last2) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
|
||||
return _STLP_PRIV __find_first_of(__first1, __last1, __first2, __last2);
|
||||
}
|
||||
|
||||
template <class _InputIter, class _ForwardIter, class _BinaryPredicate>
|
||||
inline _InputIter
|
||||
find_first_of(_InputIter __first1, _InputIter __last1,
|
||||
_ForwardIter __first2, _ForwardIter __last2, _BinaryPredicate __comp) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
|
||||
return _STLP_PRIV __find_first_of(__first1, __last1, __first2, __last2, __comp);
|
||||
}
|
||||
|
||||
template <class _ForwardIter1, class _ForwardIter2>
|
||||
_ForwardIter1
|
||||
find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,
|
||||
_ForwardIter2 __first2, _ForwardIter2 __last2);
|
||||
|
||||
// swap_ranges
|
||||
template <class _ForwardIter1, class _ForwardIter2>
|
||||
_STLP_INLINE_LOOP _ForwardIter2
|
||||
swap_ranges(_ForwardIter1 __first1, _ForwardIter1 __last1, _ForwardIter2 __first2) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
for ( ; __first1 != __last1; ++__first1, ++__first2)
|
||||
iter_swap(__first1, __first2);
|
||||
return __first2;
|
||||
}
|
||||
|
||||
// transform
|
||||
template <class _InputIter, class _OutputIter, class _UnaryOperation>
|
||||
_STLP_INLINE_LOOP _OutputIter
|
||||
transform(_InputIter __first, _InputIter __last, _OutputIter __result, _UnaryOperation __opr) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
for ( ; __first != __last; ++__first, ++__result)
|
||||
*__result = __opr(*__first);
|
||||
return __result;
|
||||
}
|
||||
template <class _InputIter1, class _InputIter2, class _OutputIter, class _BinaryOperation>
|
||||
_STLP_INLINE_LOOP _OutputIter
|
||||
transform(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _OutputIter __result,_BinaryOperation __binary_op) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
for ( ; __first1 != __last1; ++__first1, ++__first2, ++__result)
|
||||
*__result = __binary_op(*__first1, *__first2);
|
||||
return __result;
|
||||
}
|
||||
|
||||
// replace_if, replace_copy, replace_copy_if
|
||||
|
||||
template <class _ForwardIter, class _Predicate, class _Tp>
|
||||
_STLP_INLINE_LOOP void
|
||||
replace_if(_ForwardIter __first, _ForwardIter __last, _Predicate __pred, const _Tp& __new_value) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
for ( ; __first != __last; ++__first)
|
||||
if (__pred(*__first))
|
||||
*__first = __new_value;
|
||||
}
|
||||
|
||||
template <class _InputIter, class _OutputIter, class _Tp>
|
||||
_STLP_INLINE_LOOP _OutputIter
|
||||
replace_copy(_InputIter __first, _InputIter __last,_OutputIter __result,
|
||||
const _Tp& __old_value, const _Tp& __new_value) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
for ( ; __first != __last; ++__first, ++__result)
|
||||
*__result = *__first == __old_value ? __new_value : *__first;
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _Iterator, class _OutputIter, class _Predicate, class _Tp>
|
||||
_STLP_INLINE_LOOP _OutputIter
|
||||
replace_copy_if(_Iterator __first, _Iterator __last,
|
||||
_OutputIter __result,
|
||||
_Predicate __pred, const _Tp& __new_value) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
for ( ; __first != __last; ++__first, ++__result)
|
||||
*__result = __pred(*__first) ? __new_value : *__first;
|
||||
return __result;
|
||||
}
|
||||
|
||||
// generate and generate_n
|
||||
|
||||
template <class _ForwardIter, class _Generator>
|
||||
_STLP_INLINE_LOOP void
|
||||
generate(_ForwardIter __first, _ForwardIter __last, _Generator __gen) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
for ( ; __first != __last; ++__first)
|
||||
*__first = __gen();
|
||||
}
|
||||
|
||||
template <class _OutputIter, class _Size, class _Generator>
|
||||
_STLP_INLINE_LOOP void
|
||||
generate_n(_OutputIter __first, _Size __n, _Generator __gen) {
|
||||
for ( ; __n > 0; --__n, ++__first)
|
||||
*__first = __gen();
|
||||
}
|
||||
|
||||
// remove, remove_if, remove_copy, remove_copy_if
|
||||
|
||||
template <class _InputIter, class _OutputIter, class _Tp>
|
||||
_STLP_INLINE_LOOP _OutputIter
|
||||
remove_copy(_InputIter __first, _InputIter __last,_OutputIter __result, const _Tp& __val) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
for ( ; __first != __last; ++__first) {
|
||||
if (!(*__first == __val)) {
|
||||
*__result = *__first;
|
||||
++__result;
|
||||
}
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _InputIter, class _OutputIter, class _Predicate>
|
||||
_STLP_INLINE_LOOP _OutputIter
|
||||
remove_copy_if(_InputIter __first, _InputIter __last, _OutputIter __result, _Predicate __pred) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
for ( ; __first != __last; ++__first) {
|
||||
if (!__pred(*__first)) {
|
||||
*__result = *__first;
|
||||
++__result;
|
||||
}
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _Tp>
|
||||
_STLP_INLINE_LOOP _ForwardIter
|
||||
remove(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
__first = find(__first, __last, __val);
|
||||
if (__first == __last)
|
||||
return __first;
|
||||
else {
|
||||
_ForwardIter __next = __first;
|
||||
return remove_copy(++__next, __last, __first, __val);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _Predicate>
|
||||
_STLP_INLINE_LOOP _ForwardIter
|
||||
remove_if(_ForwardIter __first, _ForwardIter __last, _Predicate __pred) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
__first = find_if(__first, __last, __pred);
|
||||
if ( __first == __last )
|
||||
return __first;
|
||||
else {
|
||||
_ForwardIter __next = __first;
|
||||
return remove_copy_if(++__next, __last, __first, __pred);
|
||||
}
|
||||
}
|
||||
|
||||
// unique and unique_copy
|
||||
template <class _InputIter, class _OutputIter>
|
||||
_OutputIter unique_copy(_InputIter __first, _InputIter __last, _OutputIter __result);
|
||||
|
||||
template <class _InputIter, class _OutputIter, class _BinaryPredicate>
|
||||
_OutputIter unique_copy(_InputIter __first, _InputIter __last,_OutputIter __result,
|
||||
_BinaryPredicate __binary_pred);
|
||||
|
||||
template <class _ForwardIter>
|
||||
inline _ForwardIter unique(_ForwardIter __first, _ForwardIter __last) {
|
||||
__first = adjacent_find(__first, __last);
|
||||
return unique_copy(__first, __last, __first);
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _BinaryPredicate>
|
||||
inline _ForwardIter unique(_ForwardIter __first, _ForwardIter __last,
|
||||
_BinaryPredicate __binary_pred) {
|
||||
__first = adjacent_find(__first, __last, __binary_pred);
|
||||
return unique_copy(__first, __last, __first, __binary_pred);
|
||||
}
|
||||
|
||||
// reverse and reverse_copy, and their auxiliary functions
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _BidirectionalIter>
|
||||
_STLP_INLINE_LOOP void
|
||||
__reverse(_BidirectionalIter __first, _BidirectionalIter __last, const bidirectional_iterator_tag &) {
|
||||
for (; __first != __last && __first != --__last; ++__first)
|
||||
_STLP_STD::iter_swap(__first,__last);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIter>
|
||||
_STLP_INLINE_LOOP void
|
||||
__reverse(_RandomAccessIter __first, _RandomAccessIter __last, const random_access_iterator_tag &) {
|
||||
for (; __first < __last; ++__first)
|
||||
_STLP_STD::iter_swap(__first, --__last);
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _BidirectionalIter>
|
||||
inline void
|
||||
reverse(_BidirectionalIter __first, _BidirectionalIter __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_STLP_PRIV __reverse(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _BidirectionalIter));
|
||||
}
|
||||
|
||||
template <class _BidirectionalIter, class _OutputIter>
|
||||
_STLP_INLINE_LOOP
|
||||
_OutputIter reverse_copy(_BidirectionalIter __first,
|
||||
_BidirectionalIter __last,
|
||||
_OutputIter __result) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
while (__first != __last) {
|
||||
--__last;
|
||||
*__result = *__last;
|
||||
++__result;
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _ForwardIter>
|
||||
void rotate(_ForwardIter __first, _ForwardIter __middle, _ForwardIter __last);
|
||||
|
||||
template <class _ForwardIter, class _OutputIter>
|
||||
inline _OutputIter rotate_copy(_ForwardIter __first, _ForwardIter __middle,
|
||||
_ForwardIter __last, _OutputIter __result) {
|
||||
return _STLP_STD::copy(__first, __middle, copy(__middle, __last, __result));
|
||||
}
|
||||
|
||||
// random_shuffle
|
||||
|
||||
template <class _RandomAccessIter>
|
||||
void random_shuffle(_RandomAccessIter __first, _RandomAccessIter __last);
|
||||
|
||||
template <class _RandomAccessIter, class _RandomNumberGenerator>
|
||||
void random_shuffle(_RandomAccessIter __first, _RandomAccessIter __last,
|
||||
_RandomNumberGenerator& __rand);
|
||||
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
// random_sample and random_sample_n (extensions, not part of the standard).
|
||||
|
||||
template <class _ForwardIter, class _OutputIter, class _Distance>
|
||||
_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last,
|
||||
_OutputIter __out_ite, const _Distance __n);
|
||||
|
||||
template <class _ForwardIter, class _OutputIter, class _Distance,
|
||||
class _RandomNumberGenerator>
|
||||
_OutputIter random_sample_n(_ForwardIter __first, _ForwardIter __last,
|
||||
_OutputIter __out_ite, const _Distance __n,
|
||||
_RandomNumberGenerator& __rand);
|
||||
|
||||
template <class _InputIter, class _RandomAccessIter>
|
||||
_RandomAccessIter
|
||||
random_sample(_InputIter __first, _InputIter __last,
|
||||
_RandomAccessIter __out_first, _RandomAccessIter __out_last);
|
||||
|
||||
template <class _InputIter, class _RandomAccessIter,
|
||||
class _RandomNumberGenerator>
|
||||
_RandomAccessIter
|
||||
random_sample(_InputIter __first, _InputIter __last,
|
||||
_RandomAccessIter __out_first, _RandomAccessIter __out_last,
|
||||
_RandomNumberGenerator& __rand);
|
||||
|
||||
#endif /* _STLP_NO_EXTENSIONS */
|
||||
|
||||
// partition, stable_partition, and their auxiliary functions
|
||||
|
||||
template <class _ForwardIter, class _Predicate>
|
||||
_ForwardIter partition(_ForwardIter __first, _ForwardIter __last, _Predicate __pred);
|
||||
|
||||
template <class _ForwardIter, class _Predicate>
|
||||
_ForwardIter
|
||||
stable_partition(_ForwardIter __first, _ForwardIter __last, _Predicate __pred);
|
||||
|
||||
// sort() and its auxiliary functions.
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Size>
|
||||
inline _Size __lg(_Size __n) {
|
||||
_Size __k;
|
||||
for (__k = 0; __n != 1; __n >>= 1) ++__k;
|
||||
return __k;
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _RandomAccessIter>
|
||||
void sort(_RandomAccessIter __first, _RandomAccessIter __last);
|
||||
template <class _RandomAccessIter, class _Compare>
|
||||
void sort(_RandomAccessIter __first, _RandomAccessIter __last, _Compare __comp);
|
||||
|
||||
// stable_sort() and its auxiliary functions.
|
||||
template <class _RandomAccessIter>
|
||||
void stable_sort(_RandomAccessIter __first,
|
||||
_RandomAccessIter __last);
|
||||
|
||||
template <class _RandomAccessIter, class _Compare>
|
||||
void stable_sort(_RandomAccessIter __first,
|
||||
_RandomAccessIter __last, _Compare __comp);
|
||||
|
||||
// partial_sort, partial_sort_copy, and auxiliary functions.
|
||||
|
||||
template <class _RandomAccessIter>
|
||||
void partial_sort(_RandomAccessIter __first, _RandomAccessIter __middle,
|
||||
_RandomAccessIter __last);
|
||||
|
||||
template <class _RandomAccessIter, class _Compare>
|
||||
void partial_sort(_RandomAccessIter __first,_RandomAccessIter __middle,
|
||||
_RandomAccessIter __last, _Compare __comp);
|
||||
|
||||
template <class _InputIter, class _RandomAccessIter>
|
||||
_RandomAccessIter
|
||||
partial_sort_copy(_InputIter __first, _InputIter __last,
|
||||
_RandomAccessIter __result_first, _RandomAccessIter __result_last);
|
||||
|
||||
template <class _InputIter, class _RandomAccessIter, class _Compare>
|
||||
_RandomAccessIter
|
||||
partial_sort_copy(_InputIter __first, _InputIter __last,
|
||||
_RandomAccessIter __result_first,
|
||||
_RandomAccessIter __result_last, _Compare __comp);
|
||||
|
||||
// nth_element() and its auxiliary functions.
|
||||
template <class _RandomAccessIter>
|
||||
void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth,
|
||||
_RandomAccessIter __last);
|
||||
|
||||
template <class _RandomAccessIter, class _Compare>
|
||||
void nth_element(_RandomAccessIter __first, _RandomAccessIter __nth,
|
||||
_RandomAccessIter __last, _Compare __comp);
|
||||
|
||||
// auxiliary class for lower_bound, etc.
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _T1, class _T2>
|
||||
struct __less_2 {
|
||||
bool operator() (const _T1& __x, const _T2& __y) const { return __x < __y ; }
|
||||
};
|
||||
|
||||
template <class _T1, class _T2>
|
||||
__less_2<_T1,_T2> __less2(_T1*, _T2* ) { return __less_2<_T1, _T2>(); }
|
||||
|
||||
#if defined (_STLP_FUNCTION_PARTIAL_ORDER)
|
||||
template <class _Tp>
|
||||
less<_Tp> __less2(_Tp*, _Tp* ) { return less<_Tp>(); }
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
// Binary search (lower_bound, upper_bound, equal_range, binary_search).
|
||||
template <class _ForwardIter, class _Tp>
|
||||
inline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last,
|
||||
const _Tp& __val) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
return _STLP_PRIV __lower_bound(__first, __last, __val,
|
||||
_STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
|
||||
_STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)),
|
||||
_STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _Tp, class _Compare>
|
||||
inline _ForwardIter lower_bound(_ForwardIter __first, _ForwardIter __last,
|
||||
const _Tp& __val, _Compare __comp) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
return _STLP_PRIV __lower_bound(__first, __last, __val, __comp, __comp,
|
||||
_STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _ForwardIter, class _Tp, class _Compare1, class _Compare2, class _Distance>
|
||||
_ForwardIter __upper_bound(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,
|
||||
_Compare1 __comp1, _Compare2 __comp2, _Distance*);
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _ForwardIter, class _Tp>
|
||||
inline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last,
|
||||
const _Tp& __val) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
return _STLP_PRIV __upper_bound(__first, __last, __val,
|
||||
_STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
|
||||
_STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)),
|
||||
_STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _Tp, class _Compare>
|
||||
inline _ForwardIter upper_bound(_ForwardIter __first, _ForwardIter __last,
|
||||
const _Tp& __val, _Compare __comp) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
return _STLP_PRIV __upper_bound(__first, __last, __val, __comp, __comp,
|
||||
_STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _ForwardIter, class _Tp, class _Compare1, class _Compare2, class _Distance>
|
||||
pair<_ForwardIter, _ForwardIter>
|
||||
__equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,
|
||||
_Compare1 __comp1, _Compare2 __comp2, _Distance*);
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _ForwardIter, class _Tp>
|
||||
inline pair<_ForwardIter, _ForwardIter>
|
||||
equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
return _STLP_PRIV __equal_range(__first, __last, __val,
|
||||
_STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
|
||||
_STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)),
|
||||
_STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _Tp, class _Compare>
|
||||
inline pair<_ForwardIter, _ForwardIter>
|
||||
equal_range(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,
|
||||
_Compare __comp) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
return _STLP_PRIV __equal_range(__first, __last, __val, __comp, __comp,
|
||||
_STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _Tp>
|
||||
inline bool binary_search(_ForwardIter __first, _ForwardIter __last,
|
||||
const _Tp& __val) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_ForwardIter __i = _STLP_PRIV __lower_bound(__first, __last, __val,
|
||||
_STLP_PRIV __less2(_STLP_VALUE_TYPE(__first, _ForwardIter), (_Tp*)0),
|
||||
_STLP_PRIV __less2((_Tp*)0, _STLP_VALUE_TYPE(__first, _ForwardIter)),
|
||||
_STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
||||
return __i != __last && !(__val < *__i);
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _Tp, class _Compare>
|
||||
inline bool binary_search(_ForwardIter __first, _ForwardIter __last,
|
||||
const _Tp& __val,
|
||||
_Compare __comp) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_ForwardIter __i = _STLP_PRIV __lower_bound(__first, __last, __val, __comp, __comp,
|
||||
_STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
||||
return __i != __last && !__comp(__val, *__i);
|
||||
}
|
||||
|
||||
// merge, with and without an explicitly supplied comparison function.
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _OutputIter>
|
||||
_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_OutputIter __result);
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _OutputIter,
|
||||
class _Compare>
|
||||
_OutputIter merge(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_OutputIter __result, _Compare __comp);
|
||||
|
||||
|
||||
// inplace_merge and its auxiliary functions.
|
||||
|
||||
|
||||
template <class _BidirectionalIter>
|
||||
void inplace_merge(_BidirectionalIter __first,
|
||||
_BidirectionalIter __middle,
|
||||
_BidirectionalIter __last) ;
|
||||
|
||||
template <class _BidirectionalIter, class _Compare>
|
||||
void inplace_merge(_BidirectionalIter __first,
|
||||
_BidirectionalIter __middle,
|
||||
_BidirectionalIter __last, _Compare __comp);
|
||||
|
||||
// Set algorithms: includes, set_union, set_intersection, set_difference,
|
||||
// set_symmetric_difference. All of these algorithms have the precondition
|
||||
// that their input ranges are sorted and the postcondition that their output
|
||||
// ranges are sorted.
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
bool includes(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2);
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _Compare>
|
||||
bool includes(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2, _Compare __comp);
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _OutputIter>
|
||||
_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_OutputIter __result);
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _OutputIter,
|
||||
class _Compare>
|
||||
_OutputIter set_union(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_OutputIter __result, _Compare __comp);
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _OutputIter>
|
||||
_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_OutputIter __result);
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _OutputIter,
|
||||
class _Compare>
|
||||
_OutputIter set_intersection(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_OutputIter __result, _Compare __comp);
|
||||
|
||||
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _OutputIter>
|
||||
_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_OutputIter __result);
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _OutputIter,
|
||||
class _Compare>
|
||||
_OutputIter set_difference(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_OutputIter __result, _Compare __comp);
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _OutputIter>
|
||||
_OutputIter
|
||||
set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_OutputIter __result);
|
||||
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _OutputIter,
|
||||
class _Compare>
|
||||
_OutputIter
|
||||
set_symmetric_difference(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_OutputIter __result,
|
||||
_Compare __comp);
|
||||
|
||||
|
||||
// min_element and max_element, with and without an explicitly supplied
|
||||
// comparison function.
|
||||
|
||||
template <class _ForwardIter>
|
||||
_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last);
|
||||
template <class _ForwardIter, class _Compare>
|
||||
_ForwardIter max_element(_ForwardIter __first, _ForwardIter __last,
|
||||
_Compare __comp);
|
||||
|
||||
template <class _ForwardIter>
|
||||
_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last);
|
||||
|
||||
template <class _ForwardIter, class _Compare>
|
||||
_ForwardIter min_element(_ForwardIter __first, _ForwardIter __last,
|
||||
_Compare __comp);
|
||||
|
||||
// next_permutation and prev_permutation, with and without an explicitly
|
||||
// supplied comparison function.
|
||||
|
||||
template <class _BidirectionalIter>
|
||||
bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last);
|
||||
|
||||
template <class _BidirectionalIter, class _Compare>
|
||||
bool next_permutation(_BidirectionalIter __first, _BidirectionalIter __last,
|
||||
_Compare __comp);
|
||||
|
||||
|
||||
template <class _BidirectionalIter>
|
||||
bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last);
|
||||
|
||||
|
||||
template <class _BidirectionalIter, class _Compare>
|
||||
bool prev_permutation(_BidirectionalIter __first, _BidirectionalIter __last,
|
||||
_Compare __comp);
|
||||
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
// is_heap, a predicate testing whether or not a range is
|
||||
// a heap. This function is an extension, not part of the C++
|
||||
// standard.
|
||||
|
||||
template <class _RandomAccessIter>
|
||||
bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last);
|
||||
|
||||
template <class _RandomAccessIter, class _StrictWeakOrdering>
|
||||
bool is_heap(_RandomAccessIter __first, _RandomAccessIter __last,
|
||||
_StrictWeakOrdering __comp);
|
||||
|
||||
// is_sorted, a predicated testing whether a range is sorted in
|
||||
// nondescending order. This is an extension, not part of the C++
|
||||
// standard.
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _ForwardIter, class _StrictWeakOrdering>
|
||||
bool __is_sorted(_ForwardIter __first, _ForwardIter __last,
|
||||
_StrictWeakOrdering __comp);
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
template <class _ForwardIter>
|
||||
inline bool is_sorted(_ForwardIter __first, _ForwardIter __last) {
|
||||
return _STLP_PRIV __is_sorted(__first, __last,
|
||||
_STLP_PRIV __less(_STLP_VALUE_TYPE(__first, _ForwardIter)));
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _StrictWeakOrdering>
|
||||
inline bool is_sorted(_ForwardIter __first, _ForwardIter __last,
|
||||
_StrictWeakOrdering __comp) {
|
||||
return _STLP_PRIV __is_sorted(__first, __last, __comp);
|
||||
}
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_algo.c>
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_ALGO_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
483
extern/STLport/5.2.1/stlport/stl/_algobase.c
vendored
Normal file
483
extern/STLport/5.2.1/stlport/stl/_algobase.c
vendored
Normal file
@@ -0,0 +1,483 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_ALGOBASE_C
|
||||
#define _STLP_ALGOBASE_C
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALGOBASE_H
|
||||
# include <stl/_algobase.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
|
||||
# include <stl/_function_base.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
|
||||
for ( ; __first1 != __last1 && __first2 != __last2
|
||||
; ++__first1, ++__first2) {
|
||||
if (*__first1 < *__first2) {
|
||||
_STLP_VERBOSE_ASSERT(!(*__first2 < *__first1), _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
|
||||
return true;
|
||||
}
|
||||
if (*__first2 < *__first1)
|
||||
return false;
|
||||
}
|
||||
return __first1 == __last1 && __first2 != __last2;
|
||||
}
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _Compare>
|
||||
bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_Compare __comp) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
|
||||
for ( ; __first1 != __last1 && __first2 != __last2
|
||||
; ++__first1, ++__first2) {
|
||||
if (__comp(*__first1, *__first2)) {
|
||||
_STLP_VERBOSE_ASSERT(!__comp(*__first2, *__first1),
|
||||
_StlMsg_INVALID_STRICT_WEAK_PREDICATE)
|
||||
return true;
|
||||
}
|
||||
if (__comp(*__first2, *__first1))
|
||||
return false;
|
||||
}
|
||||
return __first1 == __last1 && __first2 != __last2;
|
||||
}
|
||||
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2) {
|
||||
while (__first1 != __last1 && __first2 != __last2) {
|
||||
if (*__first1 < *__first2) {
|
||||
_STLP_VERBOSE_ASSERT(!(*__first2 < *__first1), _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
|
||||
return -1;
|
||||
}
|
||||
if (*__first2 < *__first1)
|
||||
return 1;
|
||||
++__first1;
|
||||
++__first2;
|
||||
}
|
||||
if (__first2 == __last2) {
|
||||
return !(__first1 == __last1);
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
|
||||
return _STLP_PRIV __lexicographical_compare_3way(__first1, __last1, __first2, __last2);
|
||||
}
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _RandomAccessIter, class _Tp>
|
||||
_STLP_INLINE_LOOP _RandomAccessIter __find(_RandomAccessIter __first, _RandomAccessIter __last,
|
||||
const _Tp& __val,
|
||||
const random_access_iterator_tag &) {
|
||||
_STLP_DIFFERENCE_TYPE(_RandomAccessIter) __trip_count = (__last - __first) >> 2;
|
||||
|
||||
for ( ; __trip_count > 0 ; --__trip_count) {
|
||||
if (*__first == __val) return __first;
|
||||
++__first;
|
||||
|
||||
if (*__first == __val) return __first;
|
||||
++__first;
|
||||
|
||||
if (*__first == __val) return __first;
|
||||
++__first;
|
||||
|
||||
if (*__first == __val) return __first;
|
||||
++__first;
|
||||
}
|
||||
|
||||
switch (__last - __first) {
|
||||
case 3:
|
||||
if (*__first == __val) return __first;
|
||||
++__first;
|
||||
case 2:
|
||||
if (*__first == __val) return __first;
|
||||
++__first;
|
||||
case 1:
|
||||
if (*__first == __val) return __first;
|
||||
//++__first;
|
||||
case 0:
|
||||
default:
|
||||
return __last;
|
||||
}
|
||||
}
|
||||
|
||||
inline char*
|
||||
__find(char* __first, char* __last, char __val, const random_access_iterator_tag &) {
|
||||
void *res = memchr(__first, __val, __last - __first);
|
||||
return res != 0 ? __STATIC_CAST(char*, res) : __last;
|
||||
}
|
||||
inline const char*
|
||||
__find(const char* __first, const char* __last, char __val, const random_access_iterator_tag &) {
|
||||
const void *res = memchr(__first, __val, __last - __first);
|
||||
return res != 0 ? __STATIC_CAST(const char*, res) : __last;
|
||||
}
|
||||
|
||||
template <class _RandomAccessIter, class _Predicate>
|
||||
_STLP_INLINE_LOOP _RandomAccessIter __find_if(_RandomAccessIter __first, _RandomAccessIter __last,
|
||||
_Predicate __pred,
|
||||
const random_access_iterator_tag &) {
|
||||
_STLP_DIFFERENCE_TYPE(_RandomAccessIter) __trip_count = (__last - __first) >> 2;
|
||||
|
||||
for ( ; __trip_count > 0 ; --__trip_count) {
|
||||
if (__pred(*__first)) return __first;
|
||||
++__first;
|
||||
|
||||
if (__pred(*__first)) return __first;
|
||||
++__first;
|
||||
|
||||
if (__pred(*__first)) return __first;
|
||||
++__first;
|
||||
|
||||
if (__pred(*__first)) return __first;
|
||||
++__first;
|
||||
}
|
||||
|
||||
switch(__last - __first) {
|
||||
case 3:
|
||||
if (__pred(*__first)) return __first;
|
||||
++__first;
|
||||
case 2:
|
||||
if (__pred(*__first)) return __first;
|
||||
++__first;
|
||||
case 1:
|
||||
if (__pred(*__first)) return __first;
|
||||
//++__first;
|
||||
case 0:
|
||||
default:
|
||||
return __last;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _InputIter, class _Tp>
|
||||
_STLP_INLINE_LOOP _InputIter __find(_InputIter __first, _InputIter __last,
|
||||
const _Tp& __val,
|
||||
const input_iterator_tag &) {
|
||||
while (__first != __last && !(*__first == __val)) ++__first;
|
||||
return __first;
|
||||
}
|
||||
|
||||
template <class _InputIter, class _Predicate>
|
||||
_STLP_INLINE_LOOP _InputIter __find_if(_InputIter __first, _InputIter __last,
|
||||
_Predicate __pred,
|
||||
const input_iterator_tag &) {
|
||||
while (__first != __last && !__pred(*__first))
|
||||
++__first;
|
||||
return __first;
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _InputIter, class _Predicate>
|
||||
_InputIter find_if(_InputIter __first, _InputIter __last,
|
||||
_Predicate __pred) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
return _STLP_PRIV __find_if(__first, __last, __pred, _STLP_ITERATOR_CATEGORY(__first, _InputIter));
|
||||
}
|
||||
|
||||
template <class _InputIter, class _Tp>
|
||||
_InputIter find(_InputIter __first, _InputIter __last, const _Tp& __val) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
return _STLP_PRIV __find(__first, __last, __val, _STLP_ITERATOR_CATEGORY(__first, _InputIter));
|
||||
}
|
||||
|
||||
template <class _ForwardIter1, class _ForwardIter2, class _BinaryPred>
|
||||
_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1,
|
||||
_ForwardIter2 __first2, _ForwardIter2 __last2,
|
||||
_BinaryPred __pred) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
|
||||
// Test for empty ranges
|
||||
if (__first1 == __last1 || __first2 == __last2)
|
||||
return __first1;
|
||||
|
||||
// Test for a pattern of length 1.
|
||||
_ForwardIter2 __p1(__first2);
|
||||
|
||||
if ( ++__p1 == __last2 ) {
|
||||
while (__first1 != __last1 && !__pred(*__first1, *__first2)) {
|
||||
++__first1;
|
||||
}
|
||||
return __first1;
|
||||
}
|
||||
|
||||
// General case.
|
||||
|
||||
for ( ; ; ) { // __first1 != __last1 will be checked below
|
||||
while (__first1 != __last1 && !__pred(*__first1, *__first2)) {
|
||||
++__first1;
|
||||
}
|
||||
if (__first1 == __last1) {
|
||||
return __last1;
|
||||
}
|
||||
_ForwardIter2 __p = __p1;
|
||||
_ForwardIter1 __current = __first1;
|
||||
if (++__current == __last1) return __last1;
|
||||
|
||||
while (__pred(*__current, *__p)) {
|
||||
if (++__p == __last2)
|
||||
return __first1;
|
||||
if (++__current == __last1)
|
||||
return __last1;
|
||||
}
|
||||
++__first1;
|
||||
}
|
||||
return __first1;
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
template <class _Tp>
|
||||
struct _IsCharLikeType
|
||||
{ typedef __false_type _Ret; };
|
||||
|
||||
_STLP_TEMPLATE_NULL struct _IsCharLikeType<char>
|
||||
{ typedef __true_type _Ret; };
|
||||
|
||||
_STLP_TEMPLATE_NULL struct _IsCharLikeType<unsigned char>
|
||||
{ typedef __true_type _Ret; };
|
||||
|
||||
# ifndef _STLP_NO_SIGNED_BUILTINS
|
||||
_STLP_TEMPLATE_NULL struct _IsCharLikeType<signed char>
|
||||
{ typedef __true_type _Ret; };
|
||||
# endif
|
||||
|
||||
template <class _Tp1, class _Tp2>
|
||||
inline bool __stlp_eq(_Tp1 __val1, _Tp2 __val2)
|
||||
{ return __val1 == __val2; }
|
||||
|
||||
#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
template <class _Tp>
|
||||
inline bool __stlp_eq(_Tp, _Tp)
|
||||
{ return true; }
|
||||
#endif
|
||||
|
||||
template <class _InputIter, class _ForwardIter, class _Tp2, class _Predicate>
|
||||
inline _InputIter __find_first_of_aux2(_InputIter __first1, _InputIter __last1,
|
||||
_ForwardIter __first2, _ForwardIter __last2,
|
||||
_Tp2*, _Predicate __pred,
|
||||
const __true_type& /* _UseStrcspnLikeAlgo */) {
|
||||
unsigned char __hints[(UCHAR_MAX + 1) / CHAR_BIT];
|
||||
memset(__hints, 0, sizeof(__hints) / sizeof(unsigned char));
|
||||
for (; __first2 != __last2; ++__first2) {
|
||||
unsigned char __tmp = (unsigned char)*__first2;
|
||||
__hints[__tmp / CHAR_BIT] |= (1 << (__tmp % CHAR_BIT));
|
||||
}
|
||||
|
||||
for (; __first1 != __last1; ++__first1) {
|
||||
_Tp2 __tmp = (_Tp2)*__first1;
|
||||
if (__stlp_eq(*__first1, __tmp) &&
|
||||
__pred((__hints[(unsigned char)__tmp / CHAR_BIT] & (1 << ((unsigned char)__tmp % CHAR_BIT))) != 0))
|
||||
break;
|
||||
}
|
||||
return __first1;
|
||||
}
|
||||
|
||||
template <class _InputIter, class _ForwardIter, class _Tp2, class _Predicate>
|
||||
inline _InputIter __find_first_of_aux2(_InputIter __first1, _InputIter __last1,
|
||||
_ForwardIter __first2, _ForwardIter __last2,
|
||||
_Tp2* /* __dummy */, _Predicate /* __pred */,
|
||||
const __false_type& /* _UseStrcspnLikeAlgo */) {
|
||||
return _STLP_PRIV __find_first_of(__first1, __last1, __first2, __last2,
|
||||
_STLP_PRIV __equal_to(_STLP_VALUE_TYPE(__first1, _InputIter)));
|
||||
}
|
||||
|
||||
template <class _InputIter, class _ForwardIter, class _Tp1, class _Tp2>
|
||||
inline _InputIter __find_first_of_aux1(_InputIter __first1, _InputIter __last1,
|
||||
_ForwardIter __first2, _ForwardIter __last2,
|
||||
_Tp1* __pt1, _Tp2* __pt2) {
|
||||
typedef _STLP_TYPENAME _STLP_STD::_IsIntegral<_Tp1>::_Ret _IsIntegral;
|
||||
typedef _STLP_TYPENAME _STLP_PRIV _IsCharLikeType<_Tp2>::_Ret _IsCharLike;
|
||||
typedef _STLP_TYPENAME _STLP_STD::_Land2<_IsIntegral, _IsCharLike>::_Ret _UseStrcspnLikeAlgo;
|
||||
return _STLP_PRIV __find_first_of_aux2(__first1, __last1,
|
||||
__first2, __last2,
|
||||
__pt2, _Identity<bool>(), _UseStrcspnLikeAlgo());
|
||||
}
|
||||
|
||||
template <class _InputIter, class _ForwardIter>
|
||||
inline _InputIter __find_first_of(_InputIter __first1, _InputIter __last1,
|
||||
_ForwardIter __first2, _ForwardIter __last2) {
|
||||
return _STLP_PRIV __find_first_of_aux1(__first1, __last1, __first2, __last2,
|
||||
_STLP_VALUE_TYPE(__first1, _InputIter),
|
||||
_STLP_VALUE_TYPE(__first2, _ForwardIter));
|
||||
}
|
||||
|
||||
// find_first_of, with and without an explicitly supplied comparison function.
|
||||
template <class _InputIter, class _ForwardIter, class _BinaryPredicate>
|
||||
_InputIter __find_first_of(_InputIter __first1, _InputIter __last1,
|
||||
_ForwardIter __first2, _ForwardIter __last2,
|
||||
_BinaryPredicate __comp) {
|
||||
for ( ; __first1 != __last1; ++__first1) {
|
||||
for (_ForwardIter __iter = __first2; __iter != __last2; ++__iter) {
|
||||
if (__comp(*__first1, *__iter)) {
|
||||
return __first1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return __last1;
|
||||
}
|
||||
|
||||
// find_end, with and without an explicitly supplied comparison function.
|
||||
// Search [first2, last2) as a subsequence in [first1, last1), and return
|
||||
// the *last* possible match. Note that find_end for bidirectional iterators
|
||||
// is much faster than for forward iterators.
|
||||
|
||||
// find_end for forward iterators.
|
||||
template <class _ForwardIter1, class _ForwardIter2,
|
||||
class _BinaryPredicate>
|
||||
_ForwardIter1 __find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,
|
||||
_ForwardIter2 __first2, _ForwardIter2 __last2,
|
||||
const forward_iterator_tag &, const forward_iterator_tag &,
|
||||
_BinaryPredicate __comp) {
|
||||
if (__first2 == __last2)
|
||||
return __last1;
|
||||
else {
|
||||
_ForwardIter1 __result = __last1;
|
||||
for (;;) {
|
||||
_ForwardIter1 __new_result = _STLP_STD::search(__first1, __last1, __first2, __last2, __comp);
|
||||
if (__new_result == __last1)
|
||||
return __result;
|
||||
else {
|
||||
__result = __new_result;
|
||||
__first1 = __new_result;
|
||||
++__first1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
// find_end for bidirectional iterators. Requires partial specialization.
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
|
||||
# ifndef _STLP_INTERNAL_ITERATOR_H
|
||||
_STLP_END_NAMESPACE
|
||||
# include <stl/_iterator.h>
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
# endif /*_STLP_INTERNAL_ITERATOR_H*/
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _BidirectionalIter1, class _BidirectionalIter2,
|
||||
class _BinaryPredicate>
|
||||
_BidirectionalIter1
|
||||
__find_end(_BidirectionalIter1 __first1, _BidirectionalIter1 __last1,
|
||||
_BidirectionalIter2 __first2, _BidirectionalIter2 __last2,
|
||||
const bidirectional_iterator_tag &, const bidirectional_iterator_tag &,
|
||||
_BinaryPredicate __comp) {
|
||||
typedef _STLP_STD::reverse_iterator<_BidirectionalIter1> _RevIter1;
|
||||
typedef _STLP_STD::reverse_iterator<_BidirectionalIter2> _RevIter2;
|
||||
|
||||
_RevIter1 __rlast1(__first1);
|
||||
_RevIter2 __rlast2(__first2);
|
||||
_RevIter1 __rresult = _STLP_STD::search(_RevIter1(__last1), __rlast1,
|
||||
_RevIter2(__last2), __rlast2,
|
||||
__comp);
|
||||
|
||||
if (__rresult == __rlast1)
|
||||
return __last1;
|
||||
else {
|
||||
_BidirectionalIter1 __result = __rresult.base();
|
||||
_STLP_STD::advance(__result, -_STLP_STD::distance(__first2, __last2));
|
||||
return __result;
|
||||
}
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
|
||||
|
||||
template <class _ForwardIter1, class _ForwardIter2,
|
||||
class _BinaryPredicate>
|
||||
_ForwardIter1
|
||||
find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,
|
||||
_ForwardIter2 __first2, _ForwardIter2 __last2,
|
||||
_BinaryPredicate __comp) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
|
||||
return _STLP_PRIV __find_end(__first1, __last1, __first2, __last2,
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
_STLP_ITERATOR_CATEGORY(__first1, _ForwardIter1),
|
||||
_STLP_ITERATOR_CATEGORY(__first2, _ForwardIter2),
|
||||
#else
|
||||
forward_iterator_tag(),
|
||||
forward_iterator_tag(),
|
||||
#endif
|
||||
__comp);
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _ForwardIter, class _Tp, class _Compare1, class _Compare2, class _Distance>
|
||||
_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,
|
||||
_Compare1 __comp1, _Compare2 __comp2, _Distance*) {
|
||||
_Distance __len = _STLP_STD::distance(__first, __last);
|
||||
_Distance __half;
|
||||
_ForwardIter __middle;
|
||||
|
||||
while (__len > 0) {
|
||||
__half = __len >> 1;
|
||||
__middle = __first;
|
||||
_STLP_STD::advance(__middle, __half);
|
||||
if (__comp1(*__middle, __val)) {
|
||||
_STLP_VERBOSE_ASSERT(!__comp2(__val, *__middle), _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
|
||||
__first = __middle;
|
||||
++__first;
|
||||
__len = __len - __half - 1;
|
||||
}
|
||||
else
|
||||
__len = __half;
|
||||
}
|
||||
return __first;
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_ALGOBASE_C */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
728
extern/STLport/5.2.1/stlport/stl/_algobase.h
vendored
Normal file
728
extern/STLport/5.2.1/stlport/stl/_algobase.h
vendored
Normal file
@@ -0,0 +1,728 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALGOBASE_H
|
||||
#define _STLP_INTERNAL_ALGOBASE_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSTDDEF
|
||||
# include <stl/_cstddef.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSTRING
|
||||
# include <stl/_cstring.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_CLIMITS
|
||||
# include <climits>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSTDLIB
|
||||
# include <stl/_cstdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_PAIR_H
|
||||
# include <stl/_pair.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
|
||||
# include <stl/_iterator_base.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_TYPE_TRAITS_H
|
||||
# include <stl/type_traits.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
template <class _Tp>
|
||||
inline void __swap_aux(_Tp& __a, _Tp& __b, const __true_type& /*SwapImplemented*/) {
|
||||
__a._M_swap_workaround(__b);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline void __swap_aux(_Tp& __a, _Tp& __b, const __false_type& /*SwapImplemented*/) {
|
||||
_Tp __tmp = __a;
|
||||
__a = __b;
|
||||
__b = __tmp;
|
||||
}
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
#endif
|
||||
|
||||
// swap and iter_swap
|
||||
template <class _Tp>
|
||||
inline void swap(_Tp& __a, _Tp& __b) {
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
# if !defined(__BORLANDC__)
|
||||
typedef typename _SwapImplemented<_Tp>::_Ret _Implemented;
|
||||
# else
|
||||
enum { _Is = _SwapImplemented<_Tp>::_Is };
|
||||
typedef typename __bool2type<_Is>::_Ret _Implemented;
|
||||
# endif
|
||||
_STLP_PRIV __swap_aux(__a, __b, _Implemented());
|
||||
#else
|
||||
_Tp __tmp = __a;
|
||||
__a = __b;
|
||||
__b = __tmp;
|
||||
#endif
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _ForwardIter1, class _ForwardIter2, class _Value>
|
||||
inline void __iter_swap_aux_aux(_ForwardIter1& __i1, _ForwardIter2& __i2, _Value *) {
|
||||
_Value tmp = *__i1;
|
||||
*__i1 = *__i2;
|
||||
*__i2 = tmp;
|
||||
}
|
||||
|
||||
template <class _ForwardIter1, class _ForwardIter2>
|
||||
inline void __iter_swap_aux(_ForwardIter1& __i1, _ForwardIter2& __i2, const __true_type& /*OKToSwap*/) {
|
||||
/* namespace specification breaks access to the right swap template overload (at least for gcc) */
|
||||
/*_STLP_STD::*/ swap(*__i1, *__i2);
|
||||
}
|
||||
|
||||
template <class _ForwardIter1, class _ForwardIter2>
|
||||
inline void __iter_swap_aux(_ForwardIter1& __i1, _ForwardIter2& __i2, const __false_type& /*OKToSwap*/) {
|
||||
_STLP_PRIV __iter_swap_aux_aux( __i1, __i2, _STLP_VALUE_TYPE(__i1,_ForwardIter1) );
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _ForwardIter1, class _ForwardIter2>
|
||||
inline void iter_swap(_ForwardIter1 __i1, _ForwardIter2 __i2) {
|
||||
_STLP_PRIV __iter_swap_aux( __i1, __i2, _IsOKToSwap(_STLP_VALUE_TYPE(__i1, _ForwardIter1), _STLP_VALUE_TYPE(__i2, _ForwardIter2),
|
||||
_STLP_IS_REF_TYPE_REAL_REF(__i1, _ForwardIter1),
|
||||
_STLP_IS_REF_TYPE_REAL_REF(__i2, _ForwardIter2))._Answer());
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// min and max
|
||||
|
||||
#if !defined (__BORLANDC__) || defined (_STLP_USE_OWN_NAMESPACE)
|
||||
# if (defined (__BORLANDC__) && (__BORLANDC__ < 0x580)) && !defined (__STDC__)
|
||||
//In not ANSI mode Borland import min/max in global namespace which conflict
|
||||
//with STLport min/max when user does a 'using namespace std' in its code
|
||||
//(see test/unit/alg_test.cpp). To avoid this clash we simply import Borland min/max
|
||||
//in STLport namespace.
|
||||
using _STLP_VENDOR_STD::min;
|
||||
using _STLP_VENDOR_STD::max;
|
||||
# else
|
||||
template <class _Tp>
|
||||
inline const _Tp& (min)(const _Tp& __a, const _Tp& __b) { return __b < __a ? __b : __a; }
|
||||
template <class _Tp>
|
||||
inline const _Tp& (max)(const _Tp& __a, const _Tp& __b) { return __a < __b ? __b : __a; }
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# if defined (__BORLANDC__) && defined (_STLP_USE_OWN_NAMESPACE)
|
||||
inline unsigned long (min) (unsigned long __a, unsigned long __b) { return __b < __a ? __b : __a; }
|
||||
inline unsigned long (max) (unsigned long __a, unsigned long __b) { return __a < __b ? __b : __a; }
|
||||
# endif
|
||||
|
||||
# if !defined (__BORLANDC__) || (__BORLANDC__ < 0x590)
|
||||
template <class _Tp, class _Compare>
|
||||
inline const _Tp& (min)(const _Tp& __a, const _Tp& __b, _Compare __comp) {
|
||||
return __comp(__b, __a) ? __b : __a;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Compare>
|
||||
inline const _Tp& (max)(const _Tp& __a, const _Tp& __b, _Compare __comp) {
|
||||
return __comp(__a, __b) ? __b : __a;
|
||||
}
|
||||
# else
|
||||
template <class _Tp, class _Compare>
|
||||
inline const _Tp (min)(const _Tp __a, const _Tp __b, _Compare __comp) {
|
||||
return __comp(__b, __a) ? __b : __a;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Compare>
|
||||
inline const _Tp (max)(const _Tp __a, const _Tp __b, _Compare __comp) {
|
||||
return __comp(__a, __b) ? __b : __a;
|
||||
}
|
||||
# endif
|
||||
|
||||
//--------------------------------------------------
|
||||
// copy
|
||||
|
||||
// All of these auxiliary functions serve two purposes. (1) Replace
|
||||
// calls to copy with memmove whenever possible. (Memmove, not memcpy,
|
||||
// because the input and output ranges are permitted to overlap.)
|
||||
// (2) If we're using random access iterators, then write the loop as
|
||||
// a for loop with an explicit count.
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _InputIter, class _OutputIter, class _Distance>
|
||||
inline _OutputIter __copy(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result, const input_iterator_tag &, _Distance*) {
|
||||
for ( ; __first != __last; ++__result, ++__first)
|
||||
*__result = *__first;
|
||||
return __result;
|
||||
}
|
||||
|
||||
#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
|
||||
template <class _InputIter, class _OutputIter, class _Distance>
|
||||
inline _OutputIter __copy(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result, const forward_iterator_tag &, _Distance* ) {
|
||||
for ( ; __first != __last; ++__result, ++__first)
|
||||
*__result = *__first;
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _InputIter, class _OutputIter, class _Distance>
|
||||
inline _OutputIter __copy(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result, const bidirectional_iterator_tag &, _Distance* ) {
|
||||
for ( ; __first != __last; ++__result, ++__first)
|
||||
*__result = *__first;
|
||||
return __result;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _RandomAccessIter, class _OutputIter, class _Distance>
|
||||
inline _OutputIter
|
||||
__copy(_RandomAccessIter __first, _RandomAccessIter __last,
|
||||
_OutputIter __result, const random_access_iterator_tag &, _Distance*) {
|
||||
for (_Distance __n = __last - __first; __n > 0; --__n) {
|
||||
*__result = *__first;
|
||||
++__first;
|
||||
++__result;
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
inline void*
|
||||
__copy_trivial(const void* __first, const void* __last, void* __result) {
|
||||
size_t __n = (const char*)__last - (const char*)__first;
|
||||
return __n ? (void *)((char*)memmove(__result, __first, __n) + __n) : __result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// copy_backward auxiliary functions
|
||||
|
||||
template <class _BidirectionalIter1, class _BidirectionalIter2,
|
||||
class _Distance>
|
||||
inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first,
|
||||
_BidirectionalIter1 __last,
|
||||
_BidirectionalIter2 __result,
|
||||
const bidirectional_iterator_tag &,
|
||||
_Distance*) {
|
||||
while (__first != __last)
|
||||
*--__result = *--__last;
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _RandomAccessIter, class _BidirectionalIter, class _Distance>
|
||||
inline _BidirectionalIter __copy_backward(_RandomAccessIter __first,
|
||||
_RandomAccessIter __last,
|
||||
_BidirectionalIter __result,
|
||||
const random_access_iterator_tag &,
|
||||
_Distance*) {
|
||||
for (_Distance __n = __last - __first; __n > 0; --__n)
|
||||
*--__result = *--__last;
|
||||
return __result;
|
||||
}
|
||||
|
||||
inline void*
|
||||
__copy_trivial_backward(const void* __first, const void* __last, void* __result) {
|
||||
const ptrdiff_t _Num = (const char*)__last - (const char*)__first;
|
||||
return (_Num > 0) ? memmove((char*)__result - _Num, __first, _Num) : __result ;
|
||||
}
|
||||
|
||||
template <class _InputIter, class _OutputIter>
|
||||
inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result,
|
||||
const __false_type& /*IsOKToMemCpy*/) {
|
||||
return _STLP_PRIV __copy(__first, __last, __result, random_access_iterator_tag(), (ptrdiff_t*)0);
|
||||
}
|
||||
template <class _InputIter, class _OutputIter>
|
||||
inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result,
|
||||
const __true_type& /*IsOKToMemCpy*/) {
|
||||
// we know they all pointers, so this cast is OK
|
||||
// return (_OutputIter)__copy_trivial(&(*__first), &(*__last), &(*__result));
|
||||
return (_OutputIter)_STLP_PRIV __copy_trivial(__first, __last, __result);
|
||||
}
|
||||
|
||||
template <class _InputIter, class _OutputIter>
|
||||
inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result,
|
||||
const __true_type& /*BothPtrType*/) {
|
||||
return _STLP_PRIV __copy_ptrs(__first, __last, __result,
|
||||
_UseTrivialCopy(_STLP_VALUE_TYPE(__first, _InputIter),
|
||||
_STLP_VALUE_TYPE(__result, _OutputIter))._Answer());
|
||||
}
|
||||
|
||||
template <class _InputIter, class _OutputIter>
|
||||
inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result,
|
||||
const __false_type& /*BothPtrType*/) {
|
||||
return _STLP_PRIV __copy(__first, __last, __result,
|
||||
_STLP_ITERATOR_CATEGORY(__first, _InputIter),
|
||||
_STLP_DISTANCE_TYPE(__first, _InputIter));
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _InputIter, class _OutputIter>
|
||||
inline _OutputIter copy(_InputIter __first, _InputIter __last, _OutputIter __result) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
return _STLP_PRIV __copy_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter>::_Answer());
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _InputIter, class _OutputIter>
|
||||
inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result, const __false_type& /*TrivialAssignment*/) {
|
||||
return _STLP_PRIV __copy_backward(__first, __last, __result,
|
||||
_STLP_ITERATOR_CATEGORY(__first, _InputIter),
|
||||
_STLP_DISTANCE_TYPE(__first, _InputIter));
|
||||
}
|
||||
template <class _InputIter, class _OutputIter>
|
||||
inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last,
|
||||
_OutputIter __result, const __true_type& /*TrivialAssignment*/) {
|
||||
return (_OutputIter)_STLP_PRIV __copy_trivial_backward(__first, __last, __result);
|
||||
}
|
||||
|
||||
template <class _InputIter, class _OutputIter>
|
||||
inline _OutputIter __copy_backward_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type&) {
|
||||
return _STLP_PRIV __copy_backward(__first, __last, __result,
|
||||
_STLP_ITERATOR_CATEGORY(__first,_InputIter),
|
||||
_STLP_DISTANCE_TYPE(__first, _InputIter));
|
||||
}
|
||||
|
||||
template <class _InputIter, class _OutputIter>
|
||||
inline _OutputIter __copy_backward_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) {
|
||||
return _STLP_PRIV __copy_backward_ptrs(__first, __last, __result,
|
||||
_UseTrivialCopy(_STLP_VALUE_TYPE(__first, _InputIter),
|
||||
_STLP_VALUE_TYPE(__result, _OutputIter))._Answer());
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _InputIter, class _OutputIter>
|
||||
inline _OutputIter copy_backward(_InputIter __first, _InputIter __last, _OutputIter __result) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
return _STLP_PRIV __copy_backward_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter>::_Answer() );
|
||||
}
|
||||
|
||||
#if !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS)
|
||||
# define _STLP_DECLARE_COPY_TRIVIAL(_Tp) \
|
||||
inline _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) \
|
||||
{ return (_Tp*)_STLP_PRIV __copy_trivial(__first, __last, __result); } \
|
||||
inline _Tp* copy_backward(const _Tp* __first, const _Tp* __last, _Tp* __result) \
|
||||
{ return (_Tp*)_STLP_PRIV __copy_trivial_backward(__first, __last, __result); }
|
||||
|
||||
# if !defined (_STLP_NO_BOOL)
|
||||
_STLP_DECLARE_COPY_TRIVIAL(bool)
|
||||
# endif
|
||||
_STLP_DECLARE_COPY_TRIVIAL(char)
|
||||
# if !defined (_STLP_NO_SIGNED_BUILTINS)
|
||||
_STLP_DECLARE_COPY_TRIVIAL(signed char)
|
||||
# endif
|
||||
_STLP_DECLARE_COPY_TRIVIAL(unsigned char)
|
||||
_STLP_DECLARE_COPY_TRIVIAL(short)
|
||||
_STLP_DECLARE_COPY_TRIVIAL(unsigned short)
|
||||
_STLP_DECLARE_COPY_TRIVIAL(int)
|
||||
_STLP_DECLARE_COPY_TRIVIAL(unsigned int)
|
||||
_STLP_DECLARE_COPY_TRIVIAL(long)
|
||||
_STLP_DECLARE_COPY_TRIVIAL(unsigned long)
|
||||
# if !defined(_STLP_NO_WCHAR_T) && !defined (_STLP_WCHAR_T_IS_USHORT)
|
||||
_STLP_DECLARE_COPY_TRIVIAL(wchar_t)
|
||||
# endif
|
||||
# if defined (_STLP_LONG_LONG)
|
||||
_STLP_DECLARE_COPY_TRIVIAL(_STLP_LONG_LONG)
|
||||
_STLP_DECLARE_COPY_TRIVIAL(unsigned _STLP_LONG_LONG)
|
||||
# endif
|
||||
_STLP_DECLARE_COPY_TRIVIAL(float)
|
||||
_STLP_DECLARE_COPY_TRIVIAL(double)
|
||||
# if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
_STLP_DECLARE_COPY_TRIVIAL(long double)
|
||||
# endif
|
||||
# undef _STLP_DECLARE_COPY_TRIVIAL
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------
|
||||
// copy_n (not part of the C++ standard)
|
||||
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _InputIter, class _Size, class _OutputIter>
|
||||
_STLP_INLINE_LOOP _STLP_STD::pair<_InputIter, _OutputIter>
|
||||
__copy_n(_InputIter __first, _Size __count, _OutputIter __result,
|
||||
const input_iterator_tag &) {
|
||||
for ( ; __count > 0; --__count) {
|
||||
*__result = *__first;
|
||||
++__first;
|
||||
++__result;
|
||||
}
|
||||
return _STLP_STD::pair<_InputIter, _OutputIter>(__first, __result);
|
||||
}
|
||||
|
||||
template <class _RAIter, class _Size, class _OutputIter>
|
||||
inline _STLP_STD::pair<_RAIter, _OutputIter>
|
||||
__copy_n(_RAIter __first, _Size __count, _OutputIter __result,
|
||||
const random_access_iterator_tag &) {
|
||||
_RAIter __last = __first + __count;
|
||||
return _STLP_STD::pair<_RAIter, _OutputIter>(__last, _STLP_STD::copy(__first, __last, __result));
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _InputIter, class _Size, class _OutputIter>
|
||||
inline pair<_InputIter, _OutputIter>
|
||||
copy_n(_InputIter __first, _Size __count, _OutputIter __result) {
|
||||
_STLP_FIX_LITERAL_BUG(__first)
|
||||
return _STLP_PRIV __copy_n(__first, __count, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter));
|
||||
}
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------
|
||||
// fill and fill_n
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _ForwardIter, class _Tp>
|
||||
_STLP_INLINE_LOOP
|
||||
void __fill_fwd(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) {
|
||||
for ( ; __first != __last; ++__first)
|
||||
*__first = __val;
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _Tp, class _Distance>
|
||||
inline void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,
|
||||
const input_iterator_tag &, _Distance*) {
|
||||
_STLP_PRIV __fill_fwd(__first, __last, __val);
|
||||
}
|
||||
|
||||
#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
|
||||
template <class _ForwardIter, class _Tp, class _Distance>
|
||||
_STLP_INLINE_LOOP
|
||||
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,
|
||||
const forward_iterator_tag &, _Distance*) {
|
||||
_STLP_PRIV __fill_fwd(__first, __last, __val);
|
||||
}
|
||||
|
||||
template <class _ForwardIter, class _Tp, class _Distance>
|
||||
_STLP_INLINE_LOOP
|
||||
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val,
|
||||
const bidirectional_iterator_tag &, _Distance*) {
|
||||
_STLP_PRIV __fill_fwd(__first, __last, __val);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _RandomAccessIter, class _Tp, class _Distance>
|
||||
_STLP_INLINE_LOOP
|
||||
void __fill(_RandomAccessIter __first, _RandomAccessIter __last, const _Tp& __val,
|
||||
const random_access_iterator_tag &, _Distance*) {
|
||||
for (_Distance __n = __last - __first ; __n > 0; ++__first, --__n)
|
||||
*__first = __val;
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _ForwardIter, class _Tp>
|
||||
inline void fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_STLP_PRIV __fill(__first, __last, __val,
|
||||
_STLP_ITERATOR_CATEGORY(__first, _ForwardIter),
|
||||
_STLP_DISTANCE_TYPE(__first, _ForwardIter));
|
||||
}
|
||||
|
||||
// Specialization: for one-byte types we can use memset.
|
||||
inline void fill(unsigned char* __first, unsigned char* __last,
|
||||
const unsigned char& __val) {
|
||||
unsigned char __tmp = __val;
|
||||
memset(__first, __tmp, __last - __first);
|
||||
}
|
||||
#if !defined (_STLP_NO_SIGNED_BUILTINS)
|
||||
inline void fill(signed char* __first, signed char* __last,
|
||||
const signed char& __val) {
|
||||
signed char __tmp = __val;
|
||||
memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first);
|
||||
}
|
||||
#endif
|
||||
inline void fill(char* __first, char* __last, const char& __val) {
|
||||
char __tmp = __val;
|
||||
memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first);
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _OutputIter, class _Size, class _Tp>
|
||||
_STLP_INLINE_LOOP
|
||||
_OutputIter __fill_n(_OutputIter __first, _Size __n, const _Tp& __val) {
|
||||
_STLP_FIX_LITERAL_BUG(__first)
|
||||
for ( ; __n > 0; --__n, ++__first)
|
||||
*__first = __val;
|
||||
return __first;
|
||||
}
|
||||
|
||||
#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
template <class _Size>
|
||||
inline unsigned char* __fill_n(unsigned char* __first, _Size __n,
|
||||
const unsigned char& __val) {
|
||||
_STLP_STD::fill(__first, __first + __n, __val);
|
||||
return __first + __n;
|
||||
}
|
||||
#if !defined (_STLP_NO_SIGNED_BUILTINS)
|
||||
template <class _Size>
|
||||
inline signed char* __fill_n(signed char* __first, _Size __n,
|
||||
const signed char& __val) {
|
||||
_STLP_STD::fill(__first, __first + __n, __val);
|
||||
return __first + __n;
|
||||
}
|
||||
#endif
|
||||
template <class _Size>
|
||||
inline char* __fill_n(char* __first, _Size __n,
|
||||
const char& __val) {
|
||||
_STLP_STD::fill(__first, __first + __n, __val);
|
||||
return __first + __n;
|
||||
}
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _OutputIter, class _Size, class _Tp>
|
||||
inline void fill_n(_OutputIter __first, _Size __n, const _Tp& __val) {
|
||||
_STLP_FIX_LITERAL_BUG(__first)
|
||||
_STLP_PRIV __fill_n(__first, __n, __val);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// equal and mismatch
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
_STLP_INLINE_LOOP
|
||||
_STLP_STD::pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,
|
||||
_InputIter1 __last1,
|
||||
_InputIter2 __first2) {
|
||||
_STLP_FIX_LITERAL_BUG(__first2)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
while (__first1 != __last1 && *__first1 == *__first2) {
|
||||
++__first1;
|
||||
++__first2;
|
||||
}
|
||||
return _STLP_STD::pair<_InputIter1, _InputIter2>(__first1, __first2);
|
||||
}
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _BinaryPredicate>
|
||||
_STLP_INLINE_LOOP
|
||||
_STLP_STD::pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1,
|
||||
_InputIter1 __last1,
|
||||
_InputIter2 __first2,
|
||||
_BinaryPredicate __binary_pred) {
|
||||
_STLP_FIX_LITERAL_BUG(__first2)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) {
|
||||
++__first1;
|
||||
++__first2;
|
||||
}
|
||||
return _STLP_STD::pair<_InputIter1, _InputIter2>(__first1, __first2);
|
||||
}
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
_STLP_INLINE_LOOP
|
||||
bool equal(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2) {
|
||||
_STLP_FIX_LITERAL_BUG(__first1) _STLP_FIX_LITERAL_BUG(__last1) _STLP_FIX_LITERAL_BUG(__first2)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
for ( ; __first1 != __last1; ++__first1, ++__first2)
|
||||
if (!(*__first1 == *__first2))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _BinaryPredicate>
|
||||
_STLP_INLINE_LOOP
|
||||
bool equal(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _BinaryPredicate __binary_pred) {
|
||||
_STLP_FIX_LITERAL_BUG(__first2)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
for ( ; __first1 != __last1; ++__first1, ++__first2)
|
||||
if (!__binary_pred(*__first1, *__first2))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// lexicographical_compare and lexicographical_compare_3way.
|
||||
// (the latter is not part of the C++ standard.)
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2);
|
||||
|
||||
template <class _InputIter1, class _InputIter2, class _Compare>
|
||||
bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2,
|
||||
_Compare __comp);
|
||||
|
||||
inline bool
|
||||
lexicographical_compare(const unsigned char* __first1,
|
||||
const unsigned char* __last1,
|
||||
const unsigned char* __first2,
|
||||
const unsigned char* __last2) {
|
||||
const size_t __len1 = __last1 - __first1;
|
||||
const size_t __len2 = __last2 - __first2;
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
|
||||
|
||||
const int __result = memcmp(__first1, __first2, (min) (__len1, __len2));
|
||||
return __result != 0 ? (__result < 0) : (__len1 < __len2);
|
||||
}
|
||||
|
||||
|
||||
#if !(CHAR_MAX == SCHAR_MAX)
|
||||
inline bool lexicographical_compare(const char* __first1, const char* __last1,
|
||||
const char* __first2, const char* __last2) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2))
|
||||
|
||||
return lexicographical_compare((const unsigned char*) __first1,
|
||||
(const unsigned char*) __last1,
|
||||
(const unsigned char*) __first2,
|
||||
(const unsigned char*) __last2);
|
||||
}
|
||||
#endif /* CHAR_MAX == SCHAR_MAX */
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2);
|
||||
|
||||
inline int
|
||||
__lexicographical_compare_3way(const unsigned char* __first1,
|
||||
const unsigned char* __last1,
|
||||
const unsigned char* __first2,
|
||||
const unsigned char* __last2) {
|
||||
const ptrdiff_t __len1 = __last1 - __first1;
|
||||
const ptrdiff_t __len2 = __last2 - __first2;
|
||||
const int __result = memcmp(__first1, __first2, (min) (__len1, __len2));
|
||||
return __result != 0 ? __result
|
||||
: (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));
|
||||
}
|
||||
|
||||
|
||||
#if !(CHAR_MAX == SCHAR_MAX)
|
||||
inline int
|
||||
__lexicographical_compare_3way(const char* __first1, const char* __last1,
|
||||
const char* __first2, const char* __last2) {
|
||||
return __lexicographical_compare_3way((const unsigned char*) __first1,
|
||||
(const unsigned char*) __last1,
|
||||
(const unsigned char*) __first2,
|
||||
(const unsigned char*) __last2);
|
||||
}
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
template <class _InputIter1, class _InputIter2>
|
||||
int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,
|
||||
_InputIter2 __first2, _InputIter2 __last2);
|
||||
|
||||
#endif
|
||||
|
||||
// count
|
||||
template <class _InputIter, class _Tp>
|
||||
_STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_InputIter)
|
||||
count(_InputIter __first, _InputIter __last, const _Tp& __val) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_STLP_DIFFERENCE_TYPE(_InputIter) __n = 0;
|
||||
for ( ; __first != __last; ++__first)
|
||||
if (*__first == __val)
|
||||
++__n;
|
||||
return __n;
|
||||
}
|
||||
|
||||
// find and find_if. Note find may be expressed in terms of find_if if appropriate binder was available.
|
||||
template <class _InputIter, class _Tp>
|
||||
_InputIter find(_InputIter __first, _InputIter __last, const _Tp& __val);
|
||||
|
||||
template <class _InputIter, class _Predicate>
|
||||
_InputIter find_if(_InputIter __first, _InputIter __last, _Predicate __pred);
|
||||
|
||||
// search.
|
||||
template <class _ForwardIter1, class _ForwardIter2, class _BinaryPred>
|
||||
_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1,
|
||||
_ForwardIter2 __first2, _ForwardIter2 __last2, _BinaryPred __predicate);
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
// find_first_of
|
||||
template <class _InputIter, class _ForwardIter>
|
||||
_InputIter __find_first_of(_InputIter __first1, _InputIter __last1,
|
||||
_ForwardIter __first2, _ForwardIter __last2);
|
||||
|
||||
template <class _InputIter, class _ForwardIter, class _BinaryPredicate>
|
||||
_InputIter __find_first_of(_InputIter __first1, _InputIter __last1,
|
||||
_ForwardIter __first2, _ForwardIter __last2,
|
||||
_BinaryPredicate __comp);
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _ForwardIter1, class _ForwardIter2,
|
||||
class _BinaryPredicate>
|
||||
_ForwardIter1
|
||||
find_end(_ForwardIter1 __first1, _ForwardIter1 __last1,
|
||||
_ForwardIter2 __first2, _ForwardIter2 __last2,
|
||||
_BinaryPredicate __comp);
|
||||
|
||||
// replace
|
||||
template <class _ForwardIter, class _Tp>
|
||||
_STLP_INLINE_LOOP void
|
||||
replace(_ForwardIter __first, _ForwardIter __last,
|
||||
const _Tp& __old_value, const _Tp& __new_value) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
for ( ; __first != __last; ++__first)
|
||||
if (*__first == __old_value)
|
||||
*__first = __new_value;
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _ForwardIter, class _Tp, class _Compare1, class _Compare2, class _Distance>
|
||||
_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last,
|
||||
const _Tp& __val, _Compare1 __comp1, _Compare2 __comp2, _Distance*);
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_algobase.c>
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_ALGOBASE_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
87
extern/STLport/5.2.1/stlport/stl/_alloc.c
vendored
Normal file
87
extern/STLport/5.2.1/stlport/stl/_alloc.c
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_ALLOC_C
|
||||
#define _STLP_ALLOC_C
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALLOC_H
|
||||
# include <stl/_alloc.h>
|
||||
#endif
|
||||
|
||||
#if defined (__WATCOMC__)
|
||||
# pragma warning 13 9
|
||||
# pragma warning 367 9
|
||||
# pragma warning 368 9
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _Alloc>
|
||||
void * _STLP_CALL __debug_alloc<_Alloc>::allocate(size_t __n) {
|
||||
size_t __total_extra = __extra_before_chunk() + __extra_after_chunk();
|
||||
size_t __real_n = __n + __total_extra;
|
||||
if (__real_n < __n) {
|
||||
//It means that we rolled on size_t, __n must be very large:
|
||||
_STLP_THROW_BAD_ALLOC;
|
||||
}
|
||||
__alloc_header *__result = (__alloc_header *)__allocator_type::allocate(__real_n);
|
||||
memset((char*)__result, __shred_byte, __real_n * sizeof(value_type));
|
||||
__result->__magic = __magic;
|
||||
__result->__type_size = sizeof(value_type);
|
||||
__result->_M_size = (_STLP_UINT32_T)__n;
|
||||
return ((char*)__result) + (long)__extra_before;
|
||||
}
|
||||
|
||||
template <class _Alloc>
|
||||
void _STLP_CALL
|
||||
__debug_alloc<_Alloc>::deallocate(void *__p, size_t __n) {
|
||||
__alloc_header * __real_p = (__alloc_header*)((char *)__p -(long)__extra_before);
|
||||
// check integrity
|
||||
_STLP_VERBOSE_ASSERT(__real_p->__magic != __deleted_magic, _StlMsg_DBA_DELETED_TWICE)
|
||||
_STLP_VERBOSE_ASSERT(__real_p->__magic == __magic, _StlMsg_DBA_NEVER_ALLOCATED)
|
||||
_STLP_VERBOSE_ASSERT(__real_p->__type_size == 1,_StlMsg_DBA_TYPE_MISMATCH)
|
||||
_STLP_VERBOSE_ASSERT(__real_p->_M_size == __n, _StlMsg_DBA_SIZE_MISMATCH)
|
||||
// check pads on both sides
|
||||
unsigned char* __tmp;
|
||||
for (__tmp = (unsigned char*)(__real_p + 1); __tmp < (unsigned char*)__p; ++__tmp) {
|
||||
_STLP_VERBOSE_ASSERT(*__tmp == __shred_byte, _StlMsg_DBA_UNDERRUN)
|
||||
}
|
||||
|
||||
size_t __real_n = __n + __extra_before_chunk() + __extra_after_chunk();
|
||||
|
||||
for (__tmp= ((unsigned char*)__p) + __n * sizeof(value_type);
|
||||
__tmp < ((unsigned char*)__real_p) + __real_n ; ++__tmp) {
|
||||
_STLP_VERBOSE_ASSERT(*__tmp == __shred_byte, _StlMsg_DBA_OVERRUN)
|
||||
}
|
||||
|
||||
// that may be unfortunate, just in case
|
||||
__real_p->__magic = __deleted_magic;
|
||||
memset((char*)__p, __shred_byte, __n * sizeof(value_type));
|
||||
__allocator_type::deallocate(__real_p, __real_n);
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_ALLOC_C */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
580
extern/STLport/5.2.1/stlport/stl/_alloc.h
vendored
Normal file
580
extern/STLport/5.2.1/stlport/stl/_alloc.h
vendored
Normal file
@@ -0,0 +1,580 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALLOC_H
|
||||
#define _STLP_INTERNAL_ALLOC_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSTDDEF
|
||||
# include <stl/_cstddef.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSTDLIB
|
||||
# include <stl/_cstdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSTRING
|
||||
# include <stl/_cstring.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALGOBASE_H
|
||||
# include <stl/_algobase.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_NEW_HEADER
|
||||
# include <stl/_new.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_CONSTRUCT_H
|
||||
# include <stl/_construct.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
// Malloc-based allocator. Typically slower than default alloc below.
|
||||
// Typically thread-safe and more storage efficient.
|
||||
|
||||
#if !defined (_STLP_USE_NO_IOSTREAMS)
|
||||
typedef void (* __oom_handler_type)();
|
||||
#endif
|
||||
|
||||
class _STLP_CLASS_DECLSPEC __malloc_alloc {
|
||||
public:
|
||||
// this one is needed for proper simple_alloc wrapping
|
||||
typedef char value_type;
|
||||
static void* _STLP_CALL allocate(size_t __n)
|
||||
#if !defined (_STLP_USE_NO_IOSTREAMS)
|
||||
;
|
||||
#else
|
||||
{
|
||||
void *__result = malloc(__n);
|
||||
if (__result == 0) {
|
||||
_STLP_THROW_BAD_ALLOC;
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void _STLP_CALL deallocate(void* __p, size_t /* __n */) { free((char*)__p); }
|
||||
#if !defined (_STLP_USE_NO_IOSTREAMS)
|
||||
static __oom_handler_type _STLP_CALL set_malloc_handler(__oom_handler_type __f);
|
||||
#endif
|
||||
};
|
||||
|
||||
// New-based allocator. Typically slower than default alloc below.
|
||||
// Typically thread-safe and more storage efficient.
|
||||
class _STLP_CLASS_DECLSPEC __new_alloc {
|
||||
public:
|
||||
// this one is needed for proper simple_alloc wrapping
|
||||
typedef char value_type;
|
||||
static void* _STLP_CALL allocate(size_t __n) { return __stl_new(__n); }
|
||||
static void _STLP_CALL deallocate(void* __p, size_t) { __stl_delete(__p); }
|
||||
};
|
||||
|
||||
// Allocator adaptor to check size arguments for debugging.
|
||||
// Reports errors using assert. Checking can be disabled with
|
||||
// NDEBUG, but it's far better to just use the underlying allocator
|
||||
// instead when no checking is desired.
|
||||
// There is some evidence that this can confuse Purify.
|
||||
// This adaptor can only be applied to raw allocators
|
||||
|
||||
template <class _Alloc>
|
||||
class __debug_alloc : public _Alloc {
|
||||
public:
|
||||
typedef _Alloc __allocator_type;
|
||||
typedef typename _Alloc::value_type value_type;
|
||||
private:
|
||||
struct __alloc_header {
|
||||
size_t __magic: 16;
|
||||
size_t __type_size:16;
|
||||
_STLP_UINT32_T _M_size;
|
||||
}; // that is 8 bytes for sure
|
||||
// Sunpro CC has bug on enums, so extra_before/after set explicitly
|
||||
enum { __pad = 8, __magic = 0xdeba, __deleted_magic = 0xdebd,
|
||||
__shred_byte = _STLP_SHRED_BYTE };
|
||||
|
||||
enum { __extra_before = 16, __extra_after = 8 };
|
||||
// Size of space used to store size. Note
|
||||
// that this must be large enough to preserve
|
||||
// alignment.
|
||||
static size_t _STLP_CALL __extra_before_chunk() {
|
||||
return (long)__extra_before / sizeof(value_type) +
|
||||
(size_t)((long)__extra_before % sizeof(value_type) > 0);
|
||||
}
|
||||
static size_t _STLP_CALL __extra_after_chunk() {
|
||||
return (long)__extra_after / sizeof(value_type) +
|
||||
(size_t)((long)__extra_after % sizeof(value_type) > 0);
|
||||
}
|
||||
public:
|
||||
__debug_alloc() {}
|
||||
~__debug_alloc() {}
|
||||
static void* _STLP_CALL allocate(size_t);
|
||||
static void _STLP_CALL deallocate(void *, size_t);
|
||||
};
|
||||
|
||||
# if defined (__OS400__)
|
||||
// dums 02/05/2007: is it really necessary ?
|
||||
enum { _MAX_BYTES = 256 };
|
||||
# else
|
||||
enum { _MAX_BYTES = 32 * sizeof(void*) };
|
||||
# endif
|
||||
|
||||
#if !defined (_STLP_USE_NO_IOSTREAMS)
|
||||
// Default node allocator.
|
||||
// With a reasonable compiler, this should be roughly as fast as the
|
||||
// original STL class-specific allocators, but with less fragmentation.
|
||||
class _STLP_CLASS_DECLSPEC __node_alloc {
|
||||
static void * _STLP_CALL _M_allocate(size_t& __n);
|
||||
/* __p may not be 0 */
|
||||
static void _STLP_CALL _M_deallocate(void *__p, size_t __n);
|
||||
|
||||
public:
|
||||
// this one is needed for proper simple_alloc wrapping
|
||||
typedef char value_type;
|
||||
/* __n must be > 0 */
|
||||
static void* _STLP_CALL allocate(size_t& __n)
|
||||
{ return (__n > (size_t)_MAX_BYTES) ? __stl_new(__n) : _M_allocate(__n); }
|
||||
/* __p may not be 0 */
|
||||
static void _STLP_CALL deallocate(void *__p, size_t __n)
|
||||
{ if (__n > (size_t)_MAX_BYTES) __stl_delete(__p); else _M_deallocate(__p, __n); }
|
||||
};
|
||||
|
||||
# if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__node_alloc>;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__new_alloc>;
|
||||
_STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__malloc_alloc>;
|
||||
#endif
|
||||
|
||||
/* macro to convert the allocator for initialization
|
||||
* not using MEMBER_TEMPLATE_CLASSES as it should work given template constructor */
|
||||
#if defined (_STLP_MEMBER_TEMPLATES) || ! defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
/* if _STLP_NO_TEMPLATE_CONVERSIONS is set, the member template constructor is
|
||||
* not used implicitly to convert allocator parameter, so let us do it explicitly */
|
||||
# if defined (_STLP_MEMBER_TEMPLATE_CLASSES) && defined (_STLP_NO_TEMPLATE_CONVERSIONS)
|
||||
# define _STLP_CONVERT_ALLOCATOR(__a, _Tp) __stl_alloc_create(__a,(_Tp*)0)
|
||||
# else
|
||||
# define _STLP_CONVERT_ALLOCATOR(__a, _Tp) __a
|
||||
# endif
|
||||
/* else convert, but only if partial specialization works, since else
|
||||
* Container::allocator_type won't be different */
|
||||
#else
|
||||
# define _STLP_CONVERT_ALLOCATOR(__a, _Tp) __stl_alloc_create(__a,(_Tp*)0)
|
||||
#endif
|
||||
|
||||
// Another allocator adaptor: _Alloc_traits. This serves two
|
||||
// purposes. First, make it possible to write containers that can use
|
||||
// either SGI-style allocators or standard-conforming allocator.
|
||||
|
||||
// The fully general version.
|
||||
template <class _Tp, class _Allocator>
|
||||
struct _Alloc_traits {
|
||||
typedef _Allocator _Orig;
|
||||
#if !defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE)
|
||||
typedef typename _Allocator::_STLP_TEMPLATE rebind<_Tp> _Rebind_type;
|
||||
typedef typename _Rebind_type::other allocator_type;
|
||||
static allocator_type create_allocator(const _Orig& __a)
|
||||
{ return allocator_type(_STLP_CONVERT_ALLOCATOR(__a, _Tp)); }
|
||||
#else
|
||||
// this is not actually true, used only to pass this type through
|
||||
// to dynamic overload selection in _STLP_alloc_proxy methods
|
||||
typedef _Allocator allocator_type;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined (_STLP_USE_PERTHREAD_ALLOC)
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
// include additional header here
|
||||
# include <stl/_pthread_alloc.h>
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
typedef __pthread_alloc __alloc_type;
|
||||
#elif defined (_STLP_USE_NEWALLOC)
|
||||
typedef __new_alloc __alloc_type;
|
||||
#elif defined (_STLP_USE_MALLOC)
|
||||
typedef __malloc_alloc __alloc_type;
|
||||
#else
|
||||
typedef __node_alloc __alloc_type;
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_DEBUG_ALLOC)
|
||||
typedef __debug_alloc<__alloc_type> __sgi_alloc;
|
||||
#else
|
||||
typedef __alloc_type __sgi_alloc;
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_NO_ANACHRONISMS)
|
||||
typedef __sgi_alloc __single_client_alloc;
|
||||
typedef __sgi_alloc __multithreaded_alloc;
|
||||
#endif
|
||||
|
||||
// This implements allocators as specified in the C++ standard.
|
||||
//
|
||||
// Note that standard-conforming allocators use many language features
|
||||
// that are not yet widely implemented. In particular, they rely on
|
||||
// member templates, partial specialization, partial ordering of function
|
||||
// templates, the typename keyword, and the use of the template keyword
|
||||
// to refer to a template member of a dependent type.
|
||||
|
||||
/*
|
||||
template <class _Tp>
|
||||
struct _AllocatorAux {
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
|
||||
pointer address(reference __x) const {return &__x;}
|
||||
const_pointer address(const_reference __x) const { return &__x; }
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct _AllocatorAux<const _Tp> {
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
|
||||
const_pointer address(const_reference __x) const { return &__x; }
|
||||
};
|
||||
*/
|
||||
|
||||
template <class _Tp>
|
||||
class allocator //: public _AllocatorAux<_Tp>
|
||||
/* A small helper struct to recognize STLport allocator implementation
|
||||
* from any user specialization one.
|
||||
*/
|
||||
: public __stlport_class<allocator<_Tp> >
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
#if defined (_STLP_MEMBER_TEMPLATE_CLASSES)
|
||||
template <class _Tp1> struct rebind {
|
||||
typedef allocator<_Tp1> other;
|
||||
};
|
||||
#endif
|
||||
allocator() _STLP_NOTHROW {}
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _Tp1> allocator(const allocator<_Tp1>&) _STLP_NOTHROW {}
|
||||
#endif
|
||||
allocator(const allocator<_Tp>&) _STLP_NOTHROW {}
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
allocator(__move_source<allocator<_Tp> > src) _STLP_NOTHROW {}
|
||||
#endif
|
||||
~allocator() _STLP_NOTHROW {}
|
||||
pointer address(reference __x) const {return &__x;}
|
||||
const_pointer address(const_reference __x) const { return &__x; }
|
||||
// __n is permitted to be 0. The C++ standard says nothing about what the return value is when __n == 0.
|
||||
_Tp* allocate(size_type __n, const void* = 0) {
|
||||
if (__n > max_size()) {
|
||||
_STLP_THROW_BAD_ALLOC;
|
||||
}
|
||||
if (__n != 0) {
|
||||
size_type __buf_size = __n * sizeof(value_type);
|
||||
_Tp* __ret = __REINTERPRET_CAST(_Tp*, __sgi_alloc::allocate(__buf_size));
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC)
|
||||
memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size);
|
||||
#endif
|
||||
return __ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// __p is permitted to be a null pointer, only if n==0.
|
||||
void deallocate(pointer __p, size_type __n) {
|
||||
_STLP_ASSERT( (__p == 0) == (__n == 0) )
|
||||
if (__p != 0) {
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC)
|
||||
memset((char*)__p, _STLP_SHRED_BYTE, __n * sizeof(value_type));
|
||||
#endif
|
||||
__sgi_alloc::deallocate((void*)__p, __n * sizeof(value_type));
|
||||
}
|
||||
}
|
||||
#if !defined (_STLP_NO_ANACHRONISMS)
|
||||
// backwards compatibility
|
||||
void deallocate(pointer __p) const { if (__p != 0) __sgi_alloc::deallocate((void*)__p, sizeof(value_type)); }
|
||||
#endif
|
||||
size_type max_size() const _STLP_NOTHROW { return size_t(-1) / sizeof(value_type); }
|
||||
void construct(pointer __p, const_reference __val) { _STLP_STD::_Copy_Construct(__p, __val); }
|
||||
void destroy(pointer __p) { _STLP_STD::_Destroy(__p); }
|
||||
|
||||
#if defined (_STLP_NO_EXTENSIONS)
|
||||
/* STLport extension giving rounded size of an allocated memory buffer
|
||||
* This method do not have to be part of a user defined allocator implementation
|
||||
* and won't even be called if such a function was granted.
|
||||
*/
|
||||
protected:
|
||||
#endif
|
||||
_Tp* _M_allocate(size_type __n, size_type& __allocated_n) {
|
||||
if (__n > max_size()) {
|
||||
_STLP_THROW_BAD_ALLOC;
|
||||
}
|
||||
|
||||
if (__n != 0) {
|
||||
size_type __buf_size = __n * sizeof(value_type);
|
||||
_Tp* __ret = __REINTERPRET_CAST(_Tp*, __sgi_alloc::allocate(__buf_size));
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC)
|
||||
memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size);
|
||||
#endif
|
||||
__allocated_n = __buf_size / sizeof(value_type);
|
||||
return __ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(allocator<_Tp>& __other) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC allocator<void> {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef void* pointer;
|
||||
typedef const void* const_pointer;
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
typedef void value_type;
|
||||
#endif
|
||||
#if defined (_STLP_MEMBER_TEMPLATE_CLASSES)
|
||||
template <class _Tp1> struct rebind {
|
||||
typedef allocator<_Tp1> other;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline bool _STLP_CALL operator==(const allocator<_T1>&, const allocator<_T2>&) _STLP_NOTHROW
|
||||
{ return true; }
|
||||
template <class _T1, class _T2>
|
||||
inline bool _STLP_CALL operator!=(const allocator<_T1>&, const allocator<_T2>&) _STLP_NOTHROW
|
||||
{ return false; }
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS allocator<char>;
|
||||
# if defined (_STLP_HAS_WCHAR_T)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS allocator<wchar_t>;
|
||||
# endif
|
||||
# if defined (_STLP_USE_PTR_SPECIALIZATIONS)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS allocator<void*>;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Tp>
|
||||
struct __alloc_type_traits {
|
||||
#if !defined (__BORLANDC__)
|
||||
typedef typename _IsSTLportClass<allocator<_Tp> >::_Ret _STLportAlloc;
|
||||
#else
|
||||
enum { _Is = _IsSTLportClass<allocator<_Tp> >::_Is };
|
||||
typedef typename __bool2type<_Is>::_Ret _STLportAlloc;
|
||||
#endif
|
||||
//The default allocator implementation which is recognize thanks to the
|
||||
//__stlport_class inheritance is a stateless object so:
|
||||
typedef _STLportAlloc has_trivial_default_constructor;
|
||||
typedef _STLportAlloc has_trivial_copy_constructor;
|
||||
typedef _STLportAlloc has_trivial_assignment_operator;
|
||||
typedef _STLportAlloc has_trivial_destructor;
|
||||
typedef _STLportAlloc is_POD_type;
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
template <class _Tp>
|
||||
struct __type_traits<allocator<_Tp> > : _STLP_PRIV __alloc_type_traits<_Tp> {};
|
||||
#else
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct __type_traits<allocator<char> > : _STLP_PRIV __alloc_type_traits<char> {};
|
||||
# if defined (_STLP_HAS_WCHAR_T)
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct __type_traits<allocator<wchar_t> > : _STLP_PRIV __alloc_type_traits<wchar_t> {};
|
||||
# endif
|
||||
# if defined (_STLP_USE_PTR_SPECIALIZATIONS)
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct __type_traits<allocator<void*> > : _STLP_PRIV __alloc_type_traits<void*> {};
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined (_STLP_FORCE_ALLOCATORS)
|
||||
# define _STLP_FORCE_ALLOCATORS(a,y)
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_MEMBER_TEMPLATE_CLASSES)
|
||||
// The version for the default allocator, for rare occasion when we have partial spec w/o member template classes
|
||||
template <class _Tp, class _Tp1>
|
||||
struct _Alloc_traits<_Tp, allocator<_Tp1> > {
|
||||
typedef allocator<_Tp1> _Orig;
|
||||
typedef allocator<_Tp> allocator_type;
|
||||
static allocator_type create_allocator(const allocator<_Tp1 >& __a)
|
||||
{ return allocator_type(_STLP_CONVERT_ALLOCATOR(__a, _Tp)); }
|
||||
};
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) && defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _STLP_TYPENAME_ON_RETURN_TYPE _Alloc_traits<_Tp, _Alloc>::allocator_type _STLP_CALL
|
||||
__stl_alloc_create(const _Alloc& __a, const _Tp*) {
|
||||
typedef typename _Alloc::_STLP_TEMPLATE rebind<_Tp>::other _Rebound_type;
|
||||
return _Rebound_type(__a);
|
||||
}
|
||||
#else
|
||||
// If custom allocators are being used without member template classes support :
|
||||
// user (on purpose) is forced to define rebind/get operations !!!
|
||||
template <class _Tp1, class _Tp2>
|
||||
inline allocator<_Tp2>& _STLP_CALL
|
||||
__stl_alloc_rebind(allocator<_Tp1>& __a, const _Tp2*) { return (allocator<_Tp2>&)(__a); }
|
||||
template <class _Tp1, class _Tp2>
|
||||
inline allocator<_Tp2> _STLP_CALL
|
||||
__stl_alloc_create(const allocator<_Tp1>&, const _Tp2*) { return allocator<_Tp2>(); }
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
// inheritance is being used for EBO optimization
|
||||
template <class _Value, class _Tp, class _MaybeReboundAlloc>
|
||||
class _STLP_alloc_proxy : public _MaybeReboundAlloc {
|
||||
private:
|
||||
typedef _MaybeReboundAlloc _Base;
|
||||
typedef typename _Base::size_type size_type;
|
||||
typedef _STLP_alloc_proxy<_Value, _Tp, _MaybeReboundAlloc> _Self;
|
||||
public:
|
||||
_Value _M_data;
|
||||
|
||||
_STLP_alloc_proxy (const _MaybeReboundAlloc& __a, _Value __p) :
|
||||
_MaybeReboundAlloc(__a), _M_data(__p) {}
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
_STLP_alloc_proxy (__move_source<_Self> src) :
|
||||
_Base(_STLP_PRIV _AsMoveSource(src.get()._M_base())),
|
||||
_M_data(_STLP_PRIV _AsMoveSource(src.get()._M_data)) {}
|
||||
|
||||
_Base& _M_base()
|
||||
{ return *this; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
/* Following are helper methods to detect stateless allocators and avoid
|
||||
* swap in this case. For some compilers (VC6) it is a workaround for a
|
||||
* compiler bug in the Empty Base class Optimization feature, for others
|
||||
* it is a small optimization or nothing if no EBO. */
|
||||
void _M_swap_alloc(_Self&, const __true_type& /*_IsStateless*/)
|
||||
{}
|
||||
|
||||
void _M_swap_alloc(_Self& __x, const __false_type& /*_IsStateless*/) {
|
||||
_MaybeReboundAlloc &__base_this = *this;
|
||||
_MaybeReboundAlloc &__base_x = __x;
|
||||
_STLP_STD::swap(__base_this, __base_x);
|
||||
}
|
||||
|
||||
public:
|
||||
void _M_swap_alloc(_Self& __x) {
|
||||
#if !defined (__BORLANDC__)
|
||||
typedef typename _IsStateless<_MaybeReboundAlloc>::_Ret _StatelessAlloc;
|
||||
#else
|
||||
typedef typename __bool2type<_IsStateless<_MaybeReboundAlloc>::_Is>::_Ret _StatelessAlloc;
|
||||
#endif
|
||||
_M_swap_alloc(__x, _StatelessAlloc());
|
||||
}
|
||||
|
||||
/* We need to define the following swap implementation for allocator with state
|
||||
* as those allocators might have implement a special swap function to correctly
|
||||
* move datas from an instance to the oher, _STLP_alloc_proxy should not break
|
||||
* this mecanism. */
|
||||
void swap(_Self& __x) {
|
||||
_M_swap_alloc(__x);
|
||||
_STLP_STD::swap(_M_data, __x._M_data);
|
||||
}
|
||||
|
||||
_Tp* allocate(size_type __n, size_type& __allocated_n) {
|
||||
#if !defined (__BORLANDC__)
|
||||
typedef typename _IsSTLportClass<_MaybeReboundAlloc>::_Ret _STLportAlloc;
|
||||
#else
|
||||
typedef typename __bool2type<_IsSTLportClass<_MaybeReboundAlloc>::_Is>::_Ret _STLportAlloc;
|
||||
#endif
|
||||
return allocate(__n, __allocated_n, _STLportAlloc());
|
||||
}
|
||||
|
||||
// Unified interface to perform allocate()/deallocate() with limited
|
||||
// language support
|
||||
#if defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE)
|
||||
// else it is rebound already, and allocate() member is accessible
|
||||
_Tp* allocate(size_type __n)
|
||||
{ return __stl_alloc_rebind(__STATIC_CAST(_Base&, *this), __STATIC_CAST(_Tp*, 0)).allocate(__n, 0); }
|
||||
void deallocate(_Tp* __p, size_type __n)
|
||||
{ __stl_alloc_rebind(__STATIC_CAST(_Base&, *this), __STATIC_CAST(_Tp*, 0)).deallocate(__p, __n); }
|
||||
private:
|
||||
_Tp* allocate(size_type __n, size_type& __allocated_n, const __true_type& /*STLport allocator*/)
|
||||
{ return __stl_alloc_rebind(__STATIC_CAST(_Base&, *this), __STATIC_CAST(_Tp*, 0))._M_allocate(__n, __allocated_n); }
|
||||
#else
|
||||
//Expose Standard allocate overload (using expression do not work for some compilers (Borland))
|
||||
_Tp* allocate(size_type __n)
|
||||
{ return _Base::allocate(__n); }
|
||||
private:
|
||||
_Tp* allocate(size_type __n, size_type& __allocated_n, const __true_type& /*STLport allocator*/)
|
||||
{ return _Base::_M_allocate(__n, __allocated_n); }
|
||||
#endif
|
||||
|
||||
_Tp* allocate(size_type __n, size_type& __allocated_n, const __false_type& /*STLport allocator*/)
|
||||
{ __allocated_n = __n; return allocate(__n); }
|
||||
};
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<char*, char, allocator<char> >;
|
||||
# if defined (_STLP_HAS_WCHAR_T)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<wchar_t*, wchar_t, allocator<wchar_t> >;
|
||||
# endif
|
||||
# if defined (_STLP_USE_PTR_SPECIALIZATIONS)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<void**, void*, allocator<void*> >;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_alloc.c>
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_ALLOC_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
133
extern/STLport/5.2.1/stlport/stl/_auto_ptr.h
vendored
Normal file
133
extern/STLport/5.2.1/stlport/stl/_auto_ptr.h
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (c) 1997-1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_AUTO_PTR_H
|
||||
#define _STLP_AUTO_PTR_H
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
// implementation primitive
|
||||
class __ptr_base {
|
||||
public:
|
||||
void* _M_p;
|
||||
void __set(const volatile void* p) { _M_p = __CONST_CAST(void*,p); }
|
||||
void __set(void* p) { _M_p = p; }
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
class auto_ptr_ref {
|
||||
public:
|
||||
__ptr_base& _M_r;
|
||||
_Tp* const _M_p;
|
||||
|
||||
auto_ptr_ref(__ptr_base& __r, _Tp* __p) : _M_r(__r), _M_p(__p) { }
|
||||
|
||||
_Tp* release() const { _M_r.__set(__STATIC_CAST(void*, 0)); return _M_p; }
|
||||
|
||||
private:
|
||||
//explicitely defined as private to avoid warnings:
|
||||
typedef auto_ptr_ref<_Tp> _Self;
|
||||
_Self& operator = (_Self const&);
|
||||
};
|
||||
|
||||
template<class _Tp>
|
||||
class auto_ptr : public __ptr_base {
|
||||
public:
|
||||
typedef _Tp element_type;
|
||||
typedef auto_ptr<_Tp> _Self;
|
||||
|
||||
_Tp* release() _STLP_NOTHROW {
|
||||
_Tp* __px = this->get();
|
||||
this->_M_p = 0;
|
||||
return __px;
|
||||
}
|
||||
|
||||
void reset(_Tp* __px = 0) _STLP_NOTHROW {
|
||||
_Tp* __pt = this->get();
|
||||
if (__px != __pt)
|
||||
delete __pt;
|
||||
this->__set(__px);
|
||||
}
|
||||
|
||||
_Tp* get() const _STLP_NOTHROW
|
||||
#if !defined (__GNUC__) || (__GNUC__ > 2)
|
||||
{ return __STATIC_CAST(_Tp*, _M_p); }
|
||||
#else
|
||||
{ return __REINTERPRET_CAST(_Tp*, _M_p); }
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_NO_ARROW_OPERATOR)
|
||||
_Tp* operator->() const _STLP_NOTHROW {
|
||||
_STLP_VERBOSE_ASSERT(get() != 0, _StlMsg_AUTO_PTR_NULL)
|
||||
return get();
|
||||
}
|
||||
#endif
|
||||
_Tp& operator*() const _STLP_NOTHROW {
|
||||
_STLP_VERBOSE_ASSERT(get() != 0, _StlMsg_AUTO_PTR_NULL)
|
||||
return *get();
|
||||
}
|
||||
|
||||
explicit auto_ptr(_Tp* __px = 0) _STLP_NOTHROW { this->__set(__px); }
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
# if !defined (_STLP_NO_TEMPLATE_CONVERSIONS)
|
||||
template<class _Tp1> auto_ptr(auto_ptr<_Tp1>& __r) _STLP_NOTHROW {
|
||||
_Tp* __conversionCheck = __r.release();
|
||||
this->__set(__conversionCheck);
|
||||
}
|
||||
# endif
|
||||
template<class _Tp1> auto_ptr<_Tp>& operator=(auto_ptr<_Tp1>& __r) _STLP_NOTHROW {
|
||||
_Tp* __conversionCheck = __r.release();
|
||||
reset(__conversionCheck);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
auto_ptr(_Self& __r) _STLP_NOTHROW { this->__set(__r.release()); }
|
||||
|
||||
_Self& operator=(_Self& __r) _STLP_NOTHROW {
|
||||
reset(__r.release());
|
||||
return *this;
|
||||
}
|
||||
|
||||
~auto_ptr() _STLP_NOTHROW { /* boris : reset(0) might be better */ delete this->get(); }
|
||||
|
||||
auto_ptr(auto_ptr_ref<_Tp> __r) _STLP_NOTHROW
|
||||
{ this->__set(__r.release()); }
|
||||
|
||||
_Self& operator=(auto_ptr_ref<_Tp> __r) _STLP_NOTHROW {
|
||||
reset(__r.release());
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(_STLP_MEMBER_TEMPLATES) && !defined(_STLP_NO_TEMPLATE_CONVERSIONS)
|
||||
template<class _Tp1> operator auto_ptr_ref<_Tp1>() _STLP_NOTHROW
|
||||
{ return auto_ptr_ref<_Tp1>(*this, this->get()); }
|
||||
template<class _Tp1> operator auto_ptr<_Tp1>() _STLP_NOTHROW
|
||||
{ return auto_ptr<_Tp1>(release()); }
|
||||
#else
|
||||
operator auto_ptr_ref<_Tp>() _STLP_NOTHROW
|
||||
{ return auto_ptr_ref<_Tp>(*this, this->get()); }
|
||||
#endif
|
||||
};
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_AUTO_PTR_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
235
extern/STLport/5.2.1/stlport/stl/_bitset.c
vendored
Normal file
235
extern/STLport/5.2.1/stlport/stl/_bitset.c
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
* Copyright (c) 1998
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_BITSET_C
|
||||
#define _STLP_BITSET_C
|
||||
|
||||
#ifndef _STLP_BITSET_H
|
||||
# include <stl/_bitset.h>
|
||||
#endif
|
||||
|
||||
#define __BITS_PER_WORD (CHAR_BIT * sizeof(unsigned long))
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
//
|
||||
// Definitions of non-inline functions from _Base_bitset.
|
||||
//
|
||||
template<size_t _Nw>
|
||||
void _Base_bitset<_Nw>::_M_do_left_shift(size_t __shift) {
|
||||
if (__shift != 0) {
|
||||
const size_t __wshift = __shift / __BITS_PER_WORD;
|
||||
const size_t __offset = __shift % __BITS_PER_WORD;
|
||||
|
||||
if (__offset == 0)
|
||||
for (size_t __n = _Nw - 1; __n >= __wshift; --__n)
|
||||
_M_w[__n] = _M_w[__n - __wshift];
|
||||
|
||||
else {
|
||||
const size_t __sub_offset = __BITS_PER_WORD - __offset;
|
||||
for (size_t __n = _Nw - 1; __n > __wshift; --__n)
|
||||
_M_w[__n] = (_M_w[__n - __wshift] << __offset) |
|
||||
(_M_w[__n - __wshift - 1] >> __sub_offset);
|
||||
_M_w[__wshift] = _M_w[0] << __offset;
|
||||
}
|
||||
|
||||
fill(_M_w + 0, _M_w + __wshift, __STATIC_CAST(_WordT,0));
|
||||
}
|
||||
}
|
||||
|
||||
template<size_t _Nw>
|
||||
void _Base_bitset<_Nw>::_M_do_right_shift(size_t __shift) {
|
||||
if (__shift != 0) {
|
||||
const size_t __wshift = __shift / __BITS_PER_WORD;
|
||||
const size_t __offset = __shift % __BITS_PER_WORD;
|
||||
const size_t __limit = _Nw - __wshift - 1;
|
||||
|
||||
if (__offset == 0)
|
||||
for (size_t __n = 0; __n <= __limit; ++__n)
|
||||
_M_w[__n] = _M_w[__n + __wshift];
|
||||
|
||||
else {
|
||||
const size_t __sub_offset = __BITS_PER_WORD - __offset;
|
||||
for (size_t __n = 0; __n < __limit; ++__n)
|
||||
_M_w[__n] = (_M_w[__n + __wshift] >> __offset) |
|
||||
(_M_w[__n + __wshift + 1] << __sub_offset);
|
||||
_M_w[__limit] = _M_w[_Nw-1] >> __offset;
|
||||
}
|
||||
|
||||
fill(_M_w + __limit + 1, _M_w + _Nw, __STATIC_CAST(_WordT,0));
|
||||
}
|
||||
}
|
||||
|
||||
template<size_t _Nw>
|
||||
unsigned long _Base_bitset<_Nw>::_M_do_to_ulong() const {
|
||||
for (size_t __i = 1; __i < _Nw; ++__i)
|
||||
if (_M_w[__i])
|
||||
__stl_throw_overflow_error("bitset");
|
||||
return _M_w[0];
|
||||
} // End _M_do_to_ulong
|
||||
|
||||
template<size_t _Nw>
|
||||
size_t _Base_bitset<_Nw>::_M_do_find_first(size_t __not_found) const {
|
||||
for ( size_t __i = 0; __i < _Nw; __i++ ) {
|
||||
_WordT __thisword = _M_w[__i];
|
||||
if ( __thisword != __STATIC_CAST(_WordT,0) ) {
|
||||
// find byte within word
|
||||
for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) {
|
||||
unsigned char __this_byte
|
||||
= __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0)));
|
||||
if ( __this_byte )
|
||||
return __i*__BITS_PER_WORD + __j*CHAR_BIT +
|
||||
_Bs_G::_S_first_one(__this_byte);
|
||||
|
||||
__thisword >>= CHAR_BIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
// not found, so return an indication of failure.
|
||||
return __not_found;
|
||||
}
|
||||
|
||||
template<size_t _Nw>
|
||||
size_t
|
||||
_Base_bitset<_Nw>::_M_do_find_next(size_t __prev,
|
||||
size_t __not_found) const {
|
||||
// make bound inclusive
|
||||
++__prev;
|
||||
|
||||
// check out of bounds
|
||||
if ( __prev >= _Nw * __BITS_PER_WORD )
|
||||
return __not_found;
|
||||
|
||||
// search first word
|
||||
size_t __i = _S_whichword(__prev);
|
||||
_WordT __thisword = _M_w[__i];
|
||||
|
||||
// mask off bits below bound
|
||||
__thisword &= (~__STATIC_CAST(_WordT,0)) << _S_whichbit(__prev);
|
||||
|
||||
if ( __thisword != __STATIC_CAST(_WordT,0) ) {
|
||||
// find byte within word
|
||||
// get first byte into place
|
||||
__thisword >>= _S_whichbyte(__prev) * CHAR_BIT;
|
||||
for ( size_t __j = _S_whichbyte(__prev); __j < sizeof(_WordT); ++__j ) {
|
||||
unsigned char __this_byte
|
||||
= __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0)));
|
||||
if ( __this_byte )
|
||||
return __i*__BITS_PER_WORD + __j*CHAR_BIT +
|
||||
_Bs_G::_S_first_one(__this_byte);
|
||||
|
||||
__thisword >>= CHAR_BIT;
|
||||
}
|
||||
}
|
||||
|
||||
// check subsequent words
|
||||
++__i;
|
||||
for ( ; __i < _Nw; ++__i ) {
|
||||
/* _WordT */ __thisword = _M_w[__i];
|
||||
if ( __thisword != __STATIC_CAST(_WordT,0) ) {
|
||||
// find byte within word
|
||||
for ( size_t __j = 0; __j < sizeof(_WordT); ++__j ) {
|
||||
unsigned char __this_byte
|
||||
= __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0)));
|
||||
if ( __this_byte )
|
||||
return __i*__BITS_PER_WORD + __j*CHAR_BIT +
|
||||
_Bs_G::_S_first_one(__this_byte);
|
||||
|
||||
__thisword >>= CHAR_BIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// not found, so return an indication of failure.
|
||||
return __not_found;
|
||||
} // end _M_do_find_next
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
#if !defined (_STLP_NON_TYPE_TMPL_PARAM_BUG)
|
||||
|
||||
# if !defined (_STLP_USE_NO_IOSTREAMS)
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#ifndef _STLP_STRING_IO_H
|
||||
# include <stl/_string_io.h> //includes _istream.h and _ostream.h
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _CharT, class _Traits, size_t _Nb>
|
||||
basic_istream<_CharT, _Traits>& _STLP_CALL
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x) {
|
||||
basic_string<_CharT, _Traits> __tmp;
|
||||
__tmp.reserve(_Nb);
|
||||
|
||||
// Skip whitespace
|
||||
typename basic_istream<_CharT, _Traits>::sentry __sentry(__is);
|
||||
if (__sentry) {
|
||||
basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf();
|
||||
for (size_t __i = 0; __i < _Nb; ++__i) {
|
||||
static typename _Traits::int_type __eof = _Traits::eof();
|
||||
|
||||
typename _Traits::int_type __c1 = __buf->sbumpc();
|
||||
if (_Traits::eq_int_type(__c1, __eof)) {
|
||||
__is.setstate(ios_base::eofbit);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
typename _Traits::char_type __c2 = _Traits::to_char_type(__c1);
|
||||
char __c = __is.narrow(__c2, '*');
|
||||
|
||||
if (__c == '0' || __c == '1')
|
||||
__tmp.push_back(__c);
|
||||
else if (_Traits::eq_int_type(__buf->sputbackc(__c2), __eof)) {
|
||||
__is.setstate(ios_base::failbit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (__tmp.empty())
|
||||
__is.setstate(ios_base::failbit);
|
||||
else
|
||||
__x._M_copy_from_string(__tmp, __STATIC_CAST(size_t,0), _Nb);
|
||||
}
|
||||
|
||||
return __is;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, size_t _Nb>
|
||||
basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os,
|
||||
const bitset<_Nb>& __x) {
|
||||
basic_string<_CharT, _Traits> __tmp;
|
||||
__x._M_copy_to_string(__tmp);
|
||||
return __os << __tmp;
|
||||
}
|
||||
|
||||
# endif /* !_STLP_USE_NO_IOSTREAMS */
|
||||
|
||||
#endif /* _STLP_NON_TYPE_TMPL_PARAM_BUG */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#undef __BITS_PER_WORD
|
||||
#undef bitset
|
||||
|
||||
#endif /* _STLP_BITSET_C */
|
||||
880
extern/STLport/5.2.1/stlport/stl/_bitset.h
vendored
Normal file
880
extern/STLport/5.2.1/stlport/stl/_bitset.h
vendored
Normal file
@@ -0,0 +1,880 @@
|
||||
/*
|
||||
* Copyright (c) 1998
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_BITSET_H
|
||||
#define _STLP_BITSET_H
|
||||
|
||||
// A bitset of size N has N % (sizeof(unsigned long) * CHAR_BIT) unused
|
||||
// bits. (They are the high- order bits in the highest word.) It is
|
||||
// a class invariant of class bitset<> that those unused bits are
|
||||
// always zero.
|
||||
|
||||
// Most of the actual code isn't contained in bitset<> itself, but in the
|
||||
// base class _Base_bitset. The base class works with whole words, not with
|
||||
// individual bits. This allows us to specialize _Base_bitset for the
|
||||
// important special case where the bitset is only a single word.
|
||||
|
||||
// The C++ standard does not define the precise semantics of operator[].
|
||||
// In this implementation the const version of operator[] is equivalent
|
||||
// to test(), except that it does no range checking. The non-const version
|
||||
// returns a reference to a bit, again without doing any range checking.
|
||||
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALGOBASE_H
|
||||
# include <stl/_algobase.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALLOC_H
|
||||
# include <stl/_alloc.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_H
|
||||
# include <stl/_iterator.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_UNINITIALIZED_H
|
||||
# include <stl/_uninitialized.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_RANGE_ERRORS_H
|
||||
# include <stl/_range_errors.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_STRING_H
|
||||
# include <stl/_string.h>
|
||||
#endif
|
||||
|
||||
#define __BITS_PER_WORD (CHAR_BIT*sizeof(unsigned long))
|
||||
#define __BITSET_WORDS(__n) ((__n + __BITS_PER_WORD - 1)/__BITS_PER_WORD)
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
// structure to aid in counting bits
|
||||
class _STLP_CLASS_DECLSPEC _Bs_G
|
||||
{
|
||||
public:
|
||||
//returns the number of bit set within the buffer between __beg and __end.
|
||||
static size_t _S_count(const unsigned char *__beg, const unsigned char *__end)
|
||||
#if defined (_STLP_USE_NO_IOSTREAMS)
|
||||
{
|
||||
size_t __result = 0;
|
||||
for (; __beg != __end; ++__beg) {
|
||||
for (size_t i = 0; i < (sizeof(unsigned char) * 8); ++i) {
|
||||
if ((*__beg & (1 << i)) != 0) { ++__result; }
|
||||
}
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
// Mapping from 8 bit unsigned integers to the index of the first one bit set:
|
||||
static unsigned char _S_first_one(unsigned char __x)
|
||||
#if defined (_STLP_USE_NO_IOSTREAMS)
|
||||
{
|
||||
for (unsigned char i = 0; i < (sizeof(unsigned char) * 8); ++i) {
|
||||
if ((__x & (1 << i)) != 0) { return i; }
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
};
|
||||
|
||||
//
|
||||
// Base class: general case.
|
||||
//
|
||||
|
||||
template<size_t _Nw>
|
||||
struct _Base_bitset {
|
||||
typedef unsigned long _WordT;
|
||||
|
||||
_WordT _M_w[_Nw]; // 0 is the least significant word.
|
||||
|
||||
_Base_bitset() { _M_do_reset(); }
|
||||
|
||||
_Base_bitset(unsigned long __val) {
|
||||
_M_do_reset();
|
||||
_M_w[0] = __val;
|
||||
}
|
||||
|
||||
static size_t _STLP_CALL _S_whichword( size_t __pos ) {
|
||||
return __pos / __BITS_PER_WORD;
|
||||
}
|
||||
static size_t _STLP_CALL _S_whichbyte( size_t __pos ) {
|
||||
return (__pos % __BITS_PER_WORD) / CHAR_BIT;
|
||||
}
|
||||
static size_t _STLP_CALL _S_whichbit( size_t __pos ) {
|
||||
return __pos % __BITS_PER_WORD;
|
||||
}
|
||||
static _WordT _STLP_CALL _S_maskbit( size_t __pos ) {
|
||||
return __STATIC_CAST(_WordT,1) << _S_whichbit(__pos);
|
||||
}
|
||||
|
||||
_WordT& _M_getword(size_t __pos) { return _M_w[_S_whichword(__pos)]; }
|
||||
_WordT _M_getword(size_t __pos) const { return _M_w[_S_whichword(__pos)]; }
|
||||
|
||||
_WordT& _M_hiword() { return _M_w[_Nw - 1]; }
|
||||
_WordT _M_hiword() const { return _M_w[_Nw - 1]; }
|
||||
|
||||
void _M_do_and(const _Base_bitset<_Nw>& __x) {
|
||||
for ( size_t __i = 0; __i < _Nw; __i++ ) {
|
||||
_M_w[__i] &= __x._M_w[__i];
|
||||
}
|
||||
}
|
||||
|
||||
void _M_do_or(const _Base_bitset<_Nw>& __x) {
|
||||
for ( size_t __i = 0; __i < _Nw; __i++ ) {
|
||||
_M_w[__i] |= __x._M_w[__i];
|
||||
}
|
||||
}
|
||||
|
||||
void _M_do_xor(const _Base_bitset<_Nw>& __x) {
|
||||
for ( size_t __i = 0; __i < _Nw; __i++ ) {
|
||||
_M_w[__i] ^= __x._M_w[__i];
|
||||
}
|
||||
}
|
||||
|
||||
void _M_do_left_shift(size_t __shift);
|
||||
|
||||
void _M_do_right_shift(size_t __shift);
|
||||
|
||||
void _M_do_flip() {
|
||||
for ( size_t __i = 0; __i < _Nw; __i++ ) {
|
||||
_M_w[__i] = ~_M_w[__i];
|
||||
}
|
||||
}
|
||||
|
||||
void _M_do_set() {
|
||||
for ( size_t __i = 0; __i < _Nw; __i++ ) {
|
||||
_M_w[__i] = ~__STATIC_CAST(_WordT,0);
|
||||
}
|
||||
}
|
||||
|
||||
void _M_do_reset() { memset(_M_w, 0, _Nw * sizeof(_WordT)); }
|
||||
|
||||
bool _M_is_equal(const _Base_bitset<_Nw>& __x) const {
|
||||
for (size_t __i = 0; __i < _Nw; ++__i) {
|
||||
if (_M_w[__i] != __x._M_w[__i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _M_is_any() const {
|
||||
for ( size_t __i = 0; __i < _Nw ; __i++ ) {
|
||||
if ( _M_w[__i] != __STATIC_CAST(_WordT,0) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t _M_do_count() const {
|
||||
const unsigned char* __byte_ptr = (const unsigned char*)_M_w;
|
||||
const unsigned char* __end_ptr = (const unsigned char*)(_M_w+_Nw);
|
||||
|
||||
return _Bs_G::_S_count(__byte_ptr, __end_ptr);
|
||||
}
|
||||
|
||||
unsigned long _M_do_to_ulong() const;
|
||||
|
||||
// find first "on" bit
|
||||
size_t _M_do_find_first(size_t __not_found) const;
|
||||
|
||||
// find the next "on" bit that follows "prev"
|
||||
size_t _M_do_find_next(size_t __prev, size_t __not_found) const;
|
||||
};
|
||||
|
||||
//
|
||||
// Base class: specialization for a single word.
|
||||
//
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct _Base_bitset<1UL> {
|
||||
typedef unsigned long _WordT;
|
||||
typedef _Base_bitset<1UL> _Self;
|
||||
|
||||
_WordT _M_w;
|
||||
|
||||
_Base_bitset( void ) : _M_w(0) {}
|
||||
_Base_bitset(unsigned long __val) : _M_w(__val) {}
|
||||
|
||||
static size_t _STLP_CALL _S_whichword( size_t __pos ) {
|
||||
return __pos / __BITS_PER_WORD ;
|
||||
}
|
||||
static size_t _STLP_CALL _S_whichbyte( size_t __pos ) {
|
||||
return (__pos % __BITS_PER_WORD) / CHAR_BIT;
|
||||
}
|
||||
static size_t _STLP_CALL _S_whichbit( size_t __pos ) {
|
||||
return __pos % __BITS_PER_WORD;
|
||||
}
|
||||
static _WordT _STLP_CALL _S_maskbit( size_t __pos ) {
|
||||
return (__STATIC_CAST(_WordT,1)) << _S_whichbit(__pos);
|
||||
}
|
||||
|
||||
_WordT& _M_getword(size_t) { return _M_w; }
|
||||
_WordT _M_getword(size_t) const { return _M_w; }
|
||||
|
||||
_WordT& _M_hiword() { return _M_w; }
|
||||
_WordT _M_hiword() const { return _M_w; }
|
||||
|
||||
void _M_do_and(const _Self& __x) { _M_w &= __x._M_w; }
|
||||
void _M_do_or(const _Self& __x) { _M_w |= __x._M_w; }
|
||||
void _M_do_xor(const _Self& __x) { _M_w ^= __x._M_w; }
|
||||
void _M_do_left_shift(size_t __shift) { _M_w <<= __shift; }
|
||||
void _M_do_right_shift(size_t __shift) { _M_w >>= __shift; }
|
||||
void _M_do_flip() { _M_w = ~_M_w; }
|
||||
void _M_do_set() { _M_w = ~__STATIC_CAST(_WordT,0); }
|
||||
void _M_do_reset() { _M_w = 0; }
|
||||
|
||||
bool _M_is_equal(const _Self& __x) const {
|
||||
return _M_w == __x._M_w;
|
||||
}
|
||||
bool _M_is_any() const {
|
||||
return _M_w != 0;
|
||||
}
|
||||
|
||||
size_t _M_do_count() const {
|
||||
const unsigned char* __byte_ptr = (const unsigned char*)&_M_w;
|
||||
const unsigned char* __end_ptr = ((const unsigned char*)&_M_w)+sizeof(_M_w);
|
||||
return _Bs_G::_S_count(__byte_ptr, __end_ptr);
|
||||
}
|
||||
|
||||
unsigned long _M_do_to_ulong() const { return _M_w; }
|
||||
|
||||
inline size_t _M_do_find_first(size_t __not_found) const;
|
||||
|
||||
// find the next "on" bit that follows "prev"
|
||||
inline size_t _M_do_find_next(size_t __prev, size_t __not_found) const;
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
// Definitions of should-be-non-inline functions from the single-word version of
|
||||
// _Base_bitset.
|
||||
//
|
||||
inline size_t
|
||||
_Base_bitset<1UL>::_M_do_find_first(size_t __not_found) const {
|
||||
// typedef unsigned long _WordT;
|
||||
_WordT __thisword = _M_w;
|
||||
|
||||
if ( __thisword != __STATIC_CAST(_WordT,0) ) {
|
||||
// find byte within word
|
||||
for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) {
|
||||
unsigned char __this_byte
|
||||
= __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0)));
|
||||
if ( __this_byte )
|
||||
return __j*CHAR_BIT + _Bs_G::_S_first_one(__this_byte);
|
||||
|
||||
__thisword >>= CHAR_BIT;
|
||||
}
|
||||
}
|
||||
// not found, so return a value that indicates failure.
|
||||
return __not_found;
|
||||
}
|
||||
|
||||
inline size_t
|
||||
_Base_bitset<1UL>::_M_do_find_next(size_t __prev,
|
||||
size_t __not_found ) const {
|
||||
// make bound inclusive
|
||||
++__prev;
|
||||
|
||||
// check out of bounds
|
||||
if ( __prev >= __BITS_PER_WORD )
|
||||
return __not_found;
|
||||
|
||||
// search first (and only) word
|
||||
_WordT __thisword = _M_w;
|
||||
|
||||
// mask off bits below bound
|
||||
__thisword &= (~__STATIC_CAST(_WordT,0)) << _S_whichbit(__prev);
|
||||
|
||||
if ( __thisword != __STATIC_CAST(_WordT,0) ) {
|
||||
// find byte within word
|
||||
// get first byte into place
|
||||
__thisword >>= _S_whichbyte(__prev) * CHAR_BIT;
|
||||
for ( size_t __j = _S_whichbyte(__prev); __j < sizeof(_WordT); __j++ ) {
|
||||
unsigned char __this_byte
|
||||
= __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0)));
|
||||
if ( __this_byte )
|
||||
return __j*CHAR_BIT + _Bs_G::_S_first_one(__this_byte);
|
||||
|
||||
__thisword >>= CHAR_BIT;
|
||||
}
|
||||
}
|
||||
|
||||
// not found, so return a value that indicates failure.
|
||||
return __not_found;
|
||||
} // end _M_do_find_next
|
||||
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Helper class to zero out the unused high-order bits in the highest word.
|
||||
|
||||
template <size_t _Extrabits> struct _Sanitize {
|
||||
static void _STLP_CALL _M_do_sanitize(unsigned long& __val)
|
||||
{ __val &= ~((~__STATIC_CAST(unsigned long,0)) << _Extrabits); }
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL struct _Sanitize<0UL> {
|
||||
static void _STLP_CALL _M_do_sanitize(unsigned long) {}
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Class bitset.
|
||||
// _Nb may be any nonzero number of type size_t.
|
||||
template<size_t _Nb>
|
||||
class bitset : public _STLP_PRIV _Base_bitset<__BITSET_WORDS(_Nb) > {
|
||||
public:
|
||||
enum { _Words = __BITSET_WORDS(_Nb) } ;
|
||||
|
||||
private:
|
||||
typedef _STLP_PRIV _Base_bitset< _Words > _Base;
|
||||
|
||||
void _M_do_sanitize() {
|
||||
_STLP_PRIV _Sanitize<_Nb%__BITS_PER_WORD >::_M_do_sanitize(this->_M_hiword());
|
||||
}
|
||||
public:
|
||||
typedef unsigned long _WordT;
|
||||
struct reference;
|
||||
friend struct reference;
|
||||
|
||||
// bit reference:
|
||||
struct reference {
|
||||
typedef _STLP_PRIV _Base_bitset<_Words > _Bitset_base;
|
||||
typedef bitset<_Nb> _Bitset;
|
||||
// friend _Bitset;
|
||||
_WordT *_M_wp;
|
||||
size_t _M_bpos;
|
||||
|
||||
// should be left undefined
|
||||
reference() {}
|
||||
|
||||
reference( _Bitset& __b, size_t __pos ) {
|
||||
_M_wp = &__b._M_getword(__pos);
|
||||
_M_bpos = _Bitset_base::_S_whichbit(__pos);
|
||||
}
|
||||
|
||||
public:
|
||||
~reference() {}
|
||||
|
||||
// for b[i] = __x;
|
||||
reference& operator=(bool __x) {
|
||||
if ( __x )
|
||||
*_M_wp |= _Bitset_base::_S_maskbit(_M_bpos);
|
||||
else
|
||||
*_M_wp &= ~_Bitset_base::_S_maskbit(_M_bpos);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// for b[i] = b[__j];
|
||||
reference& operator=(const reference& __j) {
|
||||
if ( (*(__j._M_wp) & _Bitset_base::_S_maskbit(__j._M_bpos)) )
|
||||
*_M_wp |= _Bitset_base::_S_maskbit(_M_bpos);
|
||||
else
|
||||
*_M_wp &= ~_Bitset_base::_S_maskbit(_M_bpos);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// flips the bit
|
||||
bool operator~() const { return (*(_M_wp) & _Bitset_base::_S_maskbit(_M_bpos)) == 0; }
|
||||
|
||||
// for __x = b[i];
|
||||
operator bool() const { return (*(_M_wp) & _Bitset_base::_S_maskbit(_M_bpos)) != 0; }
|
||||
|
||||
// for b[i].flip();
|
||||
reference& flip() {
|
||||
*_M_wp ^= _Bitset_base::_S_maskbit(_M_bpos);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
// 23.3.5.1 constructors:
|
||||
bitset() {}
|
||||
|
||||
bitset(unsigned long __val) : _STLP_PRIV _Base_bitset<_Words>(__val) { _M_do_sanitize(); }
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template<class _CharT, class _Traits, class _Alloc>
|
||||
explicit bitset(const basic_string<_CharT,_Traits,_Alloc>& __s,
|
||||
size_t __pos = 0)
|
||||
: _STLP_PRIV _Base_bitset<_Words >() {
|
||||
if (__pos > __s.size())
|
||||
__stl_throw_out_of_range("bitset");
|
||||
_M_copy_from_string(__s, __pos,
|
||||
basic_string<_CharT, _Traits, _Alloc>::npos);
|
||||
}
|
||||
template<class _CharT, class _Traits, class _Alloc>
|
||||
bitset(const basic_string<_CharT, _Traits, _Alloc>& __s,
|
||||
size_t __pos,
|
||||
size_t __n)
|
||||
: _STLP_PRIV _Base_bitset<_Words >() {
|
||||
if (__pos > __s.size())
|
||||
__stl_throw_out_of_range("bitset");
|
||||
_M_copy_from_string(__s, __pos, __n);
|
||||
}
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
explicit bitset(const string& __s,
|
||||
size_t __pos = 0,
|
||||
size_t __n = (size_t)-1)
|
||||
: _STLP_PRIV _Base_bitset<_Words >() {
|
||||
if (__pos > __s.size())
|
||||
__stl_throw_out_of_range("bitset");
|
||||
_M_copy_from_string(__s, __pos, __n);
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
// 23.3.5.2 bitset operations:
|
||||
bitset<_Nb>& operator&=(const bitset<_Nb>& __rhs) {
|
||||
this->_M_do_and(__rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bitset<_Nb>& operator|=(const bitset<_Nb>& __rhs) {
|
||||
this->_M_do_or(__rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bitset<_Nb>& operator^=(const bitset<_Nb>& __rhs) {
|
||||
this->_M_do_xor(__rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bitset<_Nb>& operator<<=(size_t __pos) {
|
||||
this->_M_do_left_shift(__pos);
|
||||
this->_M_do_sanitize();
|
||||
return *this;
|
||||
}
|
||||
|
||||
bitset<_Nb>& operator>>=(size_t __pos) {
|
||||
this->_M_do_right_shift(__pos);
|
||||
this->_M_do_sanitize();
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// Extension:
|
||||
// Versions of single-bit set, reset, flip, test with no range checking.
|
||||
//
|
||||
|
||||
bitset<_Nb>& _Unchecked_set(size_t __pos) {
|
||||
this->_M_getword(__pos) |= _STLP_PRIV _Base_bitset<_Words > ::_S_maskbit(__pos);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bitset<_Nb>& _Unchecked_set(size_t __pos, int __val) {
|
||||
if (__val)
|
||||
this->_M_getword(__pos) |= this->_S_maskbit(__pos);
|
||||
else
|
||||
this->_M_getword(__pos) &= ~ this->_S_maskbit(__pos);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bitset<_Nb>& _Unchecked_reset(size_t __pos) {
|
||||
this->_M_getword(__pos) &= ~ this->_S_maskbit(__pos);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bitset<_Nb>& _Unchecked_flip(size_t __pos) {
|
||||
this->_M_getword(__pos) ^= this->_S_maskbit(__pos);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool _Unchecked_test(size_t __pos) const {
|
||||
return (this->_M_getword(__pos) & this->_S_maskbit(__pos)) != __STATIC_CAST(_WordT,0);
|
||||
}
|
||||
|
||||
// Set, reset, and flip.
|
||||
|
||||
bitset<_Nb>& set() {
|
||||
this->_M_do_set();
|
||||
this->_M_do_sanitize();
|
||||
return *this;
|
||||
}
|
||||
|
||||
bitset<_Nb>& set(size_t __pos) {
|
||||
if (__pos >= _Nb)
|
||||
__stl_throw_out_of_range("bitset");
|
||||
return _Unchecked_set(__pos);
|
||||
}
|
||||
|
||||
bitset<_Nb>& set(size_t __pos, int __val) {
|
||||
if (__pos >= _Nb)
|
||||
__stl_throw_out_of_range("bitset");
|
||||
return _Unchecked_set(__pos, __val);
|
||||
}
|
||||
|
||||
bitset<_Nb>& reset() {
|
||||
this->_M_do_reset();
|
||||
return *this;
|
||||
}
|
||||
|
||||
bitset<_Nb>& reset(size_t __pos) {
|
||||
if (__pos >= _Nb)
|
||||
__stl_throw_out_of_range("bitset");
|
||||
|
||||
return _Unchecked_reset(__pos);
|
||||
}
|
||||
|
||||
bitset<_Nb>& flip() {
|
||||
this->_M_do_flip();
|
||||
this->_M_do_sanitize();
|
||||
return *this;
|
||||
}
|
||||
|
||||
bitset<_Nb>& flip(size_t __pos) {
|
||||
if (__pos >= _Nb)
|
||||
__stl_throw_out_of_range("bitset");
|
||||
|
||||
return _Unchecked_flip(__pos);
|
||||
}
|
||||
|
||||
bitset<_Nb> operator~() const {
|
||||
return bitset<_Nb>(*this).flip();
|
||||
}
|
||||
|
||||
// element access:
|
||||
//for b[i];
|
||||
reference operator[](size_t __pos) { return reference(*this,__pos); }
|
||||
bool operator[](size_t __pos) const { return _Unchecked_test(__pos); }
|
||||
|
||||
unsigned long to_ulong() const { return this->_M_do_to_ulong(); }
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS)
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
basic_string<_CharT, _Traits, _Alloc> to_string() const {
|
||||
basic_string<_CharT, _Traits, _Alloc> __result;
|
||||
_M_copy_to_string(__result);
|
||||
return __result;
|
||||
}
|
||||
#else
|
||||
string to_string() const {
|
||||
string __result;
|
||||
_M_copy_to_string(__result);
|
||||
return __result;
|
||||
}
|
||||
#endif /* _STLP_EXPLICIT_FUNCTION_TMPL_ARGS */
|
||||
|
||||
size_t count() const { return this->_M_do_count(); }
|
||||
|
||||
size_t size() const { return _Nb; }
|
||||
|
||||
bool operator==(const bitset<_Nb>& __rhs) const {
|
||||
return this->_M_is_equal(__rhs);
|
||||
}
|
||||
bool operator!=(const bitset<_Nb>& __rhs) const {
|
||||
return !this->_M_is_equal(__rhs);
|
||||
}
|
||||
|
||||
bool test(size_t __pos) const {
|
||||
if (__pos >= _Nb)
|
||||
__stl_throw_out_of_range("bitset");
|
||||
|
||||
return _Unchecked_test(__pos);
|
||||
}
|
||||
|
||||
bool any() const { return this->_M_is_any(); }
|
||||
bool none() const { return !this->_M_is_any(); }
|
||||
|
||||
bitset<_Nb> operator<<(size_t __pos) const {
|
||||
bitset<_Nb> __result(*this);
|
||||
__result <<= __pos ; return __result;
|
||||
}
|
||||
bitset<_Nb> operator>>(size_t __pos) const {
|
||||
bitset<_Nb> __result(*this);
|
||||
__result >>= __pos ; return __result;
|
||||
}
|
||||
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
//
|
||||
// EXTENSIONS: bit-find operations. These operations are
|
||||
// experimental, and are subject to change or removal in future
|
||||
// versions.
|
||||
//
|
||||
|
||||
// find the index of the first "on" bit
|
||||
size_t _Find_first() const
|
||||
{ return this->_M_do_find_first(_Nb); }
|
||||
|
||||
// find the index of the next "on" bit after prev
|
||||
size_t _Find_next( size_t __prev ) const
|
||||
{ return this->_M_do_find_next(__prev, _Nb); }
|
||||
#endif
|
||||
|
||||
//
|
||||
// Definitions of should-be non-inline member functions.
|
||||
//
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template<class _CharT, class _Traits, class _Alloc>
|
||||
void _M_copy_from_string(const basic_string<_CharT,_Traits,_Alloc>& __s,
|
||||
size_t __pos, size_t __n) {
|
||||
#else
|
||||
void _M_copy_from_string(const string& __s,
|
||||
size_t __pos, size_t __n) {
|
||||
typedef typename string::traits_type _Traits;
|
||||
#endif
|
||||
reset();
|
||||
size_t __tmp = _Nb;
|
||||
const size_t __Nbits = (min) (__tmp, (min) (__n, __s.size() - __pos));
|
||||
for ( size_t __i= 0; __i < __Nbits; ++__i) {
|
||||
typename _Traits::int_type __k = _Traits::to_int_type(__s[__pos + __Nbits - __i - 1]);
|
||||
// boris : widen() ?
|
||||
if (__k == '1')
|
||||
set(__i);
|
||||
else if (__k != '0')
|
||||
__stl_throw_invalid_argument("bitset");
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
void _M_copy_to_string(basic_string<_CharT, _Traits, _Alloc>& __s) const
|
||||
#else
|
||||
void _M_copy_to_string(string& __s) const
|
||||
#endif
|
||||
{
|
||||
__s.assign(_Nb, '0');
|
||||
|
||||
for (size_t __i = 0; __i < _Nb; ++__i) {
|
||||
if (_Unchecked_test(__i))
|
||||
__s[_Nb - 1 - __i] = '1';
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_NO_WCHAR_T)
|
||||
void _M_copy_to_string(wstring& __s) const {
|
||||
__s.assign(_Nb, '0');
|
||||
|
||||
for (size_t __i = 0; __i < _Nb; ++__i) {
|
||||
if (_Unchecked_test(__i))
|
||||
__s[_Nb - 1 - __i] = '1';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_NON_TYPE_TMPL_PARAM_BUG)
|
||||
bitset<_Nb> operator&(const bitset<_Nb>& __y) const {
|
||||
bitset<_Nb> __result(*this);
|
||||
__result &= __y;
|
||||
return __result;
|
||||
}
|
||||
bitset<_Nb> operator|(const bitset<_Nb>& __y) const {
|
||||
bitset<_Nb> __result(*this);
|
||||
__result |= __y;
|
||||
return __result;
|
||||
}
|
||||
bitset<_Nb> operator^(const bitset<_Nb>& __y) const {
|
||||
bitset<_Nb> __result(*this);
|
||||
__result ^= __y;
|
||||
return __result;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
// 23.3.5.3 bitset operations:
|
||||
//
|
||||
#if ! defined (_STLP_NON_TYPE_TMPL_PARAM_BUG)
|
||||
template <size_t _Nb>
|
||||
inline bitset<_Nb> _STLP_CALL
|
||||
operator&(const bitset<_Nb>& __x,
|
||||
const bitset<_Nb>& __y) {
|
||||
bitset<_Nb> __result(__x);
|
||||
__result &= __y;
|
||||
return __result;
|
||||
}
|
||||
|
||||
|
||||
template <size_t _Nb>
|
||||
inline bitset<_Nb> _STLP_CALL
|
||||
operator|(const bitset<_Nb>& __x,
|
||||
const bitset<_Nb>& __y) {
|
||||
bitset<_Nb> __result(__x);
|
||||
__result |= __y;
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <size_t _Nb>
|
||||
inline bitset<_Nb> _STLP_CALL
|
||||
operator^(const bitset<_Nb>& __x,
|
||||
const bitset<_Nb>& __y) {
|
||||
bitset<_Nb> __result(__x);
|
||||
__result ^= __y;
|
||||
return __result;
|
||||
}
|
||||
|
||||
#if !defined (_STLP_USE_NO_IOSTREAMS)
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# if !(defined (_STLP_MSVC) && (_STLP_MSVC < 1300)) && \
|
||||
!(defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x500))
|
||||
|
||||
#ifndef _STLP_INTERNAL_IOSFWD
|
||||
# include <stl/_iosfwd.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _CharT, class _Traits, size_t _Nb>
|
||||
basic_istream<_CharT, _Traits>& _STLP_CALL
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x);
|
||||
|
||||
template <class _CharT, class _Traits, size_t _Nb>
|
||||
basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Nb>& __x);
|
||||
|
||||
# else
|
||||
|
||||
#ifndef _STLP_STRING_IO_H
|
||||
# include <stl/_string_io.h> //includes _istream.h and _ostream.h
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <size_t _Nb>
|
||||
istream& _STLP_CALL
|
||||
operator>>(istream& __is, bitset<_Nb>& __x) {
|
||||
typedef typename string::traits_type _Traits;
|
||||
string __tmp;
|
||||
__tmp.reserve(_Nb);
|
||||
|
||||
// Skip whitespace
|
||||
typename istream::sentry __sentry(__is);
|
||||
if (__sentry) {
|
||||
streambuf* __buf = __is.rdbuf();
|
||||
for (size_t __i = 0; __i < _Nb; ++__i) {
|
||||
static typename _Traits::int_type __eof = _Traits::eof();
|
||||
|
||||
typename _Traits::int_type __c1 = __buf->sbumpc();
|
||||
if (_Traits::eq_int_type(__c1, __eof)) {
|
||||
__is.setstate(ios_base::eofbit);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
typename _Traits::char_type __c2 = _Traits::to_char_type(__c1);
|
||||
char __c = __is.narrow(__c2, '*');
|
||||
|
||||
if (__c == '0' || __c == '1')
|
||||
__tmp.push_back(__c);
|
||||
else if (_Traits::eq_int_type(__buf->sputbackc(__c2), __eof)) {
|
||||
__is.setstate(ios_base::failbit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (__tmp.empty())
|
||||
__is.setstate(ios_base::failbit);
|
||||
else
|
||||
__x._M_copy_from_string(__tmp, __STATIC_CAST(size_t,0), _Nb);
|
||||
}
|
||||
|
||||
return __is;
|
||||
}
|
||||
|
||||
template <size_t _Nb>
|
||||
ostream& _STLP_CALL
|
||||
operator<<(ostream& __os, const bitset<_Nb>& __x) {
|
||||
string __tmp;
|
||||
__x._M_copy_to_string(__tmp);
|
||||
return __os << __tmp;
|
||||
}
|
||||
|
||||
# if !defined (_STLP_NO_WCHAR_T)
|
||||
|
||||
template <size_t _Nb>
|
||||
wistream& _STLP_CALL
|
||||
operator>>(wistream& __is, bitset<_Nb>& __x) {
|
||||
typedef typename wstring::traits_type _Traits;
|
||||
wstring __tmp;
|
||||
__tmp.reserve(_Nb);
|
||||
|
||||
// Skip whitespace
|
||||
typename wistream::sentry __sentry(__is);
|
||||
if (__sentry) {
|
||||
wstreambuf* __buf = __is.rdbuf();
|
||||
for (size_t __i = 0; __i < _Nb; ++__i) {
|
||||
static typename _Traits::int_type __eof = _Traits::eof();
|
||||
|
||||
typename _Traits::int_type __c1 = __buf->sbumpc();
|
||||
if (_Traits::eq_int_type(__c1, __eof)) {
|
||||
__is.setstate(ios_base::eofbit);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
typename _Traits::char_type __c2 = _Traits::to_char_type(__c1);
|
||||
char __c = __is.narrow(__c2, '*');
|
||||
|
||||
if (__c == '0' || __c == '1')
|
||||
__tmp.push_back(__c);
|
||||
else if (_Traits::eq_int_type(__buf->sputbackc(__c2), __eof)) {
|
||||
__is.setstate(ios_base::failbit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (__tmp.empty())
|
||||
__is.setstate(ios_base::failbit);
|
||||
else
|
||||
__x._M_copy_from_string(__tmp, __STATIC_CAST(size_t,0), _Nb);
|
||||
}
|
||||
|
||||
return __is;
|
||||
}
|
||||
|
||||
template <size_t _Nb>
|
||||
wostream& _STLP_CALL
|
||||
operator<<(wostream& __os, const bitset<_Nb>& __x) {
|
||||
wstring __tmp;
|
||||
__x._M_copy_to_string(__tmp);
|
||||
return __os << __tmp;
|
||||
}
|
||||
|
||||
# endif /* _STLP_NO_WCHAR_T */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_NON_TYPE_TMPL_PARAM_BUG */
|
||||
|
||||
#undef bitset
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#undef __BITS_PER_WORD
|
||||
#undef __BITSET_WORDS
|
||||
|
||||
#if !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_bitset.c>
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_BITSET_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
841
extern/STLport/5.2.1/stlport/stl/_bvector.h
vendored
Normal file
841
extern/STLport/5.2.1/stlport/stl/_bvector.h
vendored
Normal file
@@ -0,0 +1,841 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_BVECTOR_H
|
||||
#define _STLP_INTERNAL_BVECTOR_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_VECTOR_H
|
||||
# include <stl/_vector.h>
|
||||
#endif
|
||||
|
||||
#define _STLP_WORD_BIT (int(CHAR_BIT * sizeof(unsigned int)))
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
struct _Bit_reference {
|
||||
unsigned int* _M_p;
|
||||
unsigned int _M_mask;
|
||||
_Bit_reference(unsigned int* __x, unsigned int __y)
|
||||
: _M_p(__x), _M_mask(__y) {}
|
||||
|
||||
public:
|
||||
_Bit_reference() : _M_p(0), _M_mask(0) {}
|
||||
|
||||
operator bool() const {
|
||||
return !(!(*_M_p & _M_mask));
|
||||
}
|
||||
_Bit_reference& operator = (bool __x) {
|
||||
if (__x) *_M_p |= _M_mask;
|
||||
else *_M_p &= ~_M_mask;
|
||||
return *this;
|
||||
}
|
||||
_Bit_reference& operator = (const _Bit_reference& __x) {
|
||||
return *this = bool(__x);
|
||||
}
|
||||
bool operator == (const _Bit_reference& __x) const {
|
||||
return bool(*this) == bool(__x);
|
||||
}
|
||||
bool operator < (const _Bit_reference& __x) const {
|
||||
return !bool(*this) && bool(__x);
|
||||
}
|
||||
|
||||
_Bit_reference& operator |= (bool __x) {
|
||||
if (__x)
|
||||
*_M_p |= _M_mask;
|
||||
return *this;
|
||||
}
|
||||
_Bit_reference& operator &= (bool __x) {
|
||||
if (!__x)
|
||||
*_M_p &= ~_M_mask;
|
||||
return *this;
|
||||
}
|
||||
void flip() { *_M_p ^= _M_mask; }
|
||||
};
|
||||
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
inline void swap(_STLP_PRIV _Bit_reference& __x, _STLP_PRIV _Bit_reference& __y) {
|
||||
bool __tmp = (bool)__x;
|
||||
__x = __y;
|
||||
__y = __tmp;
|
||||
}
|
||||
|
||||
// Might not be very useful but costs nothing!
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct __type_traits<_STLP_PRIV _Bit_reference> {
|
||||
typedef __false_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
typedef __false_type has_trivial_assignment_operator;
|
||||
typedef __true_type has_trivial_destructor;
|
||||
typedef __false_type is_POD_type;
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
struct _Bit_iterator_base {
|
||||
typedef ptrdiff_t difference_type;
|
||||
|
||||
unsigned int* _M_p;
|
||||
unsigned int _M_offset;
|
||||
|
||||
void _M_bump_up() {
|
||||
if (_M_offset++ == _STLP_WORD_BIT - 1) {
|
||||
_M_offset = 0;
|
||||
++_M_p;
|
||||
}
|
||||
}
|
||||
|
||||
void _M_bump_down() {
|
||||
if (_M_offset-- == 0) {
|
||||
_M_offset = _STLP_WORD_BIT - 1;
|
||||
--_M_p;
|
||||
}
|
||||
}
|
||||
|
||||
_Bit_iterator_base() : _M_p(0), _M_offset(0) {}
|
||||
_Bit_iterator_base(unsigned int* __x, unsigned int __y) : _M_p(__x), _M_offset(__y) {}
|
||||
// see comment in doc/README.evc4 and doc/README.evc8
|
||||
#if defined(_MSC_VER) && _MSC_VER<=1401 && defined(MIPS) && defined(NDEBUG)
|
||||
_Bit_iterator_base( const _Bit_iterator_base& __x) : _M_p(__x._M_p), _M_offset(__x._M_offset) {}
|
||||
#endif
|
||||
// _Bit_iterator_base& operator = ( const _Bit_iterator_base& __x) { _M_p = __x._M_p ; _M_offset = __x._M_offset ; return *this; }
|
||||
|
||||
void _M_advance (difference_type __i) {
|
||||
difference_type __n = __i + _M_offset;
|
||||
_M_p += __n / _STLP_WORD_BIT;
|
||||
__n = __n % _STLP_WORD_BIT;
|
||||
if (__n < 0) {
|
||||
_M_offset = (unsigned int) __n + _STLP_WORD_BIT;
|
||||
--_M_p;
|
||||
} else
|
||||
_M_offset = (unsigned int) __n;
|
||||
}
|
||||
|
||||
difference_type _M_subtract(const _Bit_iterator_base& __x) const {
|
||||
return _STLP_WORD_BIT * (_M_p - __x._M_p) + _M_offset - __x._M_offset;
|
||||
}
|
||||
};
|
||||
|
||||
inline bool _STLP_CALL operator==(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {
|
||||
return __y._M_p == __x._M_p && __y._M_offset == __x._M_offset;
|
||||
}
|
||||
inline bool _STLP_CALL operator!=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {
|
||||
return __y._M_p != __x._M_p || __y._M_offset != __x._M_offset;
|
||||
}
|
||||
|
||||
inline bool _STLP_CALL operator<(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {
|
||||
return __x._M_p < __y._M_p || (__x._M_p == __y._M_p && __x._M_offset < __y._M_offset);
|
||||
}
|
||||
|
||||
inline bool _STLP_CALL operator>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {
|
||||
return operator <(__y , __x);
|
||||
}
|
||||
inline bool _STLP_CALL operator<=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {
|
||||
return !(__y < __x);
|
||||
}
|
||||
inline bool _STLP_CALL operator>=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {
|
||||
return !(__x < __y);
|
||||
}
|
||||
|
||||
template <class _Ref, class _Ptr>
|
||||
struct _Bit_iter : public _Bit_iterator_base {
|
||||
typedef _Ref reference;
|
||||
typedef _Ptr pointer;
|
||||
typedef _Bit_iter<_Ref, _Ptr> _Self;
|
||||
typedef random_access_iterator_tag iterator_category;
|
||||
typedef bool value_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef size_t size_type;
|
||||
|
||||
_Bit_iter(unsigned int* __x, unsigned int __y) : _Bit_iterator_base(__x, __y) {}
|
||||
_Bit_iter() {}
|
||||
|
||||
_Bit_iter(const _Bit_iter<_Bit_reference, _Bit_reference*>& __x):
|
||||
_Bit_iterator_base((const _Bit_iterator_base&)__x) {}
|
||||
|
||||
// _Self& operator = (const _Bit_iter<_Bit_reference, _Bit_reference*>& __x)
|
||||
// { (_Bit_iterator_base&)*this = (const _Bit_iterator_base&)__x; return *this; }
|
||||
|
||||
reference operator*() const {
|
||||
return _Bit_reference(_M_p, 1UL << _M_offset);
|
||||
}
|
||||
_Self& operator++() {
|
||||
_M_bump_up();
|
||||
return *this;
|
||||
}
|
||||
_Self operator++(int) {
|
||||
_Self __tmp = *this;
|
||||
_M_bump_up();
|
||||
return __tmp;
|
||||
}
|
||||
_Self& operator--() {
|
||||
_M_bump_down();
|
||||
return *this;
|
||||
}
|
||||
_Self operator--(int) {
|
||||
_Self __tmp = *this;
|
||||
_M_bump_down();
|
||||
return __tmp;
|
||||
}
|
||||
_Self& operator+=(difference_type __i) {
|
||||
_M_advance(__i);
|
||||
return *this;
|
||||
}
|
||||
_Self& operator-=(difference_type __i) {
|
||||
*this += -__i;
|
||||
return *this;
|
||||
}
|
||||
_Self operator+(difference_type __i) const {
|
||||
_Self __tmp = *this;
|
||||
return __tmp += __i;
|
||||
}
|
||||
_Self operator-(difference_type __i) const {
|
||||
_Self __tmp = *this;
|
||||
return __tmp -= __i;
|
||||
}
|
||||
difference_type operator-(const _Self& __x) const {
|
||||
return _M_subtract(__x);
|
||||
}
|
||||
reference operator[](difference_type __i) { return *(*this + __i); }
|
||||
};
|
||||
|
||||
template <class _Ref, class _Ptr>
|
||||
inline _Bit_iter<_Ref,_Ptr> _STLP_CALL
|
||||
operator+(ptrdiff_t __n, const _Bit_iter<_Ref, _Ptr>& __x) {
|
||||
return __x + __n;
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
template <class _Ref, class _Ptr>
|
||||
struct __type_traits< _STLP_PRIV _Bit_iter<_Ref, _Ptr> > {
|
||||
typedef __false_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
typedef __true_type has_trivial_assignment_operator;
|
||||
typedef __true_type has_trivial_destructor;
|
||||
typedef __false_type is_POD_type;
|
||||
};
|
||||
#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
|
||||
|
||||
#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
|
||||
inline random_access_iterator_tag iterator_category(const _STLP_PRIV _Bit_iterator_base&)
|
||||
{ return random_access_iterator_tag(); }
|
||||
inline ptrdiff_t* distance_type(const _STLP_PRIV _Bit_iterator_base&)
|
||||
{ return (ptrdiff_t*)0; }
|
||||
inline bool* value_type(const _STLP_PRIV _Bit_iter<_STLP_PRIV _Bit_reference, _STLP_PRIV _Bit_reference*>&)
|
||||
{ return (bool*)0; }
|
||||
inline bool* value_type(const _STLP_PRIV _Bit_iter<bool, const bool*>&)
|
||||
{ return (bool*)0; }
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
typedef _Bit_iter<bool, const bool*> _Bit_const_iterator;
|
||||
typedef _Bit_iter<_Bit_reference, _Bit_reference*> _Bit_iterator;
|
||||
|
||||
// Bit-vector base class, which encapsulates the difference between
|
||||
// old SGI-style allocators and standard-conforming allocators.
|
||||
template <class _Alloc>
|
||||
class _Bvector_base {
|
||||
typedef _Bvector_base<_Alloc> _Self;
|
||||
public:
|
||||
_STLP_FORCE_ALLOCATORS(bool, _Alloc)
|
||||
typedef _Alloc allocator_type;
|
||||
typedef unsigned int __chunk_type;
|
||||
typedef typename _Alloc_traits<__chunk_type, _Alloc>::allocator_type __chunk_allocator_type;
|
||||
allocator_type get_allocator() const
|
||||
{ return _STLP_CONVERT_ALLOCATOR(__STATIC_CAST(const __chunk_allocator_type&, _M_end_of_storage), bool); }
|
||||
|
||||
_Bvector_base(const allocator_type& __a)
|
||||
: _M_start(), _M_finish(), _M_end_of_storage(_STLP_CONVERT_ALLOCATOR(__a, __chunk_type),
|
||||
(__chunk_type*)0)
|
||||
{}
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
_Bvector_base(__move_source<_Self> src)
|
||||
: _M_start(src.get()._M_start), _M_finish(src.get()._M_finish),
|
||||
_M_end_of_storage(src.get()._M_end_of_storage) {
|
||||
//Make the source destroyable
|
||||
src.get()._M_start._M_p = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
~_Bvector_base() {
|
||||
_M_deallocate();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
static size_t _M_bits_to_chunks(size_t __n_bits)
|
||||
{ return (__n_bits + _STLP_WORD_BIT - 1) / _STLP_WORD_BIT; }
|
||||
|
||||
__chunk_type* _M_bit_alloc(size_t __n)
|
||||
{ return _M_end_of_storage.allocate(_M_bits_to_chunks(__n)); }
|
||||
|
||||
void _M_deallocate() {
|
||||
if (_M_start._M_p)
|
||||
_M_end_of_storage.deallocate(_M_start._M_p,
|
||||
_M_end_of_storage._M_data - _M_start._M_p);
|
||||
}
|
||||
|
||||
_Bit_iterator _M_start;
|
||||
_Bit_iterator _M_finish;
|
||||
_STLP_alloc_proxy<__chunk_type*, __chunk_type, __chunk_allocator_type> _M_end_of_storage;
|
||||
};
|
||||
|
||||
|
||||
// The next few lines are confusing. What we're doing is declaring a
|
||||
// partial specialization of vector<T, Alloc> if we have the necessary
|
||||
// compiler support. Otherwise, we define a class bit_vector which uses
|
||||
// the default allocator.
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_BOOL) && !defined (__SUNPRO_CC)
|
||||
# define _STLP_VECBOOL_TEMPLATE
|
||||
# define __BVEC_TMPL_HEADER template <class _Alloc>
|
||||
#else
|
||||
# undef _STLP_VECBOOL_TEMPLATE
|
||||
# ifdef _STLP_NO_BOOL
|
||||
# define __BVEC_TMPL_HEADER
|
||||
# else
|
||||
# define __BVEC_TMPL_HEADER _STLP_TEMPLATE_NULL
|
||||
# endif
|
||||
# define _Alloc allocator<bool>
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_DEBUG)
|
||||
# define vector _STLP_NON_DBG_NAME(vector)
|
||||
#endif
|
||||
|
||||
#ifdef _STLP_NO_BOOL
|
||||
# define __BVECTOR_QUALIFIED bit_vector
|
||||
# define __BVECTOR bit_vector
|
||||
#else
|
||||
# ifdef _STLP_VECBOOL_TEMPLATE
|
||||
# define __BVECTOR_QUALIFIED vector<bool, _Alloc>
|
||||
# else
|
||||
# define __BVECTOR_QUALIFIED vector<bool, allocator<bool> >
|
||||
# endif
|
||||
# if defined (_STLP_PARTIAL_SPEC_NEEDS_TEMPLATE_ARGS)
|
||||
# define __BVECTOR __BVECTOR_QUALIFIED
|
||||
# else
|
||||
# define __BVECTOR vector
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_DEBUG) || defined (_STLP_NO_BOOL)
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
#endif
|
||||
|
||||
__BVEC_TMPL_HEADER
|
||||
class __BVECTOR_QUALIFIED : public _STLP_PRIV _Bvector_base<_Alloc >
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_DEBUG)
|
||||
, public __stlport_class< __BVECTOR_QUALIFIED >
|
||||
#endif
|
||||
{
|
||||
typedef _STLP_PRIV _Bvector_base<_Alloc > _Base;
|
||||
typedef __BVECTOR_QUALIFIED _Self;
|
||||
public:
|
||||
typedef bool value_type;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _STLP_PRIV _Bit_reference reference;
|
||||
typedef bool const_reference;
|
||||
typedef _STLP_PRIV _Bit_reference* pointer;
|
||||
typedef const bool* const_pointer;
|
||||
typedef random_access_iterator_tag _Iterator_category;
|
||||
|
||||
typedef _STLP_PRIV _Bit_iterator iterator;
|
||||
typedef _STLP_PRIV _Bit_const_iterator const_iterator;
|
||||
|
||||
_STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
|
||||
|
||||
#ifdef _STLP_VECBOOL_TEMPLATE
|
||||
typedef _STLP_TYPENAME _STLP_PRIV _Bvector_base<_Alloc >::allocator_type allocator_type;
|
||||
typedef _STLP_TYPENAME _STLP_PRIV _Bvector_base<_Alloc >::__chunk_type __chunk_type;
|
||||
#else
|
||||
typedef _STLP_PRIV _Bvector_base<_Alloc >::allocator_type allocator_type;
|
||||
typedef _STLP_PRIV _Bvector_base<_Alloc >::__chunk_type __chunk_type;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
void _M_initialize(size_type __n) {
|
||||
__chunk_type* __q = this->_M_bit_alloc(__n);
|
||||
this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__n);
|
||||
this->_M_start = iterator(__q, 0);
|
||||
this->_M_finish = this->_M_start + difference_type(__n);
|
||||
}
|
||||
void _M_insert_aux(iterator __position, bool __x) {
|
||||
if (this->_M_finish._M_p != this->_M_end_of_storage._M_data) {
|
||||
_STLP_PRIV __copy_backward(__position, this->_M_finish, this->_M_finish + 1,
|
||||
random_access_iterator_tag(), (difference_type*)0 );
|
||||
*__position = __x;
|
||||
++this->_M_finish;
|
||||
}
|
||||
else {
|
||||
size_type __len = size() ? 2 * size() : _STLP_WORD_BIT;
|
||||
__chunk_type* __q = this->_M_bit_alloc(__len);
|
||||
iterator __i = _STLP_STD::copy(begin(), __position, iterator(__q, 0));
|
||||
*__i++ = __x;
|
||||
this->_M_finish = _STLP_STD::copy(__position, end(), __i);
|
||||
this->_M_deallocate();
|
||||
this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__len);
|
||||
this->_M_start = iterator(__q, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void _M_initialize_range(_InputIterator __first, _InputIterator __last,
|
||||
const input_iterator_tag &) {
|
||||
this->_M_start = iterator();
|
||||
this->_M_finish = iterator();
|
||||
this->_M_end_of_storage._M_data = 0;
|
||||
for ( ; __first != __last; ++__first)
|
||||
push_back(*__first);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
void _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,
|
||||
const forward_iterator_tag &) {
|
||||
size_type __n = _STLP_STD::distance(__first, __last);
|
||||
_M_initialize(__n);
|
||||
_STLP_STD::copy(__first, __last, this->_M_start);
|
||||
}
|
||||
|
||||
template <class _InputIterator>
|
||||
void _M_insert_range(iterator __pos,
|
||||
_InputIterator __first, _InputIterator __last,
|
||||
const input_iterator_tag &) {
|
||||
for ( ; __first != __last; ++__first) {
|
||||
__pos = insert(__pos, *__first);
|
||||
++__pos;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
void _M_insert_range(iterator __position,
|
||||
_ForwardIterator __first, _ForwardIterator __last,
|
||||
const forward_iterator_tag &) {
|
||||
if (__first != __last) {
|
||||
size_type __n = _STLP_STD::distance(__first, __last);
|
||||
if (capacity() - size() >= __n) {
|
||||
_STLP_PRIV __copy_backward(__position, end(), this->_M_finish + difference_type(__n),
|
||||
random_access_iterator_tag(), (difference_type*)0 );
|
||||
_STLP_STD::copy(__first, __last, __position);
|
||||
this->_M_finish += difference_type(__n);
|
||||
}
|
||||
else {
|
||||
size_type __len = size() + (max)(size(), __n);
|
||||
__chunk_type* __q = this->_M_bit_alloc(__len);
|
||||
iterator __i = _STLP_STD::copy(begin(), __position, iterator(__q, 0));
|
||||
__i = _STLP_STD::copy(__first, __last, __i);
|
||||
this->_M_finish = _STLP_STD::copy(__position, end(), __i);
|
||||
this->_M_deallocate();
|
||||
this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__len);
|
||||
this->_M_start = iterator(__q, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
public:
|
||||
iterator begin() { return this->_M_start; }
|
||||
const_iterator begin() const { return this->_M_start; }
|
||||
iterator end() { return this->_M_finish; }
|
||||
const_iterator end() const { return this->_M_finish; }
|
||||
|
||||
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
||||
const_reverse_iterator rbegin() const {
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
||||
const_reverse_iterator rend() const {
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
|
||||
size_type size() const { return size_type(end() - begin()); }
|
||||
size_type max_size() const { return size_type(-1); }
|
||||
size_type capacity() const {
|
||||
return size_type(const_iterator(this->_M_end_of_storage._M_data, 0) - begin());
|
||||
}
|
||||
bool empty() const { return begin() == end(); }
|
||||
reference operator[](size_type __n)
|
||||
{ return *(begin() + difference_type(__n)); }
|
||||
const_reference operator[](size_type __n) const
|
||||
{ return *(begin() + difference_type(__n)); }
|
||||
|
||||
void _M_range_check(size_type __n) const {
|
||||
if (__n >= this->size())
|
||||
__stl_throw_range_error("vector<bool>");
|
||||
}
|
||||
|
||||
reference at(size_type __n)
|
||||
{ _M_range_check(__n); return (*this)[__n]; }
|
||||
const_reference at(size_type __n) const
|
||||
{ _M_range_check(__n); return (*this)[__n]; }
|
||||
|
||||
explicit __BVECTOR(const allocator_type& __a = allocator_type())
|
||||
: _STLP_PRIV _Bvector_base<_Alloc >(__a) {}
|
||||
|
||||
__BVECTOR(size_type __n, bool __val,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _STLP_PRIV _Bvector_base<_Alloc >(__a) {
|
||||
_M_initialize(__n);
|
||||
fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), __val ? ~0 : 0);
|
||||
}
|
||||
|
||||
explicit __BVECTOR(size_type __n)
|
||||
: _STLP_PRIV _Bvector_base<_Alloc >(allocator_type()) {
|
||||
_M_initialize(__n);
|
||||
fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), 0);
|
||||
}
|
||||
|
||||
__BVECTOR(const _Self& __x)
|
||||
: _STLP_PRIV _Bvector_base<_Alloc >(__x.get_allocator()) {
|
||||
_M_initialize(__x.size());
|
||||
_STLP_STD::copy(__x.begin(), __x.end(), this->_M_start);
|
||||
}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _Integer>
|
||||
void _M_initialize_dispatch(_Integer __n, _Integer __x, const __true_type&) {
|
||||
_M_initialize(__n);
|
||||
fill(this->_M_start._M_p, this->_M_end_of_storage._M_data, __x ? ~0 : 0);
|
||||
}
|
||||
|
||||
template <class _InputIterator>
|
||||
void _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
|
||||
const __false_type&) {
|
||||
_M_initialize_range(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
|
||||
}
|
||||
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
|
||||
// Check whether it's an integral type. If so, it's not an iterator.
|
||||
template <class _InputIterator>
|
||||
__BVECTOR(_InputIterator __first, _InputIterator __last)
|
||||
: _STLP_PRIV _Bvector_base<_Alloc >(allocator_type()) {
|
||||
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
|
||||
_M_initialize_dispatch(__first, __last, _Integral());
|
||||
}
|
||||
# endif
|
||||
template <class _InputIterator>
|
||||
__BVECTOR(_InputIterator __first, _InputIterator __last,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
||||
: _STLP_PRIV _Bvector_base<_Alloc >(__a) {
|
||||
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
|
||||
_M_initialize_dispatch(__first, __last, _Integral());
|
||||
}
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
__BVECTOR(const_iterator __first, const_iterator __last,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _STLP_PRIV _Bvector_base<_Alloc >(__a) {
|
||||
size_type __n = _STLP_STD::distance(__first, __last);
|
||||
_M_initialize(__n);
|
||||
_STLP_STD::copy(__first, __last, this->_M_start);
|
||||
}
|
||||
__BVECTOR(const bool* __first, const bool* __last,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _STLP_PRIV _Bvector_base<_Alloc >(__a) {
|
||||
size_type __n = _STLP_STD::distance(__first, __last);
|
||||
_M_initialize(__n);
|
||||
_STLP_STD::copy(__first, __last, this->_M_start);
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
__BVECTOR(__move_source<_Self> src)
|
||||
: _STLP_PRIV _Bvector_base<_Alloc >(__move_source<_Base>(src.get())) {}
|
||||
#endif
|
||||
|
||||
~__BVECTOR() {}
|
||||
|
||||
__BVECTOR_QUALIFIED& operator=(const __BVECTOR_QUALIFIED& __x) {
|
||||
if (&__x == this) return *this;
|
||||
if (__x.size() > capacity()) {
|
||||
this->_M_deallocate();
|
||||
_M_initialize(__x.size());
|
||||
}
|
||||
_STLP_STD::copy(__x.begin(), __x.end(), begin());
|
||||
this->_M_finish = begin() + difference_type(__x.size());
|
||||
return *this;
|
||||
}
|
||||
|
||||
// assign(), a generalized assignment member function. Two
|
||||
// versions: one that takes a count, and one that takes a range.
|
||||
// The range version is a member template, so we dispatch on whether
|
||||
// or not the type is an integer.
|
||||
|
||||
void _M_fill_assign(size_t __n, bool __x) {
|
||||
if (__n > size()) {
|
||||
fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), __x ? ~0 : 0);
|
||||
insert(end(), __n - size(), __x);
|
||||
}
|
||||
else {
|
||||
erase(begin() + __n, end());
|
||||
fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), __x ? ~0 : 0);
|
||||
}
|
||||
}
|
||||
void assign(size_t __n, bool __x) { _M_fill_assign(__n, __x); }
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void assign(_InputIterator __first, _InputIterator __last) {
|
||||
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
|
||||
_M_assign_dispatch(__first, __last, _Integral());
|
||||
}
|
||||
|
||||
template <class _Integer>
|
||||
void _M_assign_dispatch(_Integer __n, _Integer __val, const __true_type&)
|
||||
{ _M_fill_assign((size_t) __n, (bool) __val); }
|
||||
|
||||
template <class _InputIter>
|
||||
void _M_assign_dispatch(_InputIter __first, _InputIter __last, const __false_type&)
|
||||
{ _M_assign_aux(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); }
|
||||
|
||||
template <class _InputIterator>
|
||||
void _M_assign_aux(_InputIterator __first, _InputIterator __last,
|
||||
const input_iterator_tag &) {
|
||||
iterator __cur = begin();
|
||||
for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
|
||||
*__cur = *__first;
|
||||
if (__first == __last)
|
||||
erase(__cur, end());
|
||||
else
|
||||
insert(end(), __first, __last);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
|
||||
const forward_iterator_tag &) {
|
||||
size_type __len = _STLP_STD::distance(__first, __last);
|
||||
if (__len < size())
|
||||
erase(_STLP_STD::copy(__first, __last, begin()), end());
|
||||
else {
|
||||
_ForwardIterator __mid = __first;
|
||||
_STLP_STD::advance(__mid, size());
|
||||
_STLP_STD::copy(__first, __mid, begin());
|
||||
insert(end(), __mid, __last);
|
||||
}
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
void reserve(size_type __n) {
|
||||
if (capacity() < __n) {
|
||||
if (max_size() < __n)
|
||||
__stl_throw_length_error("vector<bool>");
|
||||
__chunk_type* __q = this->_M_bit_alloc(__n);
|
||||
_STLP_PRIV _Bit_iterator __z(__q, 0);
|
||||
this->_M_finish = _STLP_STD::copy(begin(), end(), __z);
|
||||
this->_M_deallocate();
|
||||
this->_M_start = iterator(__q, 0);
|
||||
this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__n);
|
||||
}
|
||||
}
|
||||
|
||||
reference front() { return *begin(); }
|
||||
const_reference front() const { return *begin(); }
|
||||
reference back() { return *(end() - 1); }
|
||||
const_reference back() const { return *(end() - 1); }
|
||||
void push_back(bool __x) {
|
||||
if (this->_M_finish._M_p != this->_M_end_of_storage._M_data) {
|
||||
*(this->_M_finish) = __x;
|
||||
++this->_M_finish;
|
||||
}
|
||||
else
|
||||
_M_insert_aux(end(), __x);
|
||||
}
|
||||
void swap(__BVECTOR_QUALIFIED& __x) {
|
||||
_STLP_STD::swap(this->_M_start, __x._M_start);
|
||||
_STLP_STD::swap(this->_M_finish, __x._M_finish);
|
||||
this->_M_end_of_storage.swap(__x._M_end_of_storage);
|
||||
}
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(__BVECTOR_QUALIFIED& __x) { swap(__x); }
|
||||
#endif
|
||||
|
||||
iterator insert(iterator __position, bool __x = bool()) {
|
||||
difference_type __n = __position - begin();
|
||||
if (this->_M_finish._M_p != this->_M_end_of_storage._M_data && __position == end()) {
|
||||
*(this->_M_finish) = __x;
|
||||
++this->_M_finish;
|
||||
}
|
||||
else
|
||||
_M_insert_aux(__position, __x);
|
||||
return begin() + __n;
|
||||
}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
|
||||
template <class _Integer>
|
||||
void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
|
||||
const __true_type&) {
|
||||
_M_fill_insert(__pos, (size_type) __n, (bool) __x);
|
||||
}
|
||||
|
||||
template <class _InputIterator>
|
||||
void _M_insert_dispatch(iterator __pos,
|
||||
_InputIterator __first, _InputIterator __last,
|
||||
const __false_type&) {
|
||||
_M_insert_range(__pos, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
|
||||
}
|
||||
|
||||
// Check whether it's an integral type. If so, it's not an iterator.
|
||||
template <class _InputIterator>
|
||||
void insert(iterator __position,
|
||||
_InputIterator __first, _InputIterator __last) {
|
||||
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
|
||||
_M_insert_dispatch(__position, __first, __last, _Integral());
|
||||
}
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
void insert(iterator __position,
|
||||
const_iterator __first, const_iterator __last) {
|
||||
if (__first == __last) return;
|
||||
size_type __n = _STLP_STD::distance(__first, __last);
|
||||
if (capacity() - size() >= __n) {
|
||||
_STLP_PRIV __copy_backward(__position, end(), this->_M_finish + __n,
|
||||
random_access_iterator_tag(), (difference_type*)0 );
|
||||
_STLP_STD::copy(__first, __last, __position);
|
||||
this->_M_finish += __n;
|
||||
}
|
||||
else {
|
||||
size_type __len = size() + (max)(size(), __n);
|
||||
__chunk_type* __q = this->_M_bit_alloc(__len);
|
||||
iterator __i = _STLP_STD::copy(begin(), __position, iterator(__q, 0));
|
||||
__i = _STLP_STD::copy(__first, __last, __i);
|
||||
this->_M_finish = _STLP_STD::copy(__position, end(), __i);
|
||||
this->_M_deallocate();
|
||||
this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__len);
|
||||
this->_M_start = iterator(__q, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void insert(iterator __position, const bool* __first, const bool* __last) {
|
||||
if (__first == __last) return;
|
||||
size_type __n = _STLP_STD::distance(__first, __last);
|
||||
if (capacity() - size() >= __n) {
|
||||
_STLP_PRIV __copy_backward(__position, end(), this->_M_finish + __n,
|
||||
random_access_iterator_tag(), (difference_type*)0 );
|
||||
_STLP_STD::copy(__first, __last, __position);
|
||||
this->_M_finish += __n;
|
||||
}
|
||||
else {
|
||||
size_type __len = size() + (max)(size(), __n);
|
||||
__chunk_type* __q = this->_M_bit_alloc(__len);
|
||||
iterator __i = _STLP_STD::copy(begin(), __position, iterator(__q, 0));
|
||||
__i = _STLP_STD::copy(__first, __last, __i);
|
||||
this->_M_finish = _STLP_STD::copy(__position, end(), __i);
|
||||
this->_M_deallocate();
|
||||
this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__len);
|
||||
this->_M_start = iterator(__q, 0);
|
||||
}
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
void _M_fill_insert(iterator __position, size_type __n, bool __x) {
|
||||
if (__n == 0) return;
|
||||
if (capacity() - size() >= __n) {
|
||||
_STLP_PRIV __copy_backward(__position, end(), this->_M_finish + difference_type(__n),
|
||||
random_access_iterator_tag(), (difference_type*)0 );
|
||||
fill(__position, __position + difference_type(__n), __x);
|
||||
this->_M_finish += difference_type(__n);
|
||||
}
|
||||
else {
|
||||
size_type __len = size() + (max)(size(), __n);
|
||||
__chunk_type* __q = this->_M_bit_alloc(__len);
|
||||
iterator __i = _STLP_STD::copy(begin(), __position, iterator(__q, 0));
|
||||
fill_n(__i, __n, __x);
|
||||
this->_M_finish = _STLP_STD::copy(__position, end(), __i + difference_type(__n));
|
||||
this->_M_deallocate();
|
||||
this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__len);
|
||||
this->_M_start = iterator(__q, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void insert(iterator __position, size_type __n, bool __x) {
|
||||
_M_fill_insert(__position, __n, __x);
|
||||
}
|
||||
|
||||
void pop_back() {
|
||||
--this->_M_finish;
|
||||
}
|
||||
iterator erase(iterator __position) {
|
||||
if (__position + 1 != end())
|
||||
_STLP_STD::copy(__position + 1, end(), __position);
|
||||
--this->_M_finish;
|
||||
return __position;
|
||||
}
|
||||
iterator erase(iterator __first, iterator __last) {
|
||||
this->_M_finish = _STLP_STD::copy(__last, end(), __first);
|
||||
return __first;
|
||||
}
|
||||
void resize(size_type __new_size, bool __x = bool()) {
|
||||
if (__new_size < size())
|
||||
erase(begin() + difference_type(__new_size), end());
|
||||
else
|
||||
insert(end(), __new_size - size(), __x);
|
||||
}
|
||||
void flip() {
|
||||
for (__chunk_type* __p = this->_M_start._M_p; __p != this->_M_end_of_storage._M_data; ++__p)
|
||||
*__p = ~*__p;
|
||||
}
|
||||
|
||||
void clear() { erase(begin(), end()); }
|
||||
};
|
||||
|
||||
#if defined (_STLP_NO_BOOL) || defined (__HP_aCC) // fixed soon (03/17/2000)
|
||||
# define _STLP_TEMPLATE_HEADER __BVEC_TMPL_HEADER
|
||||
# define _STLP_TEMPLATE_CONTAINER __BVECTOR_QUALIFIED
|
||||
# include <stl/_relops_cont.h>
|
||||
# undef _STLP_TEMPLATE_CONTAINER
|
||||
# undef _STLP_TEMPLATE_HEADER
|
||||
#endif /* NO_BOOL */
|
||||
|
||||
#if defined (_STLP_DEBUG) && !defined (_STLP_NO_BOOL)
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#undef vector
|
||||
#undef _Alloc
|
||||
#undef _STLP_VECBOOL_TEMPLATE
|
||||
#undef __BVECTOR
|
||||
#undef __BVECTOR_QUALIFIED
|
||||
#undef __BVEC_TMPL_HEADER
|
||||
|
||||
#undef _STLP_WORD_BIT
|
||||
|
||||
#endif /* _STLP_INTERNAL_BVECTOR_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
61
extern/STLport/5.2.1/stlport/stl/_carray.h
vendored
Normal file
61
extern/STLport/5.2.1/stlport/stl/_carray.h
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2005
|
||||
* Francois Dumont
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_CARRAY_H
|
||||
#define _STLP_CARRAY_H
|
||||
|
||||
/* Purpose: Mimic a pur C array with the additionnal feature of
|
||||
* being able to be used with type not default constructible.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_CONSTRUCT_H
|
||||
# include <stl/_construct.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Tp, size_t _Nb>
|
||||
struct _CArray {
|
||||
_CArray (const _Tp& __val) {
|
||||
for (size_t __i = 0; __i < _Nb; ++__i) {
|
||||
_Copy_Construct(__REINTERPRET_CAST(_Tp*, _M_data + __i * sizeof(_Tp)), __val);
|
||||
}
|
||||
}
|
||||
|
||||
~_CArray() {
|
||||
_Destroy_Range(__REINTERPRET_CAST(_Tp*, _M_data + 0),
|
||||
__REINTERPRET_CAST(_Tp*, _M_data + _Nb * sizeof(_Tp)));
|
||||
}
|
||||
|
||||
_Tp& operator [] (size_t __i) {
|
||||
_STLP_ASSERT(__i < _Nb)
|
||||
return *__REINTERPRET_CAST(_Tp*, _M_data + __i * sizeof(_Tp));
|
||||
}
|
||||
|
||||
private:
|
||||
char _M_data[sizeof(_Tp) * _Nb];
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif //_STLP_CARRAY_H
|
||||
49
extern/STLport/5.2.1/stlport/stl/_cctype.h
vendored
Normal file
49
extern/STLport/5.2.1/stlport/stl/_cctype.h
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_CCTYPE
|
||||
#define _STLP_INTERNAL_CCTYPE
|
||||
|
||||
#if defined (_STLP_USE_NEW_C_HEADERS)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <cctype>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(cctype)
|
||||
# endif
|
||||
#else
|
||||
# include <ctype.h>
|
||||
#endif /* _STLP_USE_NEW_C_HEADERS */
|
||||
|
||||
#if ! defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
|
||||
# if defined ( _STLP_IMPORT_VENDOR_CSTD )
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
using _STLP_VENDOR_CSTD::isalnum;
|
||||
using _STLP_VENDOR_CSTD::isalpha;
|
||||
using _STLP_VENDOR_CSTD::iscntrl;
|
||||
using _STLP_VENDOR_CSTD::isdigit;
|
||||
using _STLP_VENDOR_CSTD::isgraph;
|
||||
using _STLP_VENDOR_CSTD::islower;
|
||||
using _STLP_VENDOR_CSTD::isprint;
|
||||
using _STLP_VENDOR_CSTD::ispunct;
|
||||
using _STLP_VENDOR_CSTD::isspace;
|
||||
using _STLP_VENDOR_CSTD::isupper;
|
||||
using _STLP_VENDOR_CSTD::isxdigit;
|
||||
using _STLP_VENDOR_CSTD::tolower;
|
||||
using _STLP_VENDOR_CSTD::toupper;
|
||||
_STLP_END_NAMESPACE
|
||||
# endif /* _STLP_IMPORT_VENDOR_CSTD*/
|
||||
#endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */
|
||||
|
||||
#endif
|
||||
43
extern/STLport/5.2.1/stlport/stl/_clocale.h
vendored
Normal file
43
extern/STLport/5.2.1/stlport/stl/_clocale.h
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_CLOCALE
|
||||
#define _STLP_INTERNAL_CLOCALE
|
||||
|
||||
#if !defined (_STLP_WCE_EVC3)
|
||||
|
||||
# if defined (_STLP_USE_NEW_C_HEADERS)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <clocale>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(clocale)
|
||||
# endif
|
||||
# else
|
||||
# include <locale.h>
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_IMPORT_VENDOR_CSTD)
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
using _STLP_VENDOR_CSTD::lconv;
|
||||
# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
|
||||
using _STLP_VENDOR_CSTD::localeconv;
|
||||
using _STLP_VENDOR_CSTD::setlocale;
|
||||
# endif
|
||||
_STLP_END_NAMESPACE
|
||||
# endif
|
||||
|
||||
#endif /* !_STLP_WCE_EVC3 */
|
||||
|
||||
#endif
|
||||
579
extern/STLport/5.2.1/stlport/stl/_cmath.h
vendored
Normal file
579
extern/STLport/5.2.1/stlport/stl/_cmath.h
vendored
Normal file
@@ -0,0 +1,579 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_CMATH
|
||||
#define _STLP_INTERNAL_CMATH
|
||||
|
||||
/* gcc do not like when a using directive appear after a function
|
||||
* declaration. cmath have abs overloads and cstdlib a using directive
|
||||
* so cstdlib has to be included first.
|
||||
*/
|
||||
#if defined (__GNUC__) && defined (_STLP_USE_NEW_C_HEADERS)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <cstdlib>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(cstdlib)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_USE_NEW_C_HEADERS)
|
||||
# if defined (_STLP_HAS_NO_NAMESPACES) && !defined (exception)
|
||||
# define exception __math_exception
|
||||
# endif
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <cmath>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(cmath)
|
||||
# endif
|
||||
# if defined (_STLP_HAS_NO_NAMESPACES)
|
||||
# undef exception
|
||||
# endif
|
||||
#else
|
||||
# include <math.h>
|
||||
#endif
|
||||
|
||||
#if (defined (__SUNPRO_CC) && (__SUNPRO_CC > 0x500)) || \
|
||||
!(defined (__IBMCPP__) && (__IBMCPP__ >= 500) || !(defined(__HP_aCC) && (__HP_aCC >= 30000) ))
|
||||
# if !defined(_STLP_HAS_NO_NAMESPACES) && !defined(__SUNPRO_CC)
|
||||
// All the other hypot stuff is going to be at file scope, so follow along here.
|
||||
namespace std {
|
||||
# endif
|
||||
extern "C" double hypot(double x, double y);
|
||||
# if !defined(_STLP_HAS_NO_NAMESPACES) && !defined(__SUNPRO_CC)
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (__sun) && defined (__GNUC__)
|
||||
extern "C" {
|
||||
float __cosf(float v);
|
||||
float __sinf(float v);
|
||||
float __atan2f(float, float);
|
||||
float __coshf(float v);
|
||||
float __sinhf(float v);
|
||||
float __sqrtf(float v);
|
||||
float __expf(float v);
|
||||
float __logf(float v);
|
||||
float __log10f(float v);
|
||||
|
||||
long double __cosl(long double v);
|
||||
long double __sinl(long double v);
|
||||
long double __atan2l(long double, long double);
|
||||
long double __coshl(long double v);
|
||||
long double __sinhl(long double v);
|
||||
long double __sqrtl(long double v);
|
||||
long double __expl(long double v);
|
||||
long double __logl(long double v);
|
||||
long double __log10l(long double v);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
inline float cosf(float v) { return __cosf(v); }
|
||||
inline float sinf(float v) { return __sinf(v); }
|
||||
inline float atan2f(float v1, float v2) { return __atan2f(v1,v2); }
|
||||
inline float coshf(float v) { return __coshf(v); }
|
||||
inline float sinhf(float v) { return __sinhf(v); }
|
||||
inline float sqrtf(float v) { return __sqrtf(v); }
|
||||
inline float expf(float v) { return __expf(v); }
|
||||
inline float logf(float v) { return __logf(v); }
|
||||
inline float log10f(float v) { return __log10f(v); }
|
||||
|
||||
inline long double cosl(long double v) { return __cosl(v); }
|
||||
inline long double sinl(long double v) { return __sinl(v); }
|
||||
inline long double atan2l(long double v1, long double v2) { return __atan2l(v1,v2); }
|
||||
inline long double coshl(long double v) { return __coshl(v); }
|
||||
inline long double sinhl(long double v) { return __sinhl(v); }
|
||||
inline long double sqrtl(long double v) { return __sqrtl(v); }
|
||||
inline long double expl(long double v) { return __expl(v); }
|
||||
inline long double logl(long double v) { return __logl(v); }
|
||||
inline long double log10l(long double v) { return __log10l(v); }
|
||||
}
|
||||
#endif // __sun && __GNUC__
|
||||
|
||||
#if defined (__sun)
|
||||
extern "C" {
|
||||
extern float __acosf(float);
|
||||
extern float __asinf(float);
|
||||
extern float __atanf(float);
|
||||
extern float __atan2f(float, float);
|
||||
extern float __ceilf(float);
|
||||
extern float __cosf(float);
|
||||
extern float __coshf(float);
|
||||
extern float __expf(float);
|
||||
extern float __fabsf(float);
|
||||
extern float __floorf(float);
|
||||
extern float __fmodf(float, float);
|
||||
extern float __frexpf(float, int *);
|
||||
extern float __ldexpf(float, int);
|
||||
extern float __logf(float);
|
||||
extern float __log10f(float);
|
||||
extern float __modff(float, float *);
|
||||
extern float __powf(float, float);
|
||||
extern float __sinf(float);
|
||||
extern float __sinhf(float);
|
||||
extern float __sqrtf(float);
|
||||
extern float __tanf(float);
|
||||
extern float __tanhf(float);
|
||||
|
||||
extern long double __acosl(long double);
|
||||
extern long double __asinl(long double);
|
||||
extern long double __atanl(long double);
|
||||
extern long double __atan2l(long double, long double);
|
||||
extern long double __ceill(long double);
|
||||
extern long double __cosl(long double);
|
||||
extern long double __coshl(long double);
|
||||
extern long double __expl(long double);
|
||||
extern long double __fabsl(long double);
|
||||
extern long double __floorl(long double);
|
||||
extern long double __fmodl(long double, long double);
|
||||
extern long double __frexpl(long double, int *);
|
||||
extern long double __ldexpl(long double, int);
|
||||
extern long double __logl(long double);
|
||||
extern long double __log10l(long double);
|
||||
extern long double __modfl(long double, long double *);
|
||||
extern long double __powl(long double, long double);
|
||||
extern long double __sinl(long double);
|
||||
extern long double __sinhl(long double);
|
||||
extern long double __sqrtl(long double);
|
||||
extern long double __tanl(long double);
|
||||
extern long double __tanhl(long double);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (__BORLANDC__)
|
||||
# define _STLP_CMATH_FUNC_NAMESPACE _STLP_VENDOR_CSTD
|
||||
#else
|
||||
# define _STLP_CMATH_FUNC_NAMESPACE
|
||||
#endif
|
||||
|
||||
#if !defined (__sun) || defined (__GNUC__)
|
||||
# define _STLP_MATH_INLINE(float_type, func, cfunc) \
|
||||
inline float_type func (float_type x) { return _STLP_CMATH_FUNC_NAMESPACE::cfunc(x); }
|
||||
# define _STLP_MATH_INLINE2(float_type, type, func, cfunc) \
|
||||
inline float_type func (float_type x, type y) { return _STLP_CMATH_FUNC_NAMESPACE::cfunc(x, y); }
|
||||
# define _STLP_MATH_INLINE_D(float_type, func, cfunc)
|
||||
# define _STLP_MATH_INLINE2_D(float_type, type, func, cfunc)
|
||||
#else
|
||||
# ifdef __SUNPRO_CC
|
||||
# define _STLP_MATH_INLINE(float_type, func, cfunc) \
|
||||
inline float_type func (float_type x) { return _STLP_VENDOR_CSTD::__##cfunc(x); }
|
||||
# define _STLP_MATH_INLINE_D(float_type, func, cfunc) \
|
||||
inline float_type func (float_type x) { return _STLP_VENDOR_CSTD::cfunc(x); }
|
||||
# define _STLP_MATH_INLINE2(float_type, type, func, cfunc) \
|
||||
inline float_type func (float_type x, type y) { return _STLP_VENDOR_CSTD::__##cfunc(x,y); }
|
||||
# define _STLP_MATH_INLINE2_D(float_type, type, func, cfunc) \
|
||||
inline float_type func (float_type x, type y) { return _STLP_VENDOR_CSTD::cfunc(x,y); }
|
||||
# else
|
||||
# error Unknown compiler for the Sun platform
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/** macros to define math functions
|
||||
These macros (having an X somewhere in the name) forward to the C library's
|
||||
double functions but cast the arguments and return values to the given type. */
|
||||
|
||||
#define _STLP_MATH_INLINEX(__type,func,cfunc) \
|
||||
inline __type func (__type x) \
|
||||
{ return __STATIC_CAST(__type, _STLP_CMATH_FUNC_NAMESPACE::cfunc((double)x)); }
|
||||
#define _STLP_MATH_INLINE2X(__type1,__type2,func,cfunc) \
|
||||
inline __type1 func (__type1 x, __type2 y) \
|
||||
{ return __STATIC_CAST(__type1, _STLP_CMATH_FUNC_NAMESPACE::cfunc((double)x, y)); }
|
||||
#define _STLP_MATH_INLINE2PX(__type,func,cfunc) \
|
||||
inline __type func (__type x, __type *y) { \
|
||||
double tmp1, tmp2; \
|
||||
tmp1 = _STLP_CMATH_FUNC_NAMESPACE::cfunc(__STATIC_CAST(double, x), &tmp2); \
|
||||
*y = __STATIC_CAST(__type, tmp2); \
|
||||
return __STATIC_CAST(__type, tmp1); \
|
||||
}
|
||||
#define _STLP_MATH_INLINE2XX(__type,func,cfunc) \
|
||||
inline __type func (__type x, __type y) \
|
||||
{ return __STATIC_CAST(__type, _STLP_CMATH_FUNC_NAMESPACE::cfunc((double)x, (double)y)); }
|
||||
|
||||
|
||||
/** rough characterization of compiler and native C library
|
||||
For the compiler, it can either support long double or not. If it doesn't, the
|
||||
macro _STLP_NO_LONG_DOUBLE is not defined and we don't define any long double
|
||||
overloads.
|
||||
For the native C library the question is whether it has variants with an 'f'
|
||||
suffix (for float as opposed to double) or an 'l' suffix (for long double). If
|
||||
the float variants are missing, _STLP_NO_VENDOR_MATH_F is defined, when the
|
||||
long double variants are missing, _STLP_NO_VENDOR_MATH_L is defined. Of course
|
||||
the latter doesn't make sense anyway when the compiler already has no long
|
||||
double support.
|
||||
|
||||
Those two traits determine a) which overloads get defined and b) how they are
|
||||
defined.
|
||||
|
||||
Meaning of suffixes:
|
||||
"" : function returning and taking a float_type
|
||||
"2" : function returning a float_type and taking to float_types
|
||||
"2P" : function returning a float_type and taking a float_type and a float_type*
|
||||
"2PI": function returning a float_type and taking a float_type and an int*
|
||||
"2I" : function returning a float_type and taking a float_Type and an int
|
||||
*/
|
||||
|
||||
#if !defined (_STLP_NO_LONG_DOUBLE) && !defined (_STLP_NO_VENDOR_MATH_L) && !defined (_STLP_NO_VENDOR_MATH_F)
|
||||
// long double support and both e.g. sinl(long double) and sinf(float)
|
||||
// This is the default for a correct and complete native library.
|
||||
# define _STLP_DEF_MATH_INLINE(func,cf) \
|
||||
_STLP_MATH_INLINE(float,func,cf##f) \
|
||||
_STLP_MATH_INLINE_D(double,func,cf) \
|
||||
_STLP_MATH_INLINE(long double,func,cf##l)
|
||||
# define _STLP_DEF_MATH_INLINE2(func,cf) \
|
||||
_STLP_MATH_INLINE2(float,float,func,cf##f) \
|
||||
_STLP_MATH_INLINE2_D(double,double,func,cf) \
|
||||
_STLP_MATH_INLINE2(long double,long double,func,cf##l)
|
||||
# define _STLP_DEF_MATH_INLINE2P(func,cf) \
|
||||
_STLP_MATH_INLINE2(float,float *,func,cf##f) \
|
||||
_STLP_MATH_INLINE2_D(double,double *,func,cf) \
|
||||
_STLP_MATH_INLINE2(long double,long double *,func,cf##l)
|
||||
# define _STLP_DEF_MATH_INLINE2PI(func,cf) \
|
||||
_STLP_MATH_INLINE2(float,int *,func,cf##f) \
|
||||
_STLP_MATH_INLINE2_D(double,int *,func,cf) \
|
||||
_STLP_MATH_INLINE2(long double,int *,func,cf##l)
|
||||
# define _STLP_DEF_MATH_INLINE2I(func,cf) \
|
||||
_STLP_MATH_INLINE2(float,int,func,cf##f) \
|
||||
_STLP_MATH_INLINE2_D(double,int,func,cf) \
|
||||
_STLP_MATH_INLINE2(long double,int,func,cf##l)
|
||||
#else
|
||||
# if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
# if !defined (_STLP_NO_VENDOR_MATH_F)
|
||||
// long double support and e.g. sinf(float) but not e.g. sinl(long double)
|
||||
# define _STLP_DEF_MATH_INLINE(func,cf) \
|
||||
_STLP_MATH_INLINE(float,func,cf##f) \
|
||||
_STLP_MATH_INLINEX(long double,func,cf)
|
||||
# define _STLP_DEF_MATH_INLINE2(func,cf) \
|
||||
_STLP_MATH_INLINE2(float,float,func,cf##f) \
|
||||
_STLP_MATH_INLINE2XX(long double,func,cf)
|
||||
# define _STLP_DEF_MATH_INLINE2P(func,cf) \
|
||||
_STLP_MATH_INLINE2(float,float *,func,cf##f) \
|
||||
_STLP_MATH_INLINE2PX(long double,func,cf)
|
||||
# define _STLP_DEF_MATH_INLINE2PI(func,cf) \
|
||||
_STLP_MATH_INLINE2(float,int *,func,cf##f) \
|
||||
_STLP_MATH_INLINE2X(long double,int *,func,cf)
|
||||
# define _STLP_DEF_MATH_INLINE2I(func,cf) \
|
||||
_STLP_MATH_INLINE2(float,int,func,cf##f) \
|
||||
_STLP_MATH_INLINE2X(long double,int,func,cf)
|
||||
# elif !defined (_STLP_NO_VENDOR_MATH_L)
|
||||
// long double support and e.g. sinl(long double) but not e.g. sinf(float)
|
||||
# define _STLP_DEF_MATH_INLINE(func,cf) \
|
||||
_STLP_MATH_INLINEX(float,func,cf) \
|
||||
_STLP_MATH_INLINE(long double,func,cf##l)
|
||||
# define _STLP_DEF_MATH_INLINE2(func,cf) \
|
||||
_STLP_MATH_INLINE2XX(float,func,cf) \
|
||||
_STLP_MATH_INLINE2(long double,long double,func,cf##l)
|
||||
# define _STLP_DEF_MATH_INLINE2P(func,cf) \
|
||||
_STLP_MATH_INLINE2PX(float,func,cf) \
|
||||
_STLP_MATH_INLINE2(long double,long double *,func,cf##l)
|
||||
# define _STLP_DEF_MATH_INLINE2PI(func,cf) \
|
||||
_STLP_MATH_INLINE2X(float,int *,func,cf) \
|
||||
_STLP_MATH_INLINE2(long double,int *,func,cf##l)
|
||||
# define _STLP_DEF_MATH_INLINE2I(func,cf) \
|
||||
_STLP_MATH_INLINE2X(float,int,func,cf) \
|
||||
_STLP_MATH_INLINE2(long double,int,func,cf##l)
|
||||
# else
|
||||
# define _STLP_DEF_MATH_INLINE(func,cf) \
|
||||
_STLP_MATH_INLINEX(float,func,cf) \
|
||||
_STLP_MATH_INLINEX(long double,func,cf)
|
||||
# define _STLP_DEF_MATH_INLINE2(func,cf) \
|
||||
_STLP_MATH_INLINE2XX(float,func,cf) \
|
||||
_STLP_MATH_INLINE2XX(long double,func,cf)
|
||||
# define _STLP_DEF_MATH_INLINE2P(func,cf) \
|
||||
_STLP_MATH_INLINE2PX(float,func,cf) \
|
||||
_STLP_MATH_INLINE2PX(long double,func,cf)
|
||||
# define _STLP_DEF_MATH_INLINE2PI(func,cf) \
|
||||
_STLP_MATH_INLINE2X(float,int *,func,cf) \
|
||||
_STLP_MATH_INLINE2X(long double,int *,func,cf)
|
||||
# define _STLP_DEF_MATH_INLINE2I(func,cf) \
|
||||
_STLP_MATH_INLINE2X(float,int,func,cf) \
|
||||
_STLP_MATH_INLINE2X(long double,int,func,cf)
|
||||
# endif
|
||||
# else
|
||||
# if !defined (_STLP_NO_VENDOR_MATH_F)
|
||||
# define _STLP_DEF_MATH_INLINE(func,cf) \
|
||||
_STLP_MATH_INLINE(float,func,cf##f)
|
||||
# define _STLP_DEF_MATH_INLINE2(func,cf) \
|
||||
_STLP_MATH_INLINE2(float,float,func,cf##f)
|
||||
# define _STLP_DEF_MATH_INLINE2P(func,cf) \
|
||||
_STLP_MATH_INLINE2(float,float *,func,cf##f)
|
||||
# define _STLP_DEF_MATH_INLINE2PI(func,cf) \
|
||||
_STLP_MATH_INLINE2(float,int *,func,cf##f)
|
||||
# define _STLP_DEF_MATH_INLINE2I(func,cf) \
|
||||
_STLP_MATH_INLINE2(float,int,func,cf##f)
|
||||
# else // _STLP_NO_VENDOR_MATH_F
|
||||
// neither long double support nor e.g. sinf(float) functions
|
||||
# define _STLP_DEF_MATH_INLINE(func,cf) \
|
||||
_STLP_MATH_INLINEX(float,func,cf)
|
||||
# define _STLP_DEF_MATH_INLINE2(func,cf) \
|
||||
_STLP_MATH_INLINE2XX(float,func,cf)
|
||||
# define _STLP_DEF_MATH_INLINE2P(func,cf) \
|
||||
_STLP_MATH_INLINE2PX(float,func,cf)
|
||||
# define _STLP_DEF_MATH_INLINE2PI(func,cf) \
|
||||
_STLP_MATH_INLINE2X(float,int *,func,cf)
|
||||
# define _STLP_DEF_MATH_INLINE2I(func,cf) \
|
||||
_STLP_MATH_INLINE2X(float,int,func,cf)
|
||||
# endif // _STLP_NO_VENDOR_MATH_F
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_WCE) || \
|
||||
(defined(_STLP_MSVC) && (_STLP_MSVC <= 1300) && defined (_MSC_EXTENSIONS) /* && !defined(_STLP_WCE_NET) */)
|
||||
/*
|
||||
* dums: VC6 has all the required C++ functions but only define them if
|
||||
* _MSC_EXTENSIONS is not defined (a bug?). STLport just do the same
|
||||
* thing also when _MSC_EXTENSIONS is defined.
|
||||
* TODO: above check (_STLP_MSVC <= 1300) also catches VC7.0, is that intended?
|
||||
*/
|
||||
//We have to tell the compilers that abs, acos ... math functions are not intrinsic
|
||||
//otherwise we have Internal Compiler Error in release mode...
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4162) // no function with C linkage found
|
||||
# pragma warning(disable: 4163) // not available as an intrinsic function
|
||||
# pragma function (abs, acos, asin, atan, atan2, cos, cosh, exp, fabs, fmod, log, log10, sin, sinh, sqrt, tan, tanh)
|
||||
# if defined (_STLP_WCE)
|
||||
# pragma function (ceil, floor)
|
||||
# endif
|
||||
# define _STLP_RESTORE_FUNCTION_INTRINSIC
|
||||
#endif // _STLP_MSVC && _STLP_MSVC <= 1300 && !_STLP_WCE && _MSC_EXTENSIONS
|
||||
|
||||
#if (defined (__BORLANDC__) || defined (__WATCOMC__)) && defined (_STLP_USE_NEW_C_HEADERS)
|
||||
/* In this config Borland native lib only define functions in std namespace.
|
||||
* In order to have all overloads in STLport namespace we need to add the
|
||||
* double overload in global namespace. We do not use a using statement to avoid
|
||||
* import of invalid overload.
|
||||
*/
|
||||
# define _STLP_DMATH_INLINE(func) _STLP_MATH_INLINE(double, func, func)
|
||||
# define _STLP_DMATH_INLINE2(func) _STLP_MATH_INLINE2(double, double, func, func)
|
||||
|
||||
_STLP_DMATH_INLINE(acos)
|
||||
_STLP_DMATH_INLINE(asin)
|
||||
_STLP_DMATH_INLINE(atan)
|
||||
_STLP_DMATH_INLINE2(atan2)
|
||||
_STLP_DMATH_INLINE(ceil)
|
||||
_STLP_DMATH_INLINE(cos)
|
||||
_STLP_DMATH_INLINE(cosh)
|
||||
_STLP_DMATH_INLINE(exp)
|
||||
_STLP_DMATH_INLINE(fabs)
|
||||
_STLP_DMATH_INLINE(floor)
|
||||
_STLP_DMATH_INLINE2(fmod)
|
||||
_STLP_MATH_INLINE2X(double, int*, frexp, frexp)
|
||||
_STLP_MATH_INLINE2X(double, int, ldexp, ldexp)
|
||||
_STLP_DMATH_INLINE(log)
|
||||
_STLP_DMATH_INLINE(log10)
|
||||
_STLP_MATH_INLINE2PX(double, modf, modf)
|
||||
_STLP_DMATH_INLINE(sin)
|
||||
_STLP_DMATH_INLINE(sinh)
|
||||
_STLP_DMATH_INLINE(sqrt)
|
||||
_STLP_DMATH_INLINE(tan)
|
||||
_STLP_DMATH_INLINE(tanh)
|
||||
_STLP_DMATH_INLINE2(pow)
|
||||
_STLP_DMATH_INLINE2(hypot)
|
||||
|
||||
# undef _STLP_DMATH_INLINE
|
||||
# undef _STLP_DMATH_INLINE2
|
||||
#endif
|
||||
|
||||
#if defined (__DMC__)
|
||||
# if defined (fabs)
|
||||
inline double __stlp_fabs(double __x) { return fabs(__x); }
|
||||
# undef fabs
|
||||
inline double fabs(double __x) { return __stlp_fabs(__x); }
|
||||
# endif
|
||||
# if defined (cos)
|
||||
inline double __stlp_cos(double __x) { return cos(__x); }
|
||||
# undef cos
|
||||
inline double cos(double __x) { return __stlp_cos(__x); }
|
||||
# endif
|
||||
# if defined (sin)
|
||||
inline double __stlp_sin(double __x) { return sin(__x); }
|
||||
# undef sin
|
||||
inline double sin(double __x) { return __stlp_sin(__x); }
|
||||
# endif
|
||||
# if defined (sqrt)
|
||||
inline double __stlp_sqrt(double __x) { return sqrt(__x); }
|
||||
# undef sqrt
|
||||
inline double sqrt(double __x) { return __stlp_sqrt(__x); }
|
||||
# endif
|
||||
# if defined (ldexp)
|
||||
inline double __stlp_ldexp(double __x, int __y) { return ldexp(__x, __y); }
|
||||
# undef ldexp
|
||||
inline double ldexp(double __x, int __y) { return __stlp_ldexp(__x, __y); }
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* MSVC native lib starting with .Net 2003 has already all math functions
|
||||
* in global namespace.
|
||||
* HP-UX native lib has math functions in the global namespace.
|
||||
*/
|
||||
#if (!defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1310) || defined(UNDER_CE)) && \
|
||||
(!defined (__HP_aCC) || (__HP_aCC < 30000)) && \
|
||||
!defined (__WATCOMC__)
|
||||
inline double abs(double __x)
|
||||
{ return ::fabs(__x); }
|
||||
# if !defined (__MVS__)
|
||||
_STLP_DEF_MATH_INLINE(abs, fabs)
|
||||
# else // __MVS__ has native long double abs?
|
||||
inline float abs(float __x) { return ::fabsf(__x); }
|
||||
# endif
|
||||
|
||||
_STLP_DEF_MATH_INLINE(acos, acos)
|
||||
_STLP_DEF_MATH_INLINE(asin, asin)
|
||||
_STLP_DEF_MATH_INLINE(atan, atan)
|
||||
_STLP_DEF_MATH_INLINE2(atan2, atan2)
|
||||
_STLP_DEF_MATH_INLINE(ceil, ceil)
|
||||
_STLP_DEF_MATH_INLINE(cos, cos)
|
||||
_STLP_DEF_MATH_INLINE(cosh, cosh)
|
||||
_STLP_DEF_MATH_INLINE(exp, exp)
|
||||
_STLP_DEF_MATH_INLINE(fabs, fabs)
|
||||
_STLP_DEF_MATH_INLINE(floor, floor)
|
||||
_STLP_DEF_MATH_INLINE2(fmod, fmod)
|
||||
_STLP_DEF_MATH_INLINE2PI(frexp, frexp)
|
||||
_STLP_DEF_MATH_INLINE2I(ldexp, ldexp)
|
||||
_STLP_DEF_MATH_INLINE(log, log)
|
||||
_STLP_DEF_MATH_INLINE(log10, log10)
|
||||
_STLP_DEF_MATH_INLINE2P(modf, modf)
|
||||
_STLP_DEF_MATH_INLINE(sin, sin)
|
||||
_STLP_DEF_MATH_INLINE(sinh, sinh)
|
||||
_STLP_DEF_MATH_INLINE(sqrt, sqrt)
|
||||
_STLP_DEF_MATH_INLINE(tan, tan)
|
||||
_STLP_DEF_MATH_INLINE(tanh, tanh)
|
||||
_STLP_DEF_MATH_INLINE2(pow, pow)
|
||||
|
||||
# if !defined(_STLP_MSVC) /* || (_STLP_MSVC > 1300) */ || defined(_STLP_WCE) || !defined (_MSC_EXTENSIONS) /* && !defined(_STLP_WCE_NET) */
|
||||
# ifndef _STLP_NO_VENDOR_MATH_F
|
||||
# ifndef __sun
|
||||
inline float pow(float __x, int __y) { return _STLP_CMATH_FUNC_NAMESPACE::powf(__x, __STATIC_CAST(float,__y)); }
|
||||
# else
|
||||
inline float pow(float __x, int __y) { return ::__powf(__x, __STATIC_CAST(float,__y)); }
|
||||
# endif
|
||||
# else
|
||||
inline float pow(float __x, int __y) { return __STATIC_CAST(float, _STLP_CMATH_FUNC_NAMESPACE::pow(__x, __STATIC_CAST(float,__y))); }
|
||||
# endif
|
||||
inline double pow(double __x, int __y) { return _STLP_CMATH_FUNC_NAMESPACE::pow(__x, __STATIC_CAST(double,__y)); }
|
||||
# if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
# if !defined(_STLP_NO_VENDOR_MATH_L)
|
||||
# ifndef __sun
|
||||
inline long double pow(long double __x, int __y) { return _STLP_CMATH_FUNC_NAMESPACE::powl(__x, __STATIC_CAST(long double,__y)); }
|
||||
# else
|
||||
# ifndef __SUNPRO_CC
|
||||
inline long double pow(long double __x, int __y) { return ::__powl(__x, __STATIC_CAST(long double,__y)); }
|
||||
# else
|
||||
inline long double pow(long double __x, int __y) { return _STLP_VENDOR_CSTD::__powl(__x, __STATIC_CAST(long double,__y)); }
|
||||
# endif
|
||||
# endif
|
||||
# else
|
||||
inline long double pow(long double __x, int __y) { return __STATIC_CAST(long double, _STLP_CMATH_FUNC_NAMESPACE::pow(__x, __STATIC_CAST(long double,__y))); }
|
||||
# endif
|
||||
# endif
|
||||
# else
|
||||
//The MS native pow version has a bugged overload so it is not imported
|
||||
//in the STLport namespace.
|
||||
//Here is the bugged version:
|
||||
//inline double pow(int __x, int __y) { return (_Pow_int(__x, __y)); }
|
||||
inline double pow(double __x, int __y) { return (_Pow_int(__x, __y)); }
|
||||
inline float pow(float __x, int __y) { return (_Pow_int(__x, __y)); }
|
||||
inline long double pow(long double __x, int __y) { return (_Pow_int(__x, __y)); }
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if (defined (_STLP_MSVC) && !defined (_STLP_WCE)) || defined (__ICL) || defined (__sun)
|
||||
# if defined (_STLP_MSVC) && (_STLP_MSVC >= 1400)
|
||||
# pragma warning (push)
|
||||
# pragma warning (disable : 4996) // hypot is deprecated.
|
||||
# endif
|
||||
_STLP_MATH_INLINE2XX(float, hypot, hypot)
|
||||
inline long double hypot(long double x, long double y) { return sqrt(x * x + y * y); }
|
||||
# if defined (_STLP_MSVC) && (_STLP_MSVC >= 1400)
|
||||
# pragma warning (pop)
|
||||
# endif
|
||||
#else
|
||||
# if defined (_STLP_USE_UCLIBC)
|
||||
inline double hypot(double x, double y) { return sqrt(x * x + y * y); }
|
||||
_STLP_DEF_MATH_INLINE2(hypot, hypot)
|
||||
# elif defined (_STLP_WCE)
|
||||
/* CE has a double _hypot(double,double) which we use */
|
||||
inline double hypot(double __x, double __y) { return _hypot(__x,__y); }
|
||||
_STLP_DEF_MATH_INLINE2(hypot, _hypot)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_RESTORE_FUNCTION_INTRINSIC)
|
||||
//restoration of the default intrinsic status of those functions:
|
||||
# pragma intrinsic (abs, acos, asin, atan, atan2, cos, cosh, exp, fabs, fmod, log, log10, sin, sinh, sqrt, tan, tanh)
|
||||
# if defined (_STLP_WCE)
|
||||
# pragma intrinsic (ceil, floor)
|
||||
# endif
|
||||
# pragma warning(pop)
|
||||
# undef _STLP_RESTORE_FUNCTION_INTRINSIC
|
||||
#endif // _STLP_MSVC && _STLP_MSVC <= 1300 && !_STLP_WCE && _MSC_EXTENSIONS
|
||||
|
||||
/* C++ Standard is unclear about several call to 'using ::func' if new overloads
|
||||
* of ::func appears between 2 successive 'using' calls. To avoid this potential
|
||||
* problem we provide all abs overload before the 'using' call.
|
||||
* Beware: This header inclusion has to be after all abs overload of this file.
|
||||
* The first 'using ::abs' call is going to be in the other header.
|
||||
*/
|
||||
#ifndef _STLP_INTERNAL_CSTDLIB
|
||||
# include <stl/_cstdlib.h>
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_IMPORT_VENDOR_CSTD) && !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
using ::abs;
|
||||
using ::acos;
|
||||
using ::asin;
|
||||
using ::atan;
|
||||
using ::atan2;
|
||||
using ::ceil;
|
||||
using ::cos;
|
||||
using ::cosh;
|
||||
using ::exp;
|
||||
using ::fabs;
|
||||
using ::floor;
|
||||
using ::fmod;
|
||||
using ::frexp;
|
||||
/*
|
||||
Because of some weird interaction between STLport headers
|
||||
and native HP-UX headers, when compiled with _STLP_DEBUG
|
||||
macro defined with aC++, hypot() is not declared.
|
||||
At some point we'll need to get to the bottom line of
|
||||
this problem.
|
||||
*/
|
||||
#if !(defined(__HP_aCC) && defined(_STLP_DEBUG))
|
||||
using ::hypot;
|
||||
#endif
|
||||
using ::ldexp;
|
||||
using ::log;
|
||||
using ::log10;
|
||||
using ::modf;
|
||||
using ::pow;
|
||||
using ::sin;
|
||||
using ::sinh;
|
||||
using ::sqrt;
|
||||
using ::tan;
|
||||
using ::tanh;
|
||||
_STLP_END_NAMESPACE
|
||||
# if defined (__BORLANDC__) && (__BORLANDC__ >= 0x560) && !defined (__linux__)
|
||||
using _STLP_VENDOR_CSTD::_ecvt;
|
||||
using _STLP_VENDOR_CSTD::_fcvt;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_CMATH */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
442
extern/STLport/5.2.1/stlport/stl/_codecvt.h
vendored
Normal file
442
extern/STLport/5.2.1/stlport/stl/_codecvt.h
vendored
Normal file
@@ -0,0 +1,442 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
// WARNING: This is an internal header file, included by other C++
|
||||
// standard library headers. You should not attempt to use this header
|
||||
// file directly.
|
||||
|
||||
|
||||
#ifndef _STLP_INTERNAL_CODECVT_H
|
||||
#define _STLP_INTERNAL_CODECVT_H
|
||||
|
||||
#ifndef _STLP_C_LOCALE_H
|
||||
# include <stl/c_locale.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_LOCALE_H
|
||||
# include <stl/_locale.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALGOBASE_H
|
||||
# include <stl/_algobase.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
class _STLP_CLASS_DECLSPEC codecvt_base {
|
||||
public:
|
||||
enum result {ok, partial, error, noconv};
|
||||
};
|
||||
|
||||
template <class _InternT, class _ExternT, class _StateT>
|
||||
class codecvt : public locale::facet, public codecvt_base {
|
||||
public:
|
||||
typedef _InternT intern_type;
|
||||
typedef _ExternT extern_type;
|
||||
typedef _StateT state_type;
|
||||
|
||||
#if defined (_STLP_MSVC) && (_STLP_MSVC < 1300)
|
||||
/* For the moment VC6 do not support this facet default implementation
|
||||
* because of the static locale::id instance. When VC6 see this definition
|
||||
* it goes crasy with locale::id static instances and all the has_facet tests
|
||||
* unit tests are failing.
|
||||
*/
|
||||
};
|
||||
#else
|
||||
explicit codecvt(size_t __refs = 0) : locale::facet(__refs) {}
|
||||
|
||||
result out(state_type& __state,
|
||||
const intern_type* __from,
|
||||
const intern_type* __from_end,
|
||||
const intern_type*& __from_next,
|
||||
extern_type* __to,
|
||||
extern_type* __to_limit,
|
||||
extern_type*& __to_next) const {
|
||||
_STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT)
|
||||
return do_out(__state,
|
||||
__from, __from_end, __from_next,
|
||||
__to, __to_limit, __to_next);
|
||||
}
|
||||
|
||||
result unshift(state_type& __state,
|
||||
extern_type* __to,
|
||||
extern_type* __to_limit,
|
||||
extern_type*& __to_next) const {
|
||||
_STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT)
|
||||
return do_unshift(__state, __to, __to_limit, __to_next);
|
||||
}
|
||||
|
||||
result in(state_type& __state,
|
||||
const extern_type* __from,
|
||||
const extern_type* __from_end,
|
||||
const extern_type*& __from_next,
|
||||
intern_type* __to,
|
||||
intern_type* __to_limit,
|
||||
intern_type*& __to_next) const {
|
||||
_STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT)
|
||||
return do_in(__state,
|
||||
__from, __from_end, __from_next,
|
||||
__to, __to_limit, __to_next);
|
||||
}
|
||||
|
||||
int encoding() const _STLP_NOTHROW { return do_encoding(); }
|
||||
|
||||
bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); }
|
||||
|
||||
int length(state_type& __state,
|
||||
const extern_type* __from,
|
||||
const extern_type* __from_end,
|
||||
size_t __max) const {
|
||||
_STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT)
|
||||
return do_length(__state, __from, __from_end, __max);
|
||||
}
|
||||
|
||||
int max_length() const _STLP_NOTHROW { return do_max_length(); }
|
||||
|
||||
static locale::id id;
|
||||
|
||||
protected:
|
||||
~codecvt() {}
|
||||
|
||||
virtual result do_out(state_type&,
|
||||
const intern_type* __from,
|
||||
const intern_type*,
|
||||
const intern_type*& __from_next,
|
||||
extern_type* __to,
|
||||
extern_type*,
|
||||
extern_type*& __to_next) const
|
||||
{ __from_next = __from; __to_next = __to; return noconv; }
|
||||
|
||||
virtual result do_in (state_type&,
|
||||
const extern_type* __from,
|
||||
const extern_type*,
|
||||
const extern_type*& __from_next,
|
||||
intern_type* __to,
|
||||
intern_type*,
|
||||
intern_type*& __to_next) const
|
||||
{ __from_next = __from; __to_next = __to; return noconv; }
|
||||
|
||||
virtual result do_unshift(state_type&,
|
||||
extern_type* __to,
|
||||
extern_type*,
|
||||
extern_type*& __to_next) const
|
||||
{ __to_next = __to; return noconv; }
|
||||
|
||||
virtual int do_encoding() const _STLP_NOTHROW
|
||||
{ return 1; }
|
||||
|
||||
virtual bool do_always_noconv() const _STLP_NOTHROW
|
||||
{ return true; }
|
||||
|
||||
virtual int do_length(state_type&,
|
||||
const extern_type* __from,
|
||||
const extern_type* __end,
|
||||
size_t __max) const
|
||||
{ return (int)(min) ( __STATIC_CAST(size_t, (__end - __from)), __max); }
|
||||
|
||||
virtual int do_max_length() const _STLP_NOTHROW
|
||||
{ return 1; }
|
||||
|
||||
private:
|
||||
codecvt(const codecvt<intern_type, extern_type, state_type>&);
|
||||
codecvt<intern_type, extern_type, state_type>& operator = (const codecvt<intern_type, extern_type, state_type>&);
|
||||
};
|
||||
|
||||
# if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x590)
|
||||
template <class _InternT, class _ExternT, class _StateT>
|
||||
locale::id codecvt<_InternT, _ExternT, _StateT>::id;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
template <class _InternT, class _ExternT, class _StateT>
|
||||
class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> {};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC codecvt<char, char, mbstate_t>
|
||||
: public locale::facet, public codecvt_base {
|
||||
public:
|
||||
typedef char intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
explicit codecvt(size_t __refs = 0) : locale::facet(__refs) {}
|
||||
|
||||
result out(state_type& __state,
|
||||
const char* __from,
|
||||
const char* __from_end,
|
||||
const char*& __from_next,
|
||||
char* __to,
|
||||
char* __to_limit,
|
||||
char*& __to_next) const {
|
||||
_STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT)
|
||||
return do_out(__state,
|
||||
__from, __from_end, __from_next,
|
||||
__to, __to_limit, __to_next);
|
||||
}
|
||||
|
||||
result unshift(state_type& __state,
|
||||
char* __to, char* __to_limit, char*& __to_next) const {
|
||||
_STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT)
|
||||
return do_unshift(__state, __to, __to_limit, __to_next);
|
||||
}
|
||||
|
||||
result in(state_type& __state,
|
||||
const char* __from,
|
||||
const char* __from_end,
|
||||
const char*& __from_next,
|
||||
char* __to,
|
||||
char* __to_limit,
|
||||
char*& __to_next) const {
|
||||
_STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT)
|
||||
return do_in(__state,
|
||||
__from, __from_end, __from_next,
|
||||
__to, __to_limit, __to_next);
|
||||
}
|
||||
|
||||
int encoding() const _STLP_NOTHROW { return do_encoding(); }
|
||||
|
||||
bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); }
|
||||
|
||||
int length(state_type& __state,
|
||||
const char* __from, const char* __from_end,
|
||||
size_t __max) const {
|
||||
_STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT)
|
||||
return do_length(__state, __from, __from_end, __max);
|
||||
}
|
||||
|
||||
int max_length() const _STLP_NOTHROW { return do_max_length(); }
|
||||
|
||||
static _STLP_STATIC_DECLSPEC locale::id id;
|
||||
|
||||
protected:
|
||||
~codecvt();
|
||||
|
||||
virtual result do_out(state_type& /* __state */,
|
||||
const char* __from,
|
||||
const char* /* __from_end */,
|
||||
const char*& __from_next,
|
||||
char* __to,
|
||||
char* /* __to_limit */,
|
||||
char*& __to_next) const;
|
||||
|
||||
virtual result do_in (state_type& /* __state */ ,
|
||||
const char* __from,
|
||||
const char* /* __from_end */,
|
||||
const char*& __from_next,
|
||||
char* __to,
|
||||
char* /* __to_end */,
|
||||
char*& __to_next) const;
|
||||
|
||||
virtual result do_unshift(state_type& /* __state */,
|
||||
char* __to,
|
||||
char* /* __to_limit */,
|
||||
char*& __to_next) const;
|
||||
|
||||
virtual int do_encoding() const _STLP_NOTHROW;
|
||||
virtual bool do_always_noconv() const _STLP_NOTHROW;
|
||||
virtual int do_length(state_type& __state,
|
||||
const char* __from,
|
||||
const char* __end,
|
||||
size_t __max) const;
|
||||
virtual int do_max_length() const _STLP_NOTHROW;
|
||||
private:
|
||||
codecvt(const codecvt<char, char, mbstate_t>&);
|
||||
codecvt<char, char, mbstate_t>& operator =(const codecvt<char, char, mbstate_t>&);
|
||||
};
|
||||
|
||||
# ifndef _STLP_NO_WCHAR_T
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC codecvt<wchar_t, char, mbstate_t>
|
||||
: public locale::facet, public codecvt_base {
|
||||
public:
|
||||
typedef wchar_t intern_type;
|
||||
typedef char extern_type;
|
||||
typedef mbstate_t state_type;
|
||||
|
||||
explicit codecvt(size_t __refs = 0) : locale::facet(__refs) {}
|
||||
|
||||
result out(state_type& __state,
|
||||
const wchar_t* __from,
|
||||
const wchar_t* __from_end,
|
||||
const wchar_t*& __from_next,
|
||||
char* __to,
|
||||
char* __to_limit,
|
||||
char*& __to_next) const {
|
||||
_STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT)
|
||||
return do_out(__state,
|
||||
__from, __from_end, __from_next,
|
||||
__to, __to_limit, __to_next);
|
||||
}
|
||||
|
||||
result unshift(state_type& __state,
|
||||
char* __to, char* __to_limit, char*& __to_next) const {
|
||||
_STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT)
|
||||
return do_unshift(__state, __to, __to_limit, __to_next);
|
||||
}
|
||||
|
||||
result in(state_type& __state,
|
||||
const char* __from,
|
||||
const char* __from_end,
|
||||
const char*& __from_next,
|
||||
wchar_t* __to,
|
||||
wchar_t* __to_limit,
|
||||
wchar_t*& __to_next) const {
|
||||
_STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_VERBOSE_ASSERT(__to <= __to_limit, _StlMsg_INVALID_ARGUMENT)
|
||||
return do_in(__state,
|
||||
__from, __from_end, __from_next,
|
||||
__to, __to_limit, __to_next);
|
||||
}
|
||||
|
||||
int encoding() const _STLP_NOTHROW { return do_encoding(); }
|
||||
|
||||
bool always_noconv() const _STLP_NOTHROW { return do_always_noconv(); }
|
||||
|
||||
int length(state_type& __state,
|
||||
const char* __from, const char* __from_end,
|
||||
size_t __max) const {
|
||||
_STLP_VERBOSE_ASSERT(__from <= __from_end, _StlMsg_INVALID_ARGUMENT)
|
||||
return do_length(__state, __from, __from_end, __max);
|
||||
}
|
||||
|
||||
int max_length() const _STLP_NOTHROW { return do_max_length(); }
|
||||
|
||||
static _STLP_STATIC_DECLSPEC locale::id id;
|
||||
|
||||
protected:
|
||||
~codecvt();
|
||||
|
||||
virtual result do_out(state_type& __state,
|
||||
const wchar_t* __from,
|
||||
const wchar_t* __from_end,
|
||||
const wchar_t*& __from_next,
|
||||
char* __to,
|
||||
char* __to_limit,
|
||||
char*& __to_next) const;
|
||||
|
||||
virtual result do_in (state_type& __state,
|
||||
const char* __from,
|
||||
const char* __from_end,
|
||||
const char*& __from_next,
|
||||
wchar_t* __to,
|
||||
wchar_t* __to_limit,
|
||||
wchar_t*& __to_next) const;
|
||||
|
||||
virtual result do_unshift(state_type& __state,
|
||||
char* __to,
|
||||
char* __to_limit,
|
||||
char*& __to_next) const;
|
||||
|
||||
virtual int do_encoding() const _STLP_NOTHROW;
|
||||
|
||||
virtual bool do_always_noconv() const _STLP_NOTHROW;
|
||||
|
||||
virtual int do_length(state_type& __state,
|
||||
const char* __from,
|
||||
const char* __end,
|
||||
size_t __max) const;
|
||||
|
||||
virtual int do_max_length() const _STLP_NOTHROW;
|
||||
|
||||
private:
|
||||
codecvt(const codecvt<wchar_t, char, mbstate_t>&);
|
||||
codecvt<wchar_t, char, mbstate_t>& operator = (const codecvt<wchar_t, char, mbstate_t>&);
|
||||
};
|
||||
|
||||
# endif
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC codecvt_byname<char, char, mbstate_t>
|
||||
: public codecvt<char, char, mbstate_t> {
|
||||
public:
|
||||
explicit codecvt_byname(const char* __name, size_t __refs = 0);
|
||||
~codecvt_byname();
|
||||
private:
|
||||
codecvt_byname(const codecvt_byname<char, char, mbstate_t>&);
|
||||
codecvt_byname<char, char, mbstate_t>& operator =(const codecvt_byname<char, char, mbstate_t>&);
|
||||
};
|
||||
|
||||
# ifndef _STLP_NO_WCHAR_T
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC codecvt_byname<wchar_t, char, mbstate_t>
|
||||
: public codecvt<wchar_t, char, mbstate_t> {
|
||||
friend class _Locale_impl;
|
||||
public:
|
||||
explicit codecvt_byname(const char * __name, size_t __refs = 0);
|
||||
|
||||
protected:
|
||||
~codecvt_byname();
|
||||
|
||||
virtual result do_out(state_type& __state,
|
||||
const wchar_t* __from,
|
||||
const wchar_t* __from_end,
|
||||
const wchar_t*& __from_next,
|
||||
char* __to,
|
||||
char* __to_limit,
|
||||
char*& __to_next) const;
|
||||
|
||||
virtual result do_in (state_type& __state,
|
||||
const char* __from,
|
||||
const char* __from_end,
|
||||
const char*& __from_next,
|
||||
wchar_t* __to,
|
||||
wchar_t* __to_limit,
|
||||
wchar_t*& __to_next) const;
|
||||
|
||||
virtual result do_unshift(state_type& __state,
|
||||
char* __to,
|
||||
char* __to_limit,
|
||||
char*& __to_next) const;
|
||||
|
||||
virtual int do_encoding() const _STLP_NOTHROW;
|
||||
|
||||
virtual bool do_always_noconv() const _STLP_NOTHROW;
|
||||
|
||||
virtual int do_length(state_type& __state,
|
||||
const char* __from,
|
||||
const char* __end,
|
||||
size_t __max) const;
|
||||
|
||||
virtual int do_max_length() const _STLP_NOTHROW;
|
||||
|
||||
private:
|
||||
codecvt_byname(_Locale_codecvt* __cvt)
|
||||
: _M_codecvt(__cvt) {}
|
||||
|
||||
codecvt_byname(const codecvt_byname<wchar_t, char, mbstate_t>&);
|
||||
codecvt_byname<wchar_t, char, mbstate_t>& operator =(const codecvt_byname<wchar_t, char, mbstate_t>&);
|
||||
_Locale_codecvt* _M_codecvt;
|
||||
};
|
||||
|
||||
# endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_CODECVT_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
176
extern/STLport/5.2.1/stlport/stl/_collate.h
vendored
Normal file
176
extern/STLport/5.2.1/stlport/stl/_collate.h
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
// WARNING: This is an internal header file, included by other C++
|
||||
// standard library headers. You should not attempt to use this header
|
||||
// file directly.
|
||||
|
||||
#ifndef _STLP_INTERNAL_COLLATE_H
|
||||
#define _STLP_INTERNAL_COLLATE_H
|
||||
|
||||
#ifndef _STLP_C_LOCALE_H
|
||||
# include <stl/c_locale.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_LOCALE_H
|
||||
# include <stl/_locale.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_STRING_H
|
||||
# include <stl/_string.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _CharT> class collate {};
|
||||
template <class _CharT> class collate_byname {};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC collate<char> : public locale::facet {
|
||||
public:
|
||||
typedef char char_type;
|
||||
typedef string string_type;
|
||||
|
||||
explicit collate(size_t __refs = 0) : locale::facet(__refs) {}
|
||||
|
||||
int compare(const char* __low1, const char* __high1,
|
||||
const char* __low2, const char* __high2) const {
|
||||
return do_compare( __low1, __high1, __low2, __high2);
|
||||
}
|
||||
|
||||
string_type transform(const char* __low, const char* __high) const {
|
||||
return do_transform(__low, __high);
|
||||
}
|
||||
|
||||
long hash(const char* __low, const char* __high) const
|
||||
{ return do_hash(__low, __high); }
|
||||
|
||||
static _STLP_STATIC_DECLSPEC locale::id id;
|
||||
|
||||
protected:
|
||||
~collate();
|
||||
|
||||
virtual int do_compare(const char*, const char*,
|
||||
const char*, const char*) const;
|
||||
virtual string_type do_transform(const char*, const char*) const;
|
||||
virtual long do_hash(const char*, const char*) const;
|
||||
private:
|
||||
collate(const collate<char>&);
|
||||
collate<char>& operator =(const collate<char>&);
|
||||
};
|
||||
|
||||
# ifndef _STLP_NO_WCHAR_T
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC collate<wchar_t> : public locale::facet {
|
||||
public:
|
||||
typedef wchar_t char_type;
|
||||
typedef wstring string_type;
|
||||
|
||||
explicit collate(size_t __refs = 0) : locale::facet(__refs) {}
|
||||
|
||||
int compare(const wchar_t* __low1, const wchar_t* __high1,
|
||||
const wchar_t* __low2, const wchar_t* __high2) const {
|
||||
return do_compare( __low1, __high1, __low2, __high2);
|
||||
}
|
||||
|
||||
string_type transform(const wchar_t* __low, const wchar_t* __high) const {
|
||||
return do_transform(__low, __high);
|
||||
}
|
||||
|
||||
long hash(const wchar_t* __low, const wchar_t* __high) const
|
||||
{ return do_hash(__low, __high); }
|
||||
|
||||
static _STLP_STATIC_DECLSPEC locale::id id;
|
||||
|
||||
protected:
|
||||
~collate();
|
||||
|
||||
virtual int do_compare(const wchar_t*, const wchar_t*,
|
||||
const wchar_t*, const wchar_t*) const;
|
||||
virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
|
||||
virtual long do_hash(const wchar_t* __low, const wchar_t* __high) const;
|
||||
private:
|
||||
collate(const collate<wchar_t>&);
|
||||
collate<wchar_t>& operator = (const collate<wchar_t>&);
|
||||
};
|
||||
|
||||
# endif /* NO_WCHAR_T */
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC collate_byname<char>: public collate<char> {
|
||||
friend class _Locale_impl;
|
||||
public:
|
||||
explicit collate_byname(const char* __name, size_t __refs = 0);
|
||||
|
||||
protected:
|
||||
~collate_byname();
|
||||
|
||||
virtual int do_compare(const char*, const char*,
|
||||
const char*, const char*) const;
|
||||
virtual string_type do_transform(const char*, const char*) const;
|
||||
|
||||
private:
|
||||
collate_byname(_Locale_collate *__coll)
|
||||
: _M_collate(__coll) {}
|
||||
_Locale_collate* _M_collate;
|
||||
collate_byname(const collate_byname<char>&);
|
||||
collate_byname<char>& operator =(const collate_byname<char>&);
|
||||
};
|
||||
|
||||
# ifndef _STLP_NO_WCHAR_T
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC collate_byname<wchar_t>: public collate<wchar_t> {
|
||||
friend class _Locale_impl;
|
||||
public:
|
||||
explicit collate_byname(const char * __name, size_t __refs = 0);
|
||||
|
||||
protected:
|
||||
~collate_byname();
|
||||
|
||||
virtual int do_compare(const wchar_t*, const wchar_t*,
|
||||
const wchar_t*, const wchar_t*) const;
|
||||
virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
|
||||
|
||||
private:
|
||||
collate_byname(_Locale_collate *__coll)
|
||||
: _M_collate(__coll) {}
|
||||
_Locale_collate* _M_collate;
|
||||
collate_byname(const collate_byname<wchar_t>&);
|
||||
collate_byname<wchar_t>& operator =(const collate_byname<wchar_t>&);
|
||||
};
|
||||
|
||||
# endif /* NO_WCHAR_T */
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
bool
|
||||
__locale_do_operator_call (const locale& __loc,
|
||||
const basic_string<_CharT, _Traits, _Alloc>& __x,
|
||||
const basic_string<_CharT, _Traits, _Alloc>& __y) {
|
||||
collate<_CharT> const& __coll = use_facet<collate<_CharT> >(__loc);
|
||||
return __coll.compare(__x.data(), __x.data() + __x.size(),
|
||||
__y.data(), __y.data() + __y.size()) < 0;
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_COLLATE_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
145
extern/STLport/5.2.1/stlport/stl/_complex.c
vendored
Normal file
145
extern/STLport/5.2.1/stlport/stl/_complex.c
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_COMPLEX_C
|
||||
#define _STLP_COMPLEX_C
|
||||
|
||||
#ifndef _STLP_INTERNAL_COMPLEX
|
||||
# include <stl/_complex.h>
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_USE_NO_IOSTREAMS)
|
||||
# ifndef _STLP_INTERNAL_ISTREAM
|
||||
# include <stl/_istream.h>
|
||||
# endif
|
||||
|
||||
# ifndef _STLP_INTERNAL_SSTREAM
|
||||
# include <stl/_sstream.h>
|
||||
# endif
|
||||
|
||||
# ifndef _STLP_STRING_IO_H
|
||||
# include <stl/_string_io.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
// Non-inline member functions.
|
||||
|
||||
template <class _Tp>
|
||||
void complex<_Tp>::_div(const _Tp& __z1_r, const _Tp& __z1_i,
|
||||
const _Tp& __z2_r, const _Tp& __z2_i,
|
||||
_Tp& __res_r, _Tp& __res_i) {
|
||||
_Tp __ar = __z2_r >= 0 ? __z2_r : -__z2_r;
|
||||
_Tp __ai = __z2_i >= 0 ? __z2_i : -__z2_i;
|
||||
|
||||
if (__ar <= __ai) {
|
||||
_Tp __ratio = __z2_r / __z2_i;
|
||||
_Tp __denom = __z2_i * (1 + __ratio * __ratio);
|
||||
__res_r = (__z1_r * __ratio + __z1_i) / __denom;
|
||||
__res_i = (__z1_i * __ratio - __z1_r) / __denom;
|
||||
}
|
||||
else {
|
||||
_Tp __ratio = __z2_i / __z2_r;
|
||||
_Tp __denom = __z2_r * (1 + __ratio * __ratio);
|
||||
__res_r = (__z1_r + __z1_i * __ratio) / __denom;
|
||||
__res_i = (__z1_i - __z1_r * __ratio) / __denom;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
void complex<_Tp>::_div(const _Tp& __z1_r,
|
||||
const _Tp& __z2_r, const _Tp& __z2_i,
|
||||
_Tp& __res_r, _Tp& __res_i) {
|
||||
_Tp __ar = __z2_r >= 0 ? __z2_r : -__z2_r;
|
||||
_Tp __ai = __z2_i >= 0 ? __z2_i : -__z2_i;
|
||||
|
||||
if (__ar <= __ai) {
|
||||
_Tp __ratio = __z2_r / __z2_i;
|
||||
_Tp __denom = __z2_i * (1 + __ratio * __ratio);
|
||||
__res_r = (__z1_r * __ratio) / __denom;
|
||||
__res_i = - __z1_r / __denom;
|
||||
}
|
||||
else {
|
||||
_Tp __ratio = __z2_i / __z2_r;
|
||||
_Tp __denom = __z2_r * (1 + __ratio * __ratio);
|
||||
__res_r = __z1_r / __denom;
|
||||
__res_i = - (__z1_r * __ratio) / __denom;
|
||||
}
|
||||
}
|
||||
|
||||
// I/O.
|
||||
#if !defined (_STLP_USE_NO_IOSTREAMS)
|
||||
|
||||
// Complex output, in the form (re,im). We use a two-step process
|
||||
// involving stringstream so that we get the padding right.
|
||||
template <class _Tp, class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __z) {
|
||||
basic_ostringstream<_CharT, _Traits, allocator<_CharT> > __tmp;
|
||||
__tmp.flags(__os.flags());
|
||||
__tmp.imbue(__os.getloc());
|
||||
__tmp.precision(__os.precision());
|
||||
__tmp << '(' << __z.real() << ',' << __z.imag() << ')';
|
||||
return __os << __tmp.str();
|
||||
}
|
||||
|
||||
// Complex input from arbitrary streams. Note that results in some
|
||||
// locales may be confusing, since the decimal character varies with
|
||||
// locale and the separator between real and imaginary parts does not.
|
||||
|
||||
template <class _Tp, class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>& _STLP_CALL
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __z) {
|
||||
_Tp __re = 0;
|
||||
_Tp __im = 0;
|
||||
|
||||
const ctype<_CharT>& __c_type = *__is._M_ctype_facet();
|
||||
|
||||
const char __punct[4] = "(,)";
|
||||
_CharT __wpunct[3];
|
||||
__c_type.widen(__punct, __punct + 3, __wpunct);
|
||||
|
||||
_CharT __c;
|
||||
|
||||
__is >> __c;
|
||||
if (_Traits::eq(__c, __wpunct[0])) { // Left paren
|
||||
__is >> __re >> __c;
|
||||
if (_Traits::eq(__c, __wpunct[1])) // Comma
|
||||
__is >> __im >> __c;
|
||||
if (!_Traits::eq(__c, __wpunct[2])) // Right paren
|
||||
__is.setstate(ios_base::failbit);
|
||||
}
|
||||
else {
|
||||
__is.putback(__c);
|
||||
__is >> __re;
|
||||
}
|
||||
|
||||
if (__is)
|
||||
__z = complex<_Tp>(__re, __im);
|
||||
return __is;
|
||||
}
|
||||
|
||||
#endif /* _STLP_USE_NO_IOSTREAMS */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_COMPLEX_C */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
935
extern/STLport/5.2.1/stlport/stl/_complex.h
vendored
Normal file
935
extern/STLport/5.2.1/stlport/stl/_complex.h
vendored
Normal file
@@ -0,0 +1,935 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_INTERNAL_COMPLEX
|
||||
#define _STLP_INTERNAL_COMPLEX
|
||||
|
||||
// This header declares the template class complex, as described in
|
||||
// in the draft C++ standard. Single-precision complex numbers
|
||||
// are complex<float>, double-precision are complex<double>, and
|
||||
// quad precision are complex<long double>.
|
||||
|
||||
// Note that the template class complex is declared within namespace
|
||||
// std, as called for by the draft C++ standard.
|
||||
|
||||
#ifndef _STLP_INTERNAL_CMATH
|
||||
# include <stl/_cmath.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _Tp>
|
||||
struct complex {
|
||||
typedef _Tp value_type;
|
||||
typedef complex<_Tp> _Self;
|
||||
|
||||
// Constructors, destructor, assignment operator.
|
||||
complex() : _M_re(0), _M_im(0) {}
|
||||
complex(const value_type& __x)
|
||||
: _M_re(__x), _M_im(0) {}
|
||||
complex(const value_type& __x, const value_type& __y)
|
||||
: _M_re(__x), _M_im(__y) {}
|
||||
complex(const _Self& __z)
|
||||
: _M_re(__z._M_re), _M_im(__z._M_im) {}
|
||||
|
||||
_Self& operator=(const _Self& __z) {
|
||||
_M_re = __z._M_re;
|
||||
_M_im = __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES) && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
template <class _Tp2>
|
||||
explicit complex(const complex<_Tp2>& __z)
|
||||
: _M_re(__z._M_re), _M_im(__z._M_im) {}
|
||||
|
||||
template <class _Tp2>
|
||||
_Self& operator=(const complex<_Tp2>& __z) {
|
||||
_M_re = __z._M_re;
|
||||
_M_im = __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
// Element access.
|
||||
value_type real() const { return _M_re; }
|
||||
value_type imag() const { return _M_im; }
|
||||
|
||||
// Arithmetic op= operations involving one real argument.
|
||||
|
||||
_Self& operator= (const value_type& __x) {
|
||||
_M_re = __x;
|
||||
_M_im = 0;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator+= (const value_type& __x) {
|
||||
_M_re += __x;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator-= (const value_type& __x) {
|
||||
_M_re -= __x;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator*= (const value_type& __x) {
|
||||
_M_re *= __x;
|
||||
_M_im *= __x;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator/= (const value_type& __x) {
|
||||
_M_re /= __x;
|
||||
_M_im /= __x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Arithmetic op= operations involving two complex arguments.
|
||||
|
||||
static void _STLP_CALL _div(const value_type& __z1_r, const value_type& __z1_i,
|
||||
const value_type& __z2_r, const value_type& __z2_i,
|
||||
value_type& __res_r, value_type& __res_i);
|
||||
|
||||
static void _STLP_CALL _div(const value_type& __z1_r,
|
||||
const value_type& __z2_r, const value_type& __z2_i,
|
||||
value_type& __res_r, value_type& __res_i);
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES) // && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
|
||||
template <class _Tp2> _Self& operator+= (const complex<_Tp2>& __z) {
|
||||
_M_re += __z._M_re;
|
||||
_M_im += __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp2> _Self& operator-= (const complex<_Tp2>& __z) {
|
||||
_M_re -= __z._M_re;
|
||||
_M_im -= __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp2> _Self& operator*= (const complex<_Tp2>& __z) {
|
||||
value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
|
||||
value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp2> _Self& operator/= (const complex<_Tp2>& __z) {
|
||||
value_type __r;
|
||||
value_type __i;
|
||||
_div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
_Self& operator+= (const _Self& __z) {
|
||||
_M_re += __z._M_re;
|
||||
_M_im += __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator-= (const _Self& __z) {
|
||||
_M_re -= __z._M_re;
|
||||
_M_im -= __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator*= (const _Self& __z) {
|
||||
value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
|
||||
value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator/= (const _Self& __z) {
|
||||
value_type __r;
|
||||
value_type __i;
|
||||
_div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Data members.
|
||||
value_type _M_re;
|
||||
value_type _M_im;
|
||||
};
|
||||
|
||||
// Explicit specializations for float, double, long double. The only
|
||||
// reason for these specializations is to enable automatic conversions
|
||||
// from complex<float> to complex<double>, and complex<double> to
|
||||
// complex<long double>.
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct _STLP_CLASS_DECLSPEC complex<float> {
|
||||
typedef float value_type;
|
||||
typedef complex<float> _Self;
|
||||
// Constructors, destructor, assignment operator.
|
||||
|
||||
complex(value_type __x = 0.0f, value_type __y = 0.0f)
|
||||
: _M_re(__x), _M_im(__y) {}
|
||||
|
||||
complex(const complex<float>& __z) : _M_re(__z._M_re), _M_im(__z._M_im) {}
|
||||
|
||||
inline explicit complex(const complex<double>& __z);
|
||||
#ifndef _STLP_NO_LONG_DOUBLE
|
||||
inline explicit complex(const complex<long double>& __z);
|
||||
#endif
|
||||
// Element access.
|
||||
value_type real() const { return _M_re; }
|
||||
value_type imag() const { return _M_im; }
|
||||
|
||||
// Arithmetic op= operations involving one real argument.
|
||||
|
||||
_Self& operator= (value_type __x) {
|
||||
_M_re = __x;
|
||||
_M_im = 0.0f;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator+= (value_type __x) {
|
||||
_M_re += __x;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator-= (value_type __x) {
|
||||
_M_re -= __x;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator*= (value_type __x) {
|
||||
_M_re *= __x;
|
||||
_M_im *= __x;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator/= (value_type __x) {
|
||||
_M_re /= __x;
|
||||
_M_im /= __x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Arithmetic op= operations involving two complex arguments.
|
||||
|
||||
static void _STLP_CALL _div(const float& __z1_r, const float& __z1_i,
|
||||
const float& __z2_r, const float& __z2_i,
|
||||
float& __res_r, float& __res_i);
|
||||
|
||||
static void _STLP_CALL _div(const float& __z1_r,
|
||||
const float& __z2_r, const float& __z2_i,
|
||||
float& __res_r, float& __res_i);
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _Tp2>
|
||||
complex<float>& operator=(const complex<_Tp2>& __z) {
|
||||
_M_re = __z._M_re;
|
||||
_M_im = __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp2>
|
||||
complex<float>& operator+= (const complex<_Tp2>& __z) {
|
||||
_M_re += __z._M_re;
|
||||
_M_im += __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp2>
|
||||
complex<float>& operator-= (const complex<_Tp2>& __z) {
|
||||
_M_re -= __z._M_re;
|
||||
_M_im -= __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp2>
|
||||
complex<float>& operator*= (const complex<_Tp2>& __z) {
|
||||
float __r = _M_re * __z._M_re - _M_im * __z._M_im;
|
||||
float __i = _M_re * __z._M_im + _M_im * __z._M_re;
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp2>
|
||||
complex<float>& operator/= (const complex<_Tp2>& __z) {
|
||||
float __r;
|
||||
float __i;
|
||||
_div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
_Self& operator=(const _Self& __z) {
|
||||
_M_re = __z._M_re;
|
||||
_M_im = __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator+= (const _Self& __z) {
|
||||
_M_re += __z._M_re;
|
||||
_M_im += __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator-= (const _Self& __z) {
|
||||
_M_re -= __z._M_re;
|
||||
_M_im -= __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator*= (const _Self& __z) {
|
||||
value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
|
||||
value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator/= (const _Self& __z) {
|
||||
value_type __r;
|
||||
value_type __i;
|
||||
_div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Data members.
|
||||
value_type _M_re;
|
||||
value_type _M_im;
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct _STLP_CLASS_DECLSPEC complex<double> {
|
||||
typedef double value_type;
|
||||
typedef complex<double> _Self;
|
||||
|
||||
// Constructors, destructor, assignment operator.
|
||||
|
||||
complex(value_type __x = 0.0, value_type __y = 0.0)
|
||||
: _M_re(__x), _M_im(__y) {}
|
||||
|
||||
complex(const complex<double>& __z)
|
||||
: _M_re(__z._M_re), _M_im(__z._M_im) {}
|
||||
inline complex(const complex<float>& __z);
|
||||
#if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
explicit inline complex(const complex<long double>& __z);
|
||||
#endif
|
||||
// Element access.
|
||||
value_type real() const { return _M_re; }
|
||||
value_type imag() const { return _M_im; }
|
||||
|
||||
// Arithmetic op= operations involving one real argument.
|
||||
|
||||
_Self& operator= (value_type __x) {
|
||||
_M_re = __x;
|
||||
_M_im = 0.0;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator+= (value_type __x) {
|
||||
_M_re += __x;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator-= (value_type __x) {
|
||||
_M_re -= __x;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator*= (value_type __x) {
|
||||
_M_re *= __x;
|
||||
_M_im *= __x;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator/= (value_type __x) {
|
||||
_M_re /= __x;
|
||||
_M_im /= __x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Arithmetic op= operations involving two complex arguments.
|
||||
|
||||
static void _STLP_CALL _div(const double& __z1_r, const double& __z1_i,
|
||||
const double& __z2_r, const double& __z2_i,
|
||||
double& __res_r, double& __res_i);
|
||||
static void _STLP_CALL _div(const double& __z1_r,
|
||||
const double& __z2_r, const double& __z2_i,
|
||||
double& __res_r, double& __res_i);
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES) && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
template <class _Tp2>
|
||||
complex<double>& operator=(const complex<_Tp2>& __z) {
|
||||
_M_re = __z._M_re;
|
||||
_M_im = __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp2>
|
||||
complex<double>& operator+= (const complex<_Tp2>& __z) {
|
||||
_M_re += __z._M_re;
|
||||
_M_im += __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp2>
|
||||
complex<double>& operator-= (const complex<_Tp2>& __z) {
|
||||
_M_re -= __z._M_re;
|
||||
_M_im -= __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp2>
|
||||
complex<double>& operator*= (const complex<_Tp2>& __z) {
|
||||
double __r = _M_re * __z._M_re - _M_im * __z._M_im;
|
||||
double __i = _M_re * __z._M_im + _M_im * __z._M_re;
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp2>
|
||||
complex<double>& operator/= (const complex<_Tp2>& __z) {
|
||||
double __r;
|
||||
double __i;
|
||||
_div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
_Self& operator=(const _Self& __z) {
|
||||
_M_re = __z._M_re;
|
||||
_M_im = __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator+= (const _Self& __z) {
|
||||
_M_re += __z._M_re;
|
||||
_M_im += __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator-= (const _Self& __z) {
|
||||
_M_re -= __z._M_re;
|
||||
_M_im -= __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator*= (const _Self& __z) {
|
||||
value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
|
||||
value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator/= (const _Self& __z) {
|
||||
value_type __r;
|
||||
value_type __i;
|
||||
_div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Data members.
|
||||
value_type _M_re;
|
||||
value_type _M_im;
|
||||
};
|
||||
|
||||
#if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct _STLP_CLASS_DECLSPEC complex<long double> {
|
||||
typedef long double value_type;
|
||||
typedef complex<long double> _Self;
|
||||
|
||||
// Constructors, destructor, assignment operator.
|
||||
complex(value_type __x = 0.0l, value_type __y = 0.0l)
|
||||
: _M_re(__x), _M_im(__y) {}
|
||||
|
||||
complex(const complex<long double>& __z)
|
||||
: _M_re(__z._M_re), _M_im(__z._M_im) {}
|
||||
inline complex(const complex<float>& __z);
|
||||
inline complex(const complex<double>& __z);
|
||||
|
||||
// Element access.
|
||||
value_type real() const { return _M_re; }
|
||||
value_type imag() const { return _M_im; }
|
||||
|
||||
// Arithmetic op= operations involving one real argument.
|
||||
|
||||
_Self& operator= (value_type __x) {
|
||||
_M_re = __x;
|
||||
_M_im = 0.0l;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator+= (value_type __x) {
|
||||
_M_re += __x;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator-= (value_type __x) {
|
||||
_M_re -= __x;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator*= (value_type __x) {
|
||||
_M_re *= __x;
|
||||
_M_im *= __x;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator/= (value_type __x) {
|
||||
_M_re /= __x;
|
||||
_M_im /= __x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Arithmetic op= operations involving two complex arguments.
|
||||
|
||||
static void _STLP_CALL _div(const long double& __z1_r, const long double& __z1_i,
|
||||
const long double& __z2_r, const long double& __z2_i,
|
||||
long double& __res_r, long double& __res_i);
|
||||
|
||||
static void _STLP_CALL _div(const long double& __z1_r,
|
||||
const long double& __z2_r, const long double& __z2_i,
|
||||
long double& __res_r, long double& __res_i);
|
||||
|
||||
# if defined (_STLP_MEMBER_TEMPLATES) && defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
|
||||
template <class _Tp2>
|
||||
complex<long double>& operator=(const complex<_Tp2>& __z) {
|
||||
_M_re = __z._M_re;
|
||||
_M_im = __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp2>
|
||||
complex<long double>& operator+= (const complex<_Tp2>& __z) {
|
||||
_M_re += __z._M_re;
|
||||
_M_im += __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp2>
|
||||
complex<long double>& operator-= (const complex<_Tp2>& __z) {
|
||||
_M_re -= __z._M_re;
|
||||
_M_im -= __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp2>
|
||||
complex<long double>& operator*= (const complex<_Tp2>& __z) {
|
||||
long double __r = _M_re * __z._M_re - _M_im * __z._M_im;
|
||||
long double __i = _M_re * __z._M_im + _M_im * __z._M_re;
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp2>
|
||||
complex<long double>& operator/= (const complex<_Tp2>& __z) {
|
||||
long double __r;
|
||||
long double __i;
|
||||
_div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
# endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
_Self& operator=(const _Self& __z) {
|
||||
_M_re = __z._M_re;
|
||||
_M_im = __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator+= (const _Self& __z) {
|
||||
_M_re += __z._M_re;
|
||||
_M_im += __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator-= (const _Self& __z) {
|
||||
_M_re -= __z._M_re;
|
||||
_M_im -= __z._M_im;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator*= (const _Self& __z) {
|
||||
value_type __r = _M_re * __z._M_re - _M_im * __z._M_im;
|
||||
value_type __i = _M_re * __z._M_im + _M_im * __z._M_re;
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator/= (const _Self& __z) {
|
||||
value_type __r;
|
||||
value_type __i;
|
||||
_div(_M_re, _M_im, __z._M_re, __z._M_im, __r, __i);
|
||||
_M_re = __r;
|
||||
_M_im = __i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Data members.
|
||||
value_type _M_re;
|
||||
value_type _M_im;
|
||||
};
|
||||
|
||||
#endif /* _STLP_NO_LONG_DOUBLE */
|
||||
|
||||
// Converting constructors from one of these three specialized types
|
||||
// to another.
|
||||
|
||||
inline complex<float>::complex(const complex<double>& __z)
|
||||
: _M_re((float)__z._M_re), _M_im((float)__z._M_im) {}
|
||||
inline complex<double>::complex(const complex<float>& __z)
|
||||
: _M_re(__z._M_re), _M_im(__z._M_im) {}
|
||||
#ifndef _STLP_NO_LONG_DOUBLE
|
||||
inline complex<float>::complex(const complex<long double>& __z)
|
||||
: _M_re((float)__z._M_re), _M_im((float)__z._M_im) {}
|
||||
inline complex<double>::complex(const complex<long double>& __z)
|
||||
: _M_re((double)__z._M_re), _M_im((double)__z._M_im) {}
|
||||
inline complex<long double>::complex(const complex<float>& __z)
|
||||
: _M_re(__z._M_re), _M_im(__z._M_im) {}
|
||||
inline complex<long double>::complex(const complex<double>& __z)
|
||||
: _M_re(__z._M_re), _M_im(__z._M_im) {}
|
||||
#endif
|
||||
|
||||
// Unary non-member arithmetic operators.
|
||||
|
||||
template <class _Tp>
|
||||
inline complex<_Tp> _STLP_CALL operator+(const complex<_Tp>& __z)
|
||||
{ return __z; }
|
||||
|
||||
template <class _Tp>
|
||||
inline complex<_Tp> _STLP_CALL operator-(const complex<_Tp>& __z)
|
||||
{ return complex<_Tp>(-__z._M_re, -__z._M_im); }
|
||||
|
||||
// Non-member arithmetic operations involving one real argument.
|
||||
|
||||
template <class _Tp>
|
||||
inline complex<_Tp> _STLP_CALL operator+(const _Tp& __x, const complex<_Tp>& __z)
|
||||
{ return complex<_Tp>(__x + __z._M_re, __z._M_im); }
|
||||
|
||||
template <class _Tp>
|
||||
inline complex<_Tp> _STLP_CALL operator+(const complex<_Tp>& __z, const _Tp& __x)
|
||||
{ return complex<_Tp>(__z._M_re + __x, __z._M_im); }
|
||||
|
||||
template <class _Tp>
|
||||
inline complex<_Tp> _STLP_CALL operator-(const _Tp& __x, const complex<_Tp>& __z)
|
||||
{ return complex<_Tp>(__x - __z._M_re, -__z._M_im); }
|
||||
|
||||
template <class _Tp>
|
||||
inline complex<_Tp> _STLP_CALL operator-(const complex<_Tp>& __z, const _Tp& __x)
|
||||
{ return complex<_Tp>(__z._M_re - __x, __z._M_im); }
|
||||
|
||||
template <class _Tp>
|
||||
inline complex<_Tp> _STLP_CALL operator*(const _Tp& __x, const complex<_Tp>& __z)
|
||||
{ return complex<_Tp>(__x * __z._M_re, __x * __z._M_im); }
|
||||
|
||||
template <class _Tp>
|
||||
inline complex<_Tp> _STLP_CALL operator*(const complex<_Tp>& __z, const _Tp& __x)
|
||||
{ return complex<_Tp>(__z._M_re * __x, __z._M_im * __x); }
|
||||
|
||||
template <class _Tp>
|
||||
inline complex<_Tp> _STLP_CALL operator/(const _Tp& __x, const complex<_Tp>& __z) {
|
||||
complex<_Tp> __result;
|
||||
complex<_Tp>::_div(__x,
|
||||
__z._M_re, __z._M_im,
|
||||
__result._M_re, __result._M_im);
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline complex<_Tp> _STLP_CALL operator/(const complex<_Tp>& __z, const _Tp& __x)
|
||||
{ return complex<_Tp>(__z._M_re / __x, __z._M_im / __x); }
|
||||
|
||||
// Non-member arithmetic operations involving two complex arguments
|
||||
|
||||
template <class _Tp>
|
||||
inline complex<_Tp> _STLP_CALL
|
||||
operator+(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
|
||||
{ return complex<_Tp>(__z1._M_re + __z2._M_re, __z1._M_im + __z2._M_im); }
|
||||
|
||||
template <class _Tp>
|
||||
inline complex<_Tp> _STLP_CALL
|
||||
operator-(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
|
||||
{ return complex<_Tp>(__z1._M_re - __z2._M_re, __z1._M_im - __z2._M_im); }
|
||||
|
||||
template <class _Tp>
|
||||
inline complex<_Tp> _STLP_CALL
|
||||
operator*(const complex<_Tp>& __z1, const complex<_Tp>& __z2) {
|
||||
return complex<_Tp>(__z1._M_re * __z2._M_re - __z1._M_im * __z2._M_im,
|
||||
__z1._M_re * __z2._M_im + __z1._M_im * __z2._M_re);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline complex<_Tp> _STLP_CALL
|
||||
operator/(const complex<_Tp>& __z1, const complex<_Tp>& __z2) {
|
||||
complex<_Tp> __result;
|
||||
complex<_Tp>::_div(__z1._M_re, __z1._M_im,
|
||||
__z2._M_re, __z2._M_im,
|
||||
__result._M_re, __result._M_im);
|
||||
return __result;
|
||||
}
|
||||
|
||||
// Comparison operators.
|
||||
|
||||
template <class _Tp>
|
||||
inline bool _STLP_CALL operator==(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
|
||||
{ return __z1._M_re == __z2._M_re && __z1._M_im == __z2._M_im; }
|
||||
|
||||
template <class _Tp>
|
||||
inline bool _STLP_CALL operator==(const complex<_Tp>& __z, const _Tp& __x)
|
||||
{ return __z._M_re == __x && __z._M_im == 0; }
|
||||
|
||||
template <class _Tp>
|
||||
inline bool _STLP_CALL operator==(const _Tp& __x, const complex<_Tp>& __z)
|
||||
{ return __x == __z._M_re && 0 == __z._M_im; }
|
||||
|
||||
//04/27/04 dums: removal of this check, if it is restablish
|
||||
//please explain why the other operators are not macro guarded
|
||||
//#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
|
||||
template <class _Tp>
|
||||
inline bool _STLP_CALL operator!=(const complex<_Tp>& __z1, const complex<_Tp>& __z2)
|
||||
{ return __z1._M_re != __z2._M_re || __z1._M_im != __z2._M_im; }
|
||||
|
||||
//#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
|
||||
template <class _Tp>
|
||||
inline bool _STLP_CALL operator!=(const complex<_Tp>& __z, const _Tp& __x)
|
||||
{ return __z._M_re != __x || __z._M_im != 0; }
|
||||
|
||||
template <class _Tp>
|
||||
inline bool _STLP_CALL operator!=(const _Tp& __x, const complex<_Tp>& __z)
|
||||
{ return __x != __z._M_re || 0 != __z._M_im; }
|
||||
|
||||
// Other basic arithmetic operations
|
||||
template <class _Tp>
|
||||
inline _Tp _STLP_CALL real(const complex<_Tp>& __z)
|
||||
{ return __z._M_re; }
|
||||
|
||||
template <class _Tp>
|
||||
inline _Tp _STLP_CALL imag(const complex<_Tp>& __z)
|
||||
{ return __z._M_im; }
|
||||
|
||||
template <class _Tp>
|
||||
_Tp _STLP_CALL abs(const complex<_Tp>& __z);
|
||||
|
||||
template <class _Tp>
|
||||
_Tp _STLP_CALL arg(const complex<_Tp>& __z);
|
||||
|
||||
template <class _Tp>
|
||||
inline _Tp _STLP_CALL norm(const complex<_Tp>& __z)
|
||||
{ return __z._M_re * __z._M_re + __z._M_im * __z._M_im; }
|
||||
|
||||
template <class _Tp>
|
||||
inline complex<_Tp> _STLP_CALL conj(const complex<_Tp>& __z)
|
||||
{ return complex<_Tp>(__z._M_re, -__z._M_im); }
|
||||
|
||||
template <class _Tp>
|
||||
complex<_Tp> _STLP_CALL polar(const _Tp& __rho)
|
||||
{ return complex<_Tp>(__rho, 0); }
|
||||
|
||||
template <class _Tp>
|
||||
complex<_Tp> _STLP_CALL polar(const _Tp& __rho, const _Tp& __phi);
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
_STLP_DECLSPEC float _STLP_CALL abs(const complex<float>&);
|
||||
_STLP_TEMPLATE_NULL
|
||||
_STLP_DECLSPEC double _STLP_CALL abs(const complex<double>&);
|
||||
_STLP_TEMPLATE_NULL
|
||||
_STLP_DECLSPEC float _STLP_CALL arg(const complex<float>&);
|
||||
_STLP_TEMPLATE_NULL
|
||||
_STLP_DECLSPEC double _STLP_CALL arg(const complex<double>&);
|
||||
_STLP_TEMPLATE_NULL
|
||||
_STLP_DECLSPEC complex<float> _STLP_CALL polar(const float& __rho, const float& __phi);
|
||||
_STLP_TEMPLATE_NULL
|
||||
_STLP_DECLSPEC complex<double> _STLP_CALL polar(const double& __rho, const double& __phi);
|
||||
|
||||
template <class _Tp>
|
||||
_Tp _STLP_CALL abs(const complex<_Tp>& __z)
|
||||
{ return _Tp(abs(complex<double>(double(__z.real()), double(__z.imag())))); }
|
||||
|
||||
template <class _Tp>
|
||||
_Tp _STLP_CALL arg(const complex<_Tp>& __z)
|
||||
{ return _Tp(arg(complex<double>(double(__z.real()), double(__z.imag())))); }
|
||||
|
||||
template <class _Tp>
|
||||
complex<_Tp> _STLP_CALL polar(const _Tp& __rho, const _Tp& __phi) {
|
||||
complex<double> __tmp = polar(double(__rho), double(__phi));
|
||||
return complex<_Tp>(_Tp(__tmp.real()), _Tp(__tmp.imag()));
|
||||
}
|
||||
|
||||
#if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
_STLP_TEMPLATE_NULL
|
||||
_STLP_DECLSPEC long double _STLP_CALL arg(const complex<long double>&);
|
||||
_STLP_TEMPLATE_NULL
|
||||
_STLP_DECLSPEC long double _STLP_CALL abs(const complex<long double>&);
|
||||
_STLP_TEMPLATE_NULL
|
||||
_STLP_DECLSPEC complex<long double> _STLP_CALL polar(const long double&, const long double&);
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined (_STLP_USE_NO_IOSTREAMS)
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# ifndef _STLP_INTERNAL_IOSFWD
|
||||
# include <stl/_iosfwd.h>
|
||||
# endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
// Complex output, in the form (re,im). We use a two-step process
|
||||
// involving stringstream so that we get the padding right.
|
||||
template <class _Tp, class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __z);
|
||||
|
||||
template <class _Tp, class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>& _STLP_CALL
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __z);
|
||||
|
||||
// Specializations for narrow characters; lets us avoid widen.
|
||||
|
||||
_STLP_OPERATOR_TEMPLATE
|
||||
_STLP_DECLSPEC basic_istream<char, char_traits<char> >& _STLP_CALL
|
||||
operator>>(basic_istream<char, char_traits<char> >& __is, complex<float>& __z);
|
||||
|
||||
_STLP_OPERATOR_TEMPLATE
|
||||
_STLP_DECLSPEC basic_istream<char, char_traits<char> >& _STLP_CALL
|
||||
operator>>(basic_istream<char, char_traits<char> >& __is, complex<double>& __z);
|
||||
|
||||
_STLP_OPERATOR_TEMPLATE
|
||||
_STLP_DECLSPEC basic_ostream<char, char_traits<char> >& _STLP_CALL
|
||||
operator<<(basic_ostream<char, char_traits<char> >& __is, const complex<float>& __z);
|
||||
|
||||
_STLP_OPERATOR_TEMPLATE
|
||||
_STLP_DECLSPEC basic_ostream<char, char_traits<char> >& _STLP_CALL
|
||||
operator<<(basic_ostream<char, char_traits<char> >& __is, const complex<double>& __z);
|
||||
|
||||
# if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
_STLP_OPERATOR_TEMPLATE
|
||||
_STLP_DECLSPEC basic_istream<char, char_traits<char> >& _STLP_CALL
|
||||
operator>>(basic_istream<char, char_traits<char> >& __is, complex<long double>& __z);
|
||||
|
||||
_STLP_OPERATOR_TEMPLATE
|
||||
_STLP_DECLSPEC basic_ostream<char, char_traits<char> >& _STLP_CALL
|
||||
operator<<(basic_ostream<char, char_traits<char> >& __is, const complex<long double>& __z);
|
||||
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_USE_TEMPLATE_EXPORT) && ! defined (_STLP_NO_WCHAR_T)
|
||||
|
||||
_STLP_EXPORT_TEMPLATE basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
|
||||
operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<double>&);
|
||||
_STLP_EXPORT_TEMPLATE basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
|
||||
operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<double>&);
|
||||
_STLP_EXPORT_TEMPLATE basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
|
||||
operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<float>&);
|
||||
_STLP_EXPORT_TEMPLATE basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
|
||||
operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<float>&);
|
||||
|
||||
# if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
_STLP_EXPORT_TEMPLATE basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
|
||||
operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<long double>&);
|
||||
_STLP_EXPORT_TEMPLATE basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
|
||||
operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<long double>&);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
// Transcendental functions. These are defined only for float,
|
||||
// double, and long double. (Sqrt isn't transcendental, of course,
|
||||
// but it's included in this section anyway.)
|
||||
|
||||
_STLP_DECLSPEC complex<float> _STLP_CALL sqrt(const complex<float>&);
|
||||
|
||||
_STLP_DECLSPEC complex<float> _STLP_CALL exp(const complex<float>&);
|
||||
_STLP_DECLSPEC complex<float> _STLP_CALL log(const complex<float>&);
|
||||
_STLP_DECLSPEC complex<float> _STLP_CALL log10(const complex<float>&);
|
||||
|
||||
_STLP_DECLSPEC complex<float> _STLP_CALL pow(const complex<float>&, int);
|
||||
_STLP_DECLSPEC complex<float> _STLP_CALL pow(const complex<float>&, const float&);
|
||||
_STLP_DECLSPEC complex<float> _STLP_CALL pow(const float&, const complex<float>&);
|
||||
_STLP_DECLSPEC complex<float> _STLP_CALL pow(const complex<float>&, const complex<float>&);
|
||||
|
||||
_STLP_DECLSPEC complex<float> _STLP_CALL sin(const complex<float>&);
|
||||
_STLP_DECLSPEC complex<float> _STLP_CALL cos(const complex<float>&);
|
||||
_STLP_DECLSPEC complex<float> _STLP_CALL tan(const complex<float>&);
|
||||
|
||||
_STLP_DECLSPEC complex<float> _STLP_CALL sinh(const complex<float>&);
|
||||
_STLP_DECLSPEC complex<float> _STLP_CALL cosh(const complex<float>&);
|
||||
_STLP_DECLSPEC complex<float> _STLP_CALL tanh(const complex<float>&);
|
||||
|
||||
_STLP_DECLSPEC complex<double> _STLP_CALL sqrt(const complex<double>&);
|
||||
|
||||
_STLP_DECLSPEC complex<double> _STLP_CALL exp(const complex<double>&);
|
||||
_STLP_DECLSPEC complex<double> _STLP_CALL log(const complex<double>&);
|
||||
_STLP_DECLSPEC complex<double> _STLP_CALL log10(const complex<double>&);
|
||||
|
||||
_STLP_DECLSPEC complex<double> _STLP_CALL pow(const complex<double>&, int);
|
||||
_STLP_DECLSPEC complex<double> _STLP_CALL pow(const complex<double>&, const double&);
|
||||
_STLP_DECLSPEC complex<double> _STLP_CALL pow(const double&, const complex<double>&);
|
||||
_STLP_DECLSPEC complex<double> _STLP_CALL pow(const complex<double>&, const complex<double>&);
|
||||
|
||||
_STLP_DECLSPEC complex<double> _STLP_CALL sin(const complex<double>&);
|
||||
_STLP_DECLSPEC complex<double> _STLP_CALL cos(const complex<double>&);
|
||||
_STLP_DECLSPEC complex<double> _STLP_CALL tan(const complex<double>&);
|
||||
|
||||
_STLP_DECLSPEC complex<double> _STLP_CALL sinh(const complex<double>&);
|
||||
_STLP_DECLSPEC complex<double> _STLP_CALL cosh(const complex<double>&);
|
||||
_STLP_DECLSPEC complex<double> _STLP_CALL tanh(const complex<double>&);
|
||||
|
||||
#if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
_STLP_DECLSPEC complex<long double> _STLP_CALL sqrt(const complex<long double>&);
|
||||
_STLP_DECLSPEC complex<long double> _STLP_CALL exp(const complex<long double>&);
|
||||
_STLP_DECLSPEC complex<long double> _STLP_CALL log(const complex<long double>&);
|
||||
_STLP_DECLSPEC complex<long double> _STLP_CALL log10(const complex<long double>&);
|
||||
|
||||
_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const complex<long double>&, int);
|
||||
_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const complex<long double>&, const long double&);
|
||||
_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const long double&, const complex<long double>&);
|
||||
_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const complex<long double>&,
|
||||
const complex<long double>&);
|
||||
|
||||
_STLP_DECLSPEC complex<long double> _STLP_CALL sin(const complex<long double>&);
|
||||
_STLP_DECLSPEC complex<long double> _STLP_CALL cos(const complex<long double>&);
|
||||
_STLP_DECLSPEC complex<long double> _STLP_CALL tan(const complex<long double>&);
|
||||
|
||||
_STLP_DECLSPEC complex<long double> _STLP_CALL sinh(const complex<long double>&);
|
||||
_STLP_DECLSPEC complex<long double> _STLP_CALL cosh(const complex<long double>&);
|
||||
_STLP_DECLSPEC complex<long double> _STLP_CALL tanh(const complex<long double>&);
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#ifndef _STLP_LINK_TIME_INSTANTIATION
|
||||
# include <stl/_complex.c>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
51
extern/STLport/5.2.1/stlport/stl/_config_compat_post.h
vendored
Normal file
51
extern/STLport/5.2.1/stlport/stl/_config_compat_post.h
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
/*========================================== */
|
||||
#if 1 /* def _STLP_3_COMPATIBILITY */
|
||||
|
||||
# define __SGI_STL_PORT _STLPORT_VERSION
|
||||
|
||||
# if defined (_STLP_DEBUG) && ! defined ( __STL_DEBUG )
|
||||
# define __STL_DEBUG _STLP_DEBUG
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_USE_NAMESPACES)
|
||||
# undef __STL_USE_NAMESPACES
|
||||
# define __STL_USE_NAMESPACES _STLP_USE_NAMESPACES
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_USE_EXCEPTIONS)
|
||||
# undef __STL_USE_EXCEPTIONS
|
||||
# define __STL_USE_EXCEPTIONS _STLP_USE_EXCEPTIONS
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_BEGIN_NAMESPACE) && ! defined ( __STL_BEGIN_NAMESPACE )
|
||||
# define __STL_BEGIN_NAMESPACE _STLP_BEGIN_NAMESPACE
|
||||
# define __STL_END_NAMESPACE _STLP_END_NAMESPACE
|
||||
# define __STL_VENDOR_STD _STLP_VENDOR_STD
|
||||
# define __STL_VENDOR_CSTD _STLP_VENDOR_CSTD
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/*
|
||||
# if defined (_STLP_XXX) && ! defined ( __STL_XXX )
|
||||
# define __STL_XXX _STLP_XXX
|
||||
# endif
|
||||
*/
|
||||
|
||||
/* 5.0 -> 4.6 compatibility section */
|
||||
#if 1 /* def _STLP_46_COMPATIBILITY */
|
||||
|
||||
/* provide a uniform way to access full functionality */
|
||||
# define __slist__ slist
|
||||
# define __map__ map
|
||||
# define __multimap__ multimap
|
||||
# define __set__ set
|
||||
# define __multiset__ multiset
|
||||
# define __list__ list
|
||||
# define __hash_map__ hash_map
|
||||
# define __hash_multimap__ hash_multimap
|
||||
# define __hash_set__ hash_set
|
||||
# define __hash_multiset__ hash_multiset
|
||||
# define __vector__ vector
|
||||
|
||||
#endif
|
||||
|
||||
289
extern/STLport/5.2.1/stlport/stl/_construct.h
vendored
Normal file
289
extern/STLport/5.2.1/stlport/stl/_construct.h
vendored
Normal file
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_CONSTRUCT_H
|
||||
#define _STLP_INTERNAL_CONSTRUCT_H
|
||||
|
||||
#if !defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_INTERNAL_CSTRING)
|
||||
# include <stl/_cstring.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_NEW
|
||||
# include <stl/_new.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
|
||||
# include <stl/_iterator_base.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_TYPE_TRAITS_H
|
||||
# include <stl/type_traits.h>
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_MOVE_CONSTRUCT_FWK_H) && !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
# include <stl/_move_construct_fwk.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _Tp>
|
||||
inline void __destroy_aux(_Tp* __pointer, const __false_type& /*_Trivial_destructor*/)
|
||||
{ __pointer->~_Tp(); }
|
||||
|
||||
template <class _Tp>
|
||||
inline void __destroy_aux(_Tp*, const __true_type& /*_Trivial_destructor*/) {}
|
||||
|
||||
template <class _Tp>
|
||||
inline void _Destroy(_Tp* __pointer) {
|
||||
typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor;
|
||||
__destroy_aux(__pointer, _Trivial_destructor());
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED)
|
||||
memset(__REINTERPRET_CAST(char*, __pointer), _STLP_SHRED_BYTE, sizeof(_Tp));
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline void _Destroy_Moved(_Tp* __pointer) {
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
typedef typename __move_traits<_Tp>::complete _Trivial_destructor;
|
||||
__destroy_aux(__pointer, _Trivial_destructor());
|
||||
# if defined (_STLP_DEBUG_UNINITIALIZED)
|
||||
memset((char*)__pointer, _STLP_SHRED_BYTE, sizeof(_Tp));
|
||||
# endif
|
||||
#else
|
||||
_Destroy(__pointer);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined (new)
|
||||
# define _STLP_NEW_REDEFINE new
|
||||
# undef new
|
||||
#endif
|
||||
|
||||
template <class _T1>
|
||||
inline void _Construct_aux (_T1* __p, const __false_type&) {
|
||||
new(__p) _T1();
|
||||
}
|
||||
|
||||
template <class _T1>
|
||||
inline void _Construct_aux (_T1* __p, const __true_type&) {
|
||||
#if defined (_STLP_DEF_CONST_PLCT_NEW_BUG)
|
||||
*__p = _T1(0);
|
||||
#else
|
||||
// We use binary copying for POD types since it results
|
||||
// in a considerably better code at least on MSVC.
|
||||
*__p = _T1();
|
||||
#endif /* _STLP_DEF_CONST_PLCT_NEW_BUG */
|
||||
}
|
||||
|
||||
template <class _T1>
|
||||
inline void _Construct(_T1* __p) {
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED)
|
||||
memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1));
|
||||
#endif
|
||||
#if defined (_STLP_DEF_CONST_PLCT_NEW_BUG)
|
||||
_Construct_aux (__p, _HasDefaultZeroValue(__p)._Answer());
|
||||
#else
|
||||
_Construct_aux (__p, _Is_POD(__p)._Answer());
|
||||
#endif /* _STLP_DEF_CONST_PLCT_NEW_BUG */
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline void _Copy_Construct_aux(_Tp* __p, const _Tp& __val, const __false_type&) {
|
||||
new(__p) _Tp(__val);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline void _Copy_Construct_aux(_Tp* __p, const _Tp& __val, const __true_type&) {
|
||||
// We use binary copying for POD types since it results
|
||||
// in a considerably better code at least on MSVC.
|
||||
*__p = __val;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline void _Copy_Construct(_Tp* __p, const _Tp& __val) {
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED)
|
||||
memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_Tp));
|
||||
#endif
|
||||
_Copy_Construct_aux(__p, __val, _Is_POD(__p)._Answer());
|
||||
}
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline void _Param_Construct_aux(_T1* __p, const _T2& __val, const __false_type&) {
|
||||
new(__p) _T1(__val);
|
||||
}
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline void _Param_Construct_aux(_T1* __p, const _T2& __val, const __true_type&) {
|
||||
// We use binary copying for POD types since it results
|
||||
// in a considerably better code at least on MSVC.
|
||||
*__p = _T1(__val);
|
||||
}
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline void _Param_Construct(_T1* __p, const _T2& __val) {
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED)
|
||||
memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1));
|
||||
#endif
|
||||
_Param_Construct_aux(__p, __val, _Is_POD(__p)._Answer());
|
||||
}
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline void _Move_Construct_Aux(_T1* __p, _T2& __val, const __false_type& /*_IsPOD*/) {
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
new(__p) _T1(_STLP_PRIV _AsMoveSource(__val));
|
||||
#else
|
||||
_Param_Construct(__p, __val);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline void _Move_Construct_Aux(_T1* __p, _T2& __val, const __true_type& /*_IsPOD*/) {
|
||||
// We use binary copying for POD types since it results
|
||||
// in a considerably better code at least on MSVC.
|
||||
*__p = _T1(__val);
|
||||
}
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline void _Move_Construct(_T1* __p, _T2& __val) {
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED)
|
||||
memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1));
|
||||
#endif
|
||||
_Move_Construct_Aux(__p, __val, _Is_POD(__p)._Answer());
|
||||
}
|
||||
|
||||
#if defined(_STLP_NEW_REDEFINE)
|
||||
# if defined (DEBUG_NEW)
|
||||
# define new DEBUG_NEW
|
||||
# endif
|
||||
# undef _STLP_NEW_REDEFINE
|
||||
#endif
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
_STLP_INLINE_LOOP void
|
||||
__destroy_range_aux(_ForwardIterator __first, _ForwardIterator __last, _Tp*, const __false_type& /*_Trivial_destructor*/) {
|
||||
for ( ; __first != __last; ++__first) {
|
||||
__destroy_aux(&(*__first), __false_type());
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED)
|
||||
memset((char*)&(*__first), _STLP_SHRED_BYTE, sizeof(_Tp));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED)
|
||||
_STLP_INLINE_LOOP void
|
||||
__destroy_range_aux(_ForwardIterator __first, _ForwardIterator __last, _Tp*, const __true_type& /*_Trivial_destructor*/) {
|
||||
for ( ; __first != __last; ++__first)
|
||||
memset((char*)&(*__first), _STLP_SHRED_BYTE, sizeof(_Tp));
|
||||
}
|
||||
#else
|
||||
inline void
|
||||
__destroy_range_aux(_ForwardIterator, _ForwardIterator, _Tp*, const __true_type& /*_Trivial_destructor*/) {}
|
||||
#endif
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
inline void
|
||||
__destroy_range(_ForwardIterator __first, _ForwardIterator __last, _Tp *__ptr) {
|
||||
typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor;
|
||||
__destroy_range_aux(__first, __last, __ptr, _Trivial_destructor());
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
inline void _Destroy_Range(_ForwardIterator __first, _ForwardIterator __last) {
|
||||
__destroy_range(__first, __last, _STLP_VALUE_TYPE(__first, _ForwardIterator));
|
||||
}
|
||||
|
||||
inline void _Destroy_Range(char*, char*) {}
|
||||
#if defined (_STLP_HAS_WCHAR_T) // dwa 8/15/97
|
||||
inline void _Destroy_Range(wchar_t*, wchar_t*) {}
|
||||
inline void _Destroy_Range(const wchar_t*, const wchar_t*) {}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
inline void
|
||||
__destroy_mv_srcs(_ForwardIterator __first, _ForwardIterator __last, _Tp *__ptr) {
|
||||
typedef typename __move_traits<_Tp>::complete _CompleteMove;
|
||||
__destroy_range_aux(__first, __last, __ptr, _CompleteMove());
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _ForwardIterator>
|
||||
inline void _Destroy_Moved_Range(_ForwardIterator __first, _ForwardIterator __last)
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
{ __destroy_mv_srcs(__first, __last, _STLP_VALUE_TYPE(__first, _ForwardIterator)); }
|
||||
#else
|
||||
{ _Destroy_Range(__first, __last); }
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_DEF_CONST_DEF_PARAM_BUG)
|
||||
// Those adaptors are here to fix common compiler bug regarding builtins:
|
||||
// expressions like int k = int() should initialize k to 0
|
||||
template <class _Tp>
|
||||
inline _Tp __default_constructed_aux(_Tp*, const __false_type&) {
|
||||
return _Tp();
|
||||
}
|
||||
template <class _Tp>
|
||||
inline _Tp __default_constructed_aux(_Tp*, const __true_type&) {
|
||||
return _Tp(0);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _Tp __default_constructed(_Tp* __p) {
|
||||
return __default_constructed_aux(__p, _HasDefaultZeroValue(__p)._Answer());
|
||||
}
|
||||
|
||||
# define _STLP_DEFAULT_CONSTRUCTED(_TTp) __default_constructed((_TTp*)0)
|
||||
#else
|
||||
# define _STLP_DEFAULT_CONSTRUCTED(_TTp) _TTp()
|
||||
#endif /* _STLP_DEF_CONST_DEF_PARAM_BUG */
|
||||
|
||||
|
||||
#if !defined (_STLP_NO_ANACHRONISMS)
|
||||
// --------------------------------------------------
|
||||
// Old names from the HP STL.
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline void construct(_T1* __p, const _T2& __val) {_Param_Construct(__p, __val); }
|
||||
template <class _T1>
|
||||
inline void construct(_T1* __p) { _STLP_STD::_Construct(__p); }
|
||||
template <class _Tp>
|
||||
inline void destroy(_Tp* __pointer) { _STLP_STD::_Destroy(__pointer); }
|
||||
template <class _ForwardIterator>
|
||||
inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { _STLP_STD::_Destroy_Range(__first, __last); }
|
||||
#endif /* _STLP_NO_ANACHRONISMS */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_CONSTRUCT_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
25
extern/STLport/5.2.1/stlport/stl/_cprolog.h
vendored
Normal file
25
extern/STLport/5.2.1/stlport/stl/_cprolog.h
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
/* NOTE : this header has no guards and is MEANT for multiple inclusion!
|
||||
* If you are using "header protection" option with your compiler,
|
||||
* please also find #pragma which disables it and put it here, to
|
||||
* allow reentrancy of this header.
|
||||
*/
|
||||
|
||||
#ifdef std
|
||||
# undef std /* We undef "std" on entry , as STLport headers may include native ones. */
|
||||
#endif
|
||||
|
||||
#ifdef _STLP_PROLOG_HEADER_INCLUDED
|
||||
# error STlport prolog header can not be reincluded as long as epilog has not be included.
|
||||
#endif
|
||||
|
||||
#define _STLP_PROLOG_HEADER_INCLUDED
|
||||
|
||||
#ifndef _STLP_FEATURES_H
|
||||
# include <stl/config/features.h>
|
||||
#endif
|
||||
|
||||
/* If the platform provides any specific prolog actions,
|
||||
* like #pragmas, do include platform-specific prolog file */
|
||||
#if defined (_STLP_HAS_SPECIFIC_PROLOG_EPILOG)
|
||||
# include <stl/config/_prolog.h>
|
||||
#endif
|
||||
68
extern/STLport/5.2.1/stlport/stl/_csetjmp.h
vendored
Normal file
68
extern/STLport/5.2.1/stlport/stl/_csetjmp.h
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSETJMP
|
||||
#define _STLP_INTERNAL_CSETJMP
|
||||
|
||||
// if the macro is on, the header is already there
|
||||
#if !defined (setjmp)
|
||||
# if defined (_STLP_USE_NEW_C_HEADERS)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <csetjmp>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(csetjmp)
|
||||
# endif
|
||||
# else
|
||||
# include <setjmp.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_IMPORT_VENDOR_CSTD)
|
||||
|
||||
# if defined (__BORLANDC__) && defined (_STLP_USE_NEW_C_HEADERS)
|
||||
/* For Borland, even if stdjmp.h is included symbols won't be in global namespace
|
||||
* so we need to reach them in vendor namespace:
|
||||
*/
|
||||
# undef _STLP_NATIVE_SETJMP_H_INCLUDED
|
||||
# endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
# if !defined (_STLP_NATIVE_SETJMP_H_INCLUDED)
|
||||
using _STLP_VENDOR_CSTD::jmp_buf;
|
||||
# else
|
||||
// if setjmp.h was included first, this is in global namespace, not in
|
||||
// vendor's std. - 2005-08-04, ptr
|
||||
using ::jmp_buf;
|
||||
# endif
|
||||
# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
|
||||
# if !defined (setjmp)
|
||||
# if !defined (__MSL__) || ((__MSL__ > 0x7001) && (__MSL__ < 0x8000))
|
||||
# ifndef _STLP_NATIVE_SETJMP_H_INCLUDED
|
||||
using _STLP_VENDOR_CSTD::setjmp;
|
||||
# else
|
||||
using ::setjmp;
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
# if !defined (_STLP_NATIVE_SETJMP_H_INCLUDED)
|
||||
using _STLP_VENDOR_CSTD::longjmp;
|
||||
# else
|
||||
using ::longjmp;
|
||||
# endif
|
||||
# endif
|
||||
_STLP_END_NAMESPACE
|
||||
#endif /* _STLP_IMPORT_VENDOR_CSTD */
|
||||
|
||||
#endif
|
||||
41
extern/STLport/5.2.1/stlport/stl/_csignal.h
vendored
Normal file
41
extern/STLport/5.2.1/stlport/stl/_csignal.h
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSIGNAL
|
||||
#define _STLP_INTERNAL_CSIGNAL
|
||||
|
||||
#if !defined (_STLP_WCE)
|
||||
# if defined (_STLP_USE_NEW_C_HEADERS)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <csignal>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(csignal)
|
||||
# endif
|
||||
# else
|
||||
# include <signal.h>
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_IMPORT_VENDOR_CSTD)
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
|
||||
using _STLP_VENDOR_CSTD::signal;
|
||||
using _STLP_VENDOR_CSTD::raise;
|
||||
# endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */
|
||||
using _STLP_VENDOR_CSTD::sig_atomic_t;
|
||||
_STLP_END_NAMESPACE
|
||||
# endif /* _STLP_IMPORT_VENDOR_CSTD */
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_CSIGNAL */
|
||||
34
extern/STLport/5.2.1/stlport/stl/_cstdarg.h
vendored
Normal file
34
extern/STLport/5.2.1/stlport/stl/_cstdarg.h
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSTDARG
|
||||
#define _STLP_INTERNAL_CSTDARG
|
||||
|
||||
#if defined (_STLP_USE_NEW_C_HEADERS)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <cstdarg>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(cstdarg)
|
||||
# endif
|
||||
#else
|
||||
# include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#ifdef _STLP_IMPORT_VENDOR_CSTD
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
using _STLP_VENDOR_CSTD::va_list;
|
||||
_STLP_END_NAMESPACE
|
||||
#endif /* _STLP_IMPORT_VENDOR_CSTD */
|
||||
|
||||
#endif
|
||||
44
extern/STLport/5.2.1/stlport/stl/_cstddef.h
vendored
Normal file
44
extern/STLport/5.2.1/stlport/stl/_cstddef.h
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSTDDEF
|
||||
#define _STLP_INTERNAL_CSTDDEF
|
||||
|
||||
# if (__GNUC__ >= 3) && defined (__CYGWIN__) // this total HACK is the only expedient way I could cygwin to work with GCC 3.0
|
||||
# define __need_wint_t // mostly because wint_t didn't seem to get defined otherwise :(
|
||||
# define __need_wchar_t
|
||||
# define __need_size_t
|
||||
# define __need_ptrdiff_t
|
||||
# define __need_NULL
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_USE_NEW_C_HEADERS)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <cstddef>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(cstddef)
|
||||
# endif
|
||||
# else
|
||||
# include <stddef.h>
|
||||
# endif
|
||||
|
||||
# ifdef _STLP_IMPORT_VENDOR_CSTD
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
using _STLP_VENDOR_CSTD::ptrdiff_t;
|
||||
using _STLP_VENDOR_CSTD::size_t;
|
||||
_STLP_END_NAMESPACE
|
||||
# endif /* _STLP_IMPORT_VENDOR_CSTD */
|
||||
|
||||
#endif /* _STLP_INTERNAL_CSTDDEF */
|
||||
127
extern/STLport/5.2.1/stlport/stl/_cstdio.h
vendored
Normal file
127
extern/STLport/5.2.1/stlport/stl/_cstdio.h
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSTDIO
|
||||
#define _STLP_INTERNAL_CSTDIO
|
||||
|
||||
#if defined (__Lynx__)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <stdarg.h>
|
||||
# else
|
||||
# include _STLP_NATIVE_C_HEADER(stdarg.h)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_USE_NEW_C_HEADERS)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <cstdio>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(cstdio)
|
||||
# endif
|
||||
#else
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined (__MWERKS__)
|
||||
# undef stdin
|
||||
# undef stdout
|
||||
# undef stderr
|
||||
# define stdin (&_STLP_VENDOR_CSTD::__files[0])
|
||||
# define stdout (&_STLP_VENDOR_CSTD::__files[1])
|
||||
# define stderr (&_STLP_VENDOR_CSTD::__files[2])
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB < 1400) || defined (_STLP_USING_PLATFORM_SDK_COMPILER)
|
||||
inline int vsnprintf(char *s1, size_t n, const char *s2, va_list v)
|
||||
{ return _STLP_VENDOR_CSTD::_vsnprintf(s1, n, s2, v); }
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_IMPORT_VENDOR_CSTD )
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
using _STLP_VENDOR_CSTD::FILE;
|
||||
using _STLP_VENDOR_CSTD::fpos_t;
|
||||
using _STLP_VENDOR_CSTD::size_t;
|
||||
|
||||
// undef obsolete macros
|
||||
# undef putc
|
||||
# undef getc
|
||||
# undef getchar
|
||||
# undef putchar
|
||||
# undef feof
|
||||
# undef ferror
|
||||
|
||||
# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
|
||||
using _STLP_VENDOR_CSTD::clearerr;
|
||||
using _STLP_VENDOR_CSTD::fclose;
|
||||
using _STLP_VENDOR_CSTD::feof;
|
||||
using _STLP_VENDOR_CSTD::ferror;
|
||||
using _STLP_VENDOR_CSTD::fflush;
|
||||
using _STLP_VENDOR_CSTD::fgetc;
|
||||
using _STLP_VENDOR_CSTD::fgetpos;
|
||||
using _STLP_VENDOR_CSTD::fgets;
|
||||
using _STLP_VENDOR_CSTD::fopen;
|
||||
using _STLP_VENDOR_CSTD::fprintf;
|
||||
using _STLP_VENDOR_CSTD::fputc;
|
||||
using _STLP_VENDOR_CSTD::fputs;
|
||||
using _STLP_VENDOR_CSTD::fread;
|
||||
# if !defined (_WIN32_WCE) || (_WIN32_WCE < 400)
|
||||
using _STLP_VENDOR_CSTD::freopen;
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD::fscanf;
|
||||
using _STLP_VENDOR_CSTD::fseek;
|
||||
using _STLP_VENDOR_CSTD::fsetpos;
|
||||
using _STLP_VENDOR_CSTD::ftell;
|
||||
using _STLP_VENDOR_CSTD::fwrite;
|
||||
|
||||
# if !(defined (__IBMCPP__) && (__IBMCPP__ >= 500))
|
||||
# if !defined (_WIN32_WCE) || (_WIN32_WCE < 400) // Supplied as macros, TODO: use inline function to redirect to the macros?
|
||||
using _STLP_VENDOR_CSTD::getc;
|
||||
using _STLP_VENDOR_CSTD::putc;
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD::getchar;
|
||||
using _STLP_VENDOR_CSTD::putchar;
|
||||
# endif
|
||||
|
||||
using _STLP_VENDOR_CSTD::gets;
|
||||
# if !defined (_WIN32_WCE) || (_WIN32_WCE < 400)
|
||||
using _STLP_VENDOR_CSTD::perror;
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD::printf;
|
||||
using _STLP_VENDOR_CSTD::puts;
|
||||
# if !defined (_WIN32_WCE) || (_WIN32_WCE < 400)
|
||||
using _STLP_VENDOR_CSTD::remove;
|
||||
using _STLP_VENDOR_CSTD::rename;
|
||||
using _STLP_VENDOR_CSTD::rewind;
|
||||
using _STLP_VENDOR_CSTD::setbuf;
|
||||
using _STLP_VENDOR_CSTD::tmpfile;
|
||||
using _STLP_VENDOR_CSTD::tmpnam;
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD::scanf;
|
||||
using _STLP_VENDOR_CSTD::setvbuf;
|
||||
using _STLP_VENDOR_CSTD::sprintf;
|
||||
using _STLP_VENDOR_CSTD::sscanf;
|
||||
using _STLP_VENDOR_CSTD::ungetc;
|
||||
using _STLP_VENDOR_CSTD::vfprintf;
|
||||
using _STLP_VENDOR_CSTD::vprintf;
|
||||
using _STLP_VENDOR_CSTD::vsprintf;
|
||||
# if (defined (__MWERKS__) || (defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB < 1400)) || \
|
||||
(defined (__BORLANDC__)))
|
||||
using _STLP_VENDOR_CSTD::vsnprintf;
|
||||
# endif
|
||||
# endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */
|
||||
_STLP_END_NAMESPACE
|
||||
#endif /* _STLP_IMPORT_VENDOR_CSTD */
|
||||
|
||||
#endif /* _STLP_INTERNAL_CSTDIO */
|
||||
184
extern/STLport/5.2.1/stlport/stl/_cstdlib.h
vendored
Normal file
184
extern/STLport/5.2.1/stlport/stl/_cstdlib.h
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSTDLIB
|
||||
#define _STLP_INTERNAL_CSTDLIB
|
||||
|
||||
#if defined (_STLP_USE_NEW_C_HEADERS)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <cstdlib>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(cstdlib)
|
||||
# endif
|
||||
#else
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#if defined (__BORLANDC__) && !defined (__linux__)
|
||||
/* Borland process.h header do not bring anything here and is just included
|
||||
* in order to avoid inclusion later. This header cannot be included later
|
||||
* because Borland compiler consider that for instance the abort function
|
||||
* defined as extern "C" cannot be overloaded and it finds 2 "overloads",
|
||||
* once in native std namespace and the other in STLport namespace...
|
||||
*/
|
||||
# include <process.h>
|
||||
#endif
|
||||
|
||||
/* on evc3/evc4 including stdlib.h also defines setjmp macro */
|
||||
#if defined (_STLP_WCE)
|
||||
# define _STLP_NATIVE_SETJMP_H_INCLUDED
|
||||
#endif
|
||||
|
||||
#if defined (__MSL__) && (__MSL__ <= 0x5003)
|
||||
namespace std {
|
||||
typedef ::div_t div_t;
|
||||
typedef ::ldiv_t ldiv_t;
|
||||
# ifdef __MSL_LONGLONG_SUPPORT__
|
||||
typedef ::lldiv_t lldiv_t;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _STLP_IMPORT_VENDOR_CSTD
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
using _STLP_VENDOR_CSTD::div_t;
|
||||
using _STLP_VENDOR_CSTD::ldiv_t;
|
||||
using _STLP_VENDOR_CSTD::size_t;
|
||||
|
||||
# ifndef _STLP_NO_CSTD_FUNCTION_IMPORTS
|
||||
# ifndef _STLP_WCE
|
||||
// these functions just don't exist on Windows CE
|
||||
using _STLP_VENDOR_CSTD::abort;
|
||||
using _STLP_VENDOR_CSTD::getenv;
|
||||
using _STLP_VENDOR_CSTD::mblen;
|
||||
using _STLP_VENDOR_CSTD::mbtowc;
|
||||
using _STLP_VENDOR_CSTD::system;
|
||||
using _STLP_VENDOR_CSTD::bsearch;
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD::atexit;
|
||||
using _STLP_VENDOR_CSTD::exit;
|
||||
using _STLP_VENDOR_CSTD::calloc;
|
||||
using _STLP_VENDOR_CSTD::free;
|
||||
using _STLP_VENDOR_CSTD::malloc;
|
||||
using _STLP_VENDOR_CSTD::realloc;
|
||||
using _STLP_VENDOR_CSTD::atof;
|
||||
using _STLP_VENDOR_CSTD::atoi;
|
||||
using _STLP_VENDOR_CSTD::atol;
|
||||
using _STLP_VENDOR_CSTD::mbstowcs;
|
||||
using _STLP_VENDOR_CSTD::strtod;
|
||||
using _STLP_VENDOR_CSTD::strtol;
|
||||
using _STLP_VENDOR_CSTD::strtoul;
|
||||
|
||||
# if !(defined (_STLP_NO_NATIVE_WIDE_STREAMS) || defined (_STLP_NO_NATIVE_MBSTATE_T))
|
||||
using _STLP_VENDOR_CSTD::wcstombs;
|
||||
# ifndef _STLP_WCE
|
||||
using _STLP_VENDOR_CSTD::wctomb;
|
||||
# endif
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD::qsort;
|
||||
using _STLP_VENDOR_CSTD::labs;
|
||||
using _STLP_VENDOR_CSTD::ldiv;
|
||||
# if defined (_STLP_LONG_LONG) && !defined (_STLP_NO_VENDOR_STDLIB_L)
|
||||
# if !defined(__sun)
|
||||
using _STLP_VENDOR_CSTD::llabs;
|
||||
using _STLP_VENDOR_CSTD::lldiv_t;
|
||||
using _STLP_VENDOR_CSTD::lldiv;
|
||||
# else
|
||||
using ::llabs;
|
||||
using ::lldiv_t;
|
||||
using ::lldiv;
|
||||
# endif
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD::rand;
|
||||
using _STLP_VENDOR_CSTD::srand;
|
||||
# endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */
|
||||
_STLP_END_NAMESPACE
|
||||
#endif /* _STLP_IMPORT_VENDOR_CSTD */
|
||||
|
||||
#if (defined (__BORLANDC__) || defined (__WATCOMC__)) && defined (_STLP_USE_NEW_C_HEADERS)
|
||||
//In this config bcc define everything in std namespace and not in
|
||||
//the global one.
|
||||
inline int abs(int __x) { return _STLP_VENDOR_CSTD::abs(__x); }
|
||||
inline _STLP_VENDOR_CSTD::div_t div(int __x, int __y) { return _STLP_VENDOR_CSTD::div(__x, __y); }
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_EXTENSIONS) && defined(_STLP_MSVC) && (_STLP_MSVC <= 1300)
|
||||
# define _STLP_RESTORE_FUNCTION_INTRINSIC
|
||||
# pragma warning (push)
|
||||
# pragma warning (disable: 4162)
|
||||
# pragma function (abs)
|
||||
#endif
|
||||
|
||||
//HP-UX native lib has abs() and div() functions in global namespace
|
||||
#if !defined (__SUNPRO_CC) && \
|
||||
(!defined (__HP_aCC) || (__HP_aCC < 30000))
|
||||
|
||||
//MSVC starting with .Net 2003 already define all math functions in global namespace:
|
||||
# if !defined (__WATCOMC__) && \
|
||||
(!defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1310) || defined (UNDER_CE))
|
||||
inline long abs(long __x) { return _STLP_VENDOR_CSTD::labs(__x); }
|
||||
# endif
|
||||
|
||||
/** VC since version 8 has this, the platform SDK and CE SDKs hanging behind. */
|
||||
# if !defined (__WATCOMC__) && \
|
||||
(!defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1400) || defined (_STLP_USING_PLATFORM_SDK_COMPILER) || defined (UNDER_CE))
|
||||
inline _STLP_VENDOR_CSTD::ldiv_t div(long __x, long __y) { return _STLP_VENDOR_CSTD::ldiv(__x, __y); }
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_RESTORE_FUNCTION_INTRINSIC)
|
||||
# pragma intrinsic (abs)
|
||||
# pragma warning (pop)
|
||||
# undef _STLP_RESTORE_FUNCTION_INTRINSIC
|
||||
#endif
|
||||
|
||||
#if !defined(_STLP_MSVC) || (_STLP_MSVC < 1600)
|
||||
|
||||
#if defined (_STLP_LONG_LONG)
|
||||
# if !defined (_STLP_NO_VENDOR_STDLIB_L)
|
||||
# if !defined (__sun)
|
||||
inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return _STLP_VENDOR_CSTD::llabs(__x); }
|
||||
inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return _STLP_VENDOR_CSTD::lldiv(__x, __y); }
|
||||
# else
|
||||
inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return ::llabs(__x); }
|
||||
inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return ::lldiv(__x, __y); }
|
||||
# endif
|
||||
# else
|
||||
inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; }
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* C++ Standard is unclear about several call to 'using ::func' if new overloads
|
||||
* of ::func appears between 2 successive 'using' calls. To avoid this potential
|
||||
* problem we provide all abs overload before the 'using' call.
|
||||
* Beware: This header inclusion has to be after all abs overload of this file.
|
||||
* The first 'using ::abs' call is going to be in the other header.
|
||||
*/
|
||||
#ifndef _STLP_INTERNAL_CMATH
|
||||
# include <stl/_cmath.h>
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_IMPORT_VENDOR_CSTD) && !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
|
||||
// ad hoc, don't replace with _STLP_VENDOR_CSTD::abs here! - ptr 2005-03-05
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
using ::abs;
|
||||
using ::div;
|
||||
_STLP_END_NAMESPACE
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_CSTDLIB */
|
||||
35
extern/STLport/5.2.1/stlport/stl/_cstring.h
vendored
Normal file
35
extern/STLport/5.2.1/stlport/stl/_cstring.h
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSTRING
|
||||
#define _STLP_INTERNAL_CSTRING
|
||||
|
||||
#if defined (_STLP_USE_NEW_C_HEADERS)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <cstring>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(cstring)
|
||||
# endif
|
||||
#else
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef _STLP_IMPORT_VENDOR_CSTD
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
# include <using/cstring>
|
||||
_STLP_END_NAMESPACE
|
||||
#endif /* _STLP_IMPORT_VENDOR_CSTD */
|
||||
|
||||
#endif /* _STLP_INTERNAL_CSTRING */
|
||||
56
extern/STLport/5.2.1/stlport/stl/_ctime.h
vendored
Normal file
56
extern/STLport/5.2.1/stlport/stl/_ctime.h
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_CTIME
|
||||
#define _STLP_INTERNAL_CTIME
|
||||
|
||||
#if !defined (_STLP_WCE_EVC3)
|
||||
|
||||
# if defined (_STLP_USE_NEW_C_HEADERS)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <ctime>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(ctime)
|
||||
# endif
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_IMPORT_VENDOR_CSTD)
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
using _STLP_VENDOR_CSTD::size_t;
|
||||
using _STLP_VENDOR_CSTD::clock_t;
|
||||
using _STLP_VENDOR_CSTD::time_t;
|
||||
using _STLP_VENDOR_CSTD::tm;
|
||||
# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
|
||||
using _STLP_VENDOR_CSTD::clock;
|
||||
using _STLP_VENDOR_CSTD::asctime;
|
||||
using _STLP_VENDOR_CSTD::ctime;
|
||||
using _STLP_VENDOR_CSTD::gmtime;
|
||||
|
||||
# if !defined (_WIN32_WCE) || (_WIN32_WCE < 0x500) // CE5 stopped supplying this
|
||||
using _STLP_VENDOR_CSTD::difftime;
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD::mktime;
|
||||
using _STLP_VENDOR_CSTD::localtime;
|
||||
using _STLP_VENDOR_CSTD::strftime;
|
||||
using _STLP_VENDOR_CSTD::time;
|
||||
# endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */
|
||||
_STLP_END_NAMESPACE
|
||||
# endif /* _STLP_IMPORT_VENDOR_CSTD */
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_CTIME */
|
||||
91
extern/STLport/5.2.1/stlport/stl/_ctraits_fns.h
vendored
Normal file
91
extern/STLport/5.2.1/stlport/stl/_ctraits_fns.h
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Silicon Graphics makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
// WARNING: This is an internal header file, included by other C++
|
||||
// standard library headers. You should not attempt to use this header
|
||||
// file directly.
|
||||
|
||||
#ifndef _STLP_INTERNAL_CTRAITS_FUNCTIONS_H
|
||||
#define _STLP_INTERNAL_CTRAITS_FUNCTIONS_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
|
||||
# include <stl/_function_base.h>
|
||||
#endif
|
||||
|
||||
// This file contains a few small adapters that allow a character
|
||||
// traits class to be used as a function object.
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Traits>
|
||||
struct _Eq_traits
|
||||
: public binary_function<typename _Traits::char_type,
|
||||
typename _Traits::char_type,
|
||||
bool> {
|
||||
bool operator()(const typename _Traits::char_type& __x,
|
||||
const typename _Traits::char_type& __y) const
|
||||
{ return _Traits::eq(__x, __y); }
|
||||
};
|
||||
|
||||
template <class _Traits>
|
||||
struct _Eq_char_bound
|
||||
: public unary_function<typename _Traits::char_type, bool> {
|
||||
typename _Traits::char_type __val;
|
||||
_Eq_char_bound(typename _Traits::char_type __c) : __val(__c) {}
|
||||
bool operator()(const typename _Traits::char_type& __x) const
|
||||
{ return _Traits::eq(__x, __val); }
|
||||
};
|
||||
|
||||
template <class _Traits>
|
||||
struct _Neq_char_bound
|
||||
: public unary_function<typename _Traits::char_type, bool>
|
||||
{
|
||||
typename _Traits::char_type __val;
|
||||
_Neq_char_bound(typename _Traits::char_type __c) : __val(__c) {}
|
||||
bool operator()(const typename _Traits::char_type& __x) const
|
||||
{ return !_Traits::eq(__x, __val); }
|
||||
};
|
||||
|
||||
template <class _Traits>
|
||||
struct _Eq_int_bound
|
||||
: public unary_function<typename _Traits::char_type, bool> {
|
||||
typename _Traits::int_type __val;
|
||||
|
||||
_Eq_int_bound(typename _Traits::int_type __c) : __val(__c) {}
|
||||
bool operator()(const typename _Traits::char_type& __x) const
|
||||
{ return _Traits::eq_int_type(_Traits::to_int_type(__x), __val); }
|
||||
};
|
||||
|
||||
#if 0
|
||||
template <class _Traits>
|
||||
struct _Lt_traits
|
||||
: public binary_function<typename _Traits::char_type,
|
||||
typename _Traits::char_type,
|
||||
bool> {
|
||||
bool operator()(const typename _Traits::char_type& __x,
|
||||
const typename _Traits::char_type& __y) const
|
||||
{ return _Traits::lt(__x, __y); }
|
||||
};
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_CTRAITS_FUNCTIONS_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
280
extern/STLport/5.2.1/stlport/stl/_ctype.h
vendored
Normal file
280
extern/STLport/5.2.1/stlport/stl/_ctype.h
vendored
Normal file
@@ -0,0 +1,280 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
// WARNING: This is an internal header file, included by other C++
|
||||
// standard library headers. You should not attempt to use this header
|
||||
// file directly.
|
||||
|
||||
#ifndef _STLP_INTERNAL_CTYPE_H
|
||||
#define _STLP_INTERNAL_CTYPE_H
|
||||
|
||||
#ifndef _STLP_C_LOCALE_H
|
||||
# include <stl/c_locale.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_LOCALE_H
|
||||
# include <stl/_locale.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALGOBASE_H
|
||||
# include <stl/_algobase.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
class _STLP_CLASS_DECLSPEC ctype_base {
|
||||
public:
|
||||
enum mask {
|
||||
space = _Locale_SPACE,
|
||||
print = _Locale_PRINT,
|
||||
cntrl = _Locale_CNTRL,
|
||||
upper = _Locale_UPPER,
|
||||
lower = _Locale_LOWER,
|
||||
alpha = _Locale_ALPHA,
|
||||
digit = _Locale_DIGIT,
|
||||
punct = _Locale_PUNCT,
|
||||
xdigit = _Locale_XDIGIT,
|
||||
alnum = alpha | digit,
|
||||
graph = alnum | punct
|
||||
};
|
||||
};
|
||||
|
||||
// ctype<> template
|
||||
|
||||
template <class charT> class ctype {};
|
||||
template <class charT> class ctype_byname {};
|
||||
|
||||
//ctype specializations
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC ctype<char> : public locale::facet, public ctype_base {
|
||||
#ifndef _STLP_NO_WCHAR_T
|
||||
# ifdef _STLP_MSVC
|
||||
typedef ctype<wchar_t> _Wctype;
|
||||
friend _Wctype;
|
||||
# else
|
||||
friend class ctype<wchar_t>;
|
||||
# endif
|
||||
#endif
|
||||
public:
|
||||
|
||||
typedef char char_type;
|
||||
|
||||
explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0);
|
||||
bool is(mask __m, char __c) const
|
||||
{ return ((*(_M_ctype_table+(unsigned char)__c)) & __m) != 0; }
|
||||
|
||||
const char* is(const char* __low, const char* __high, mask* __vec) const {
|
||||
for (const char* __p = __low;__p != __high; ++__p, ++__vec) {
|
||||
*__vec = _M_ctype_table[(unsigned char)*__p];
|
||||
}
|
||||
return __high;
|
||||
}
|
||||
|
||||
const char* scan_is(mask __m, const char* __low, const char* __high) const;
|
||||
const char* scan_not(mask __m, const char* __low, const char* __high) const;
|
||||
|
||||
char (toupper)(char __c) const { return do_toupper(__c); }
|
||||
const char* (toupper)(char* __low, const char* __high) const {
|
||||
return do_toupper(__low, __high);
|
||||
}
|
||||
|
||||
char (tolower)(char __c) const { return do_tolower(__c); }
|
||||
const char* (tolower)(char* __low, const char* __high) const {
|
||||
return do_tolower(__low, __high);
|
||||
}
|
||||
|
||||
char widen(char __c) const { return do_widen(__c); }
|
||||
const char* widen(const char* __low, const char* __high, char* __to) const {
|
||||
return do_widen(__low, __high, __to);
|
||||
}
|
||||
|
||||
char narrow(char __c, char __dfault) const {
|
||||
return do_narrow(__c, __dfault);
|
||||
}
|
||||
const char* narrow(const char* __low, const char* __high,
|
||||
char __dfault, char* __to) const {
|
||||
return do_narrow(__low, __high, __dfault, __to);
|
||||
}
|
||||
|
||||
static _STLP_STATIC_DECLSPEC locale::id id;
|
||||
_STLP_STATIC_CONSTANT(size_t, table_size = 256);
|
||||
|
||||
protected:
|
||||
const mask* table() const _STLP_NOTHROW { return _M_ctype_table; }
|
||||
static const mask* _STLP_CALL classic_table() _STLP_NOTHROW;
|
||||
|
||||
~ctype();
|
||||
|
||||
virtual char do_toupper(char __c) const;
|
||||
virtual char do_tolower(char __c) const;
|
||||
virtual const char* do_toupper(char* __low, const char* __high) const;
|
||||
virtual const char* do_tolower(char* __low, const char* __high) const;
|
||||
virtual char do_widen(char __c) const;
|
||||
virtual const char* do_widen(const char* __low, const char* __high,
|
||||
char* __to) const;
|
||||
virtual char do_narrow(char __c, char /* dfault */ ) const;
|
||||
virtual const char* do_narrow(const char* __low, const char* __high,
|
||||
char /* dfault */, char* __to) const;
|
||||
private:
|
||||
struct _Is_mask {
|
||||
mask __m;
|
||||
_Is_mask(mask __x): __m(__x) {}
|
||||
bool operator()(char __c) {return (__m & (unsigned char) __c) != 0;}
|
||||
};
|
||||
|
||||
protected:
|
||||
const mask* _M_ctype_table;
|
||||
private:
|
||||
bool _M_delete;
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC ctype_byname<char>: public ctype<char> {
|
||||
friend class _Locale_impl;
|
||||
public:
|
||||
explicit ctype_byname(const char*, size_t = 0);
|
||||
~ctype_byname();
|
||||
|
||||
virtual char do_toupper(char __c) const;
|
||||
virtual char do_tolower(char __c) const;
|
||||
|
||||
virtual const char* do_toupper(char*, const char*) const;
|
||||
virtual const char* do_tolower(char*, const char*) const;
|
||||
|
||||
private:
|
||||
ctype_byname(_Locale_ctype* __ctype)
|
||||
: _M_ctype(__ctype)
|
||||
{ _M_init(); }
|
||||
|
||||
void _M_init();
|
||||
|
||||
//explicitely defined as private to avoid warnings:
|
||||
typedef ctype_byname<char> _Self;
|
||||
ctype_byname(_Self const&);
|
||||
_Self& operator = (_Self const&);
|
||||
|
||||
mask _M_byname_table[table_size];
|
||||
_Locale_ctype* _M_ctype;
|
||||
};
|
||||
|
||||
# ifndef _STLP_NO_WCHAR_T
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC ctype<wchar_t> : public locale::facet, public ctype_base {
|
||||
public:
|
||||
typedef wchar_t char_type;
|
||||
|
||||
explicit ctype(size_t __refs = 0) : locale::facet(__refs) {}
|
||||
|
||||
bool is(mask __m, wchar_t __c) const
|
||||
{ return do_is(__m, __c); }
|
||||
|
||||
const wchar_t* is(const wchar_t* __low, const wchar_t* __high,
|
||||
mask* __vec) const
|
||||
{ return do_is(__low, __high, __vec); }
|
||||
|
||||
const wchar_t* scan_is(mask __m,
|
||||
const wchar_t* __low, const wchar_t* __high) const
|
||||
{ return do_scan_is(__m, __low, __high); }
|
||||
|
||||
const wchar_t* scan_not (mask __m,
|
||||
const wchar_t* __low, const wchar_t* __high) const
|
||||
{ return do_scan_not(__m, __low, __high); }
|
||||
|
||||
wchar_t (toupper)(wchar_t __c) const { return do_toupper(__c); }
|
||||
const wchar_t* (toupper)(wchar_t* __low, const wchar_t* __high) const
|
||||
{ return do_toupper(__low, __high); }
|
||||
|
||||
wchar_t (tolower)(wchar_t __c) const { return do_tolower(__c); }
|
||||
const wchar_t* (tolower)(wchar_t* __low, const wchar_t* __high) const
|
||||
{ return do_tolower(__low, __high); }
|
||||
|
||||
wchar_t widen(char __c) const { return do_widen(__c); }
|
||||
const char* widen(const char* __low, const char* __high,
|
||||
wchar_t* __to) const
|
||||
{ return do_widen(__low, __high, __to); }
|
||||
|
||||
char narrow(wchar_t __c, char __dfault) const
|
||||
{ return do_narrow(__c, __dfault); }
|
||||
const wchar_t* narrow(const wchar_t* __low, const wchar_t* __high,
|
||||
char __dfault, char* __to) const
|
||||
{ return do_narrow(__low, __high, __dfault, __to); }
|
||||
|
||||
static _STLP_STATIC_DECLSPEC locale::id id;
|
||||
|
||||
protected:
|
||||
~ctype();
|
||||
|
||||
virtual bool do_is(mask __m, wchar_t __c) const;
|
||||
virtual const wchar_t* do_is(const wchar_t*, const wchar_t*, mask*) const;
|
||||
virtual const wchar_t* do_scan_is(mask,
|
||||
const wchar_t*, const wchar_t*) const;
|
||||
virtual const wchar_t* do_scan_not(mask,
|
||||
const wchar_t*, const wchar_t*) const;
|
||||
virtual wchar_t do_toupper(wchar_t __c) const;
|
||||
virtual const wchar_t* do_toupper(wchar_t*, const wchar_t*) const;
|
||||
virtual wchar_t do_tolower(wchar_t c) const;
|
||||
virtual const wchar_t* do_tolower(wchar_t*, const wchar_t*) const;
|
||||
virtual wchar_t do_widen(char c) const;
|
||||
virtual const char* do_widen(const char*, const char*, wchar_t*) const;
|
||||
virtual char do_narrow(wchar_t __c, char __dfault) const;
|
||||
virtual const wchar_t* do_narrow(const wchar_t*, const wchar_t*,
|
||||
char, char*) const;
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC ctype_byname<wchar_t>: public ctype<wchar_t> {
|
||||
friend class _Locale_impl;
|
||||
public:
|
||||
explicit ctype_byname(const char* __name, size_t __refs = 0);
|
||||
|
||||
protected:
|
||||
~ctype_byname();
|
||||
|
||||
virtual bool do_is(mask __m, wchar_t __c) const;
|
||||
virtual const wchar_t* do_is(const wchar_t*, const wchar_t*, mask*) const;
|
||||
virtual const wchar_t* do_scan_is(mask,
|
||||
const wchar_t*, const wchar_t*) const;
|
||||
virtual const wchar_t* do_scan_not(mask,
|
||||
const wchar_t*, const wchar_t*) const;
|
||||
virtual wchar_t do_toupper(wchar_t __c) const;
|
||||
virtual const wchar_t* do_toupper(wchar_t*, const wchar_t*) const;
|
||||
virtual wchar_t do_tolower(wchar_t c) const;
|
||||
virtual const wchar_t* do_tolower(wchar_t*, const wchar_t*) const;
|
||||
|
||||
private:
|
||||
ctype_byname(_Locale_ctype* __ctype)
|
||||
: _M_ctype(__ctype) {}
|
||||
|
||||
//explicitely defined as private to avoid warnings:
|
||||
typedef ctype_byname<wchar_t> _Self;
|
||||
ctype_byname(_Self const&);
|
||||
_Self& operator = (_Self const&);
|
||||
|
||||
_Locale_ctype* _M_ctype;
|
||||
};
|
||||
|
||||
# endif /* WCHAR_T */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_CTYPE_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
342
extern/STLport/5.2.1/stlport/stl/_cwchar.h
vendored
Normal file
342
extern/STLport/5.2.1/stlport/stl/_cwchar.h
vendored
Normal file
@@ -0,0 +1,342 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_CWCHAR
|
||||
#define _STLP_INTERNAL_CWCHAR
|
||||
|
||||
#if defined (_STLP_WCE_EVC3)
|
||||
# ifndef _STLP_INTERNAL_MBSTATE_T
|
||||
# include <stl/_mbstate_t.h>
|
||||
# endif
|
||||
#else
|
||||
# if defined (__GNUC__)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <cstddef>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(cstddef)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if !defined (_STLP_NO_CWCHAR) && defined (_STLP_USE_NEW_C_HEADERS)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <cwchar>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(cwchar)
|
||||
# endif
|
||||
# if defined (__OpenBSD__)
|
||||
typedef _BSD_WINT_T_ wint_t;
|
||||
# endif /* __OpenBSD__ */
|
||||
|
||||
# if defined (__DMC__)
|
||||
# define __STDC_LIMIT_MACROS
|
||||
# include <stdint.h> // WCHAR_MIN, WCHAR_MAX
|
||||
# endif
|
||||
# elif defined (_STLP_NO_WCHAR_T) || \
|
||||
(defined (__BORLANDC__) && (__BORLANDC__ < 0x570)) || \
|
||||
defined (__OpenBSD__) || defined (__FreeBSD__) || \
|
||||
(defined (__GNUC__) && (defined (__APPLE__) || defined ( __Lynx__ )))
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <stddef.h>
|
||||
# else
|
||||
# include _STLP_NATIVE_C_HEADER(stddef.h)
|
||||
# endif
|
||||
# if defined (__Lynx__)
|
||||
# ifndef _WINT_T
|
||||
typedef long int wint_t;
|
||||
# define _WINT_T
|
||||
# endif /* _WINT_T */
|
||||
# endif
|
||||
# if defined(__OpenBSD__)
|
||||
typedef _BSD_WINT_T_ wint_t;
|
||||
# endif /* __OpenBSD__ */
|
||||
# else
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <wchar.h>
|
||||
# else
|
||||
# include _STLP_NATIVE_C_HEADER(wchar.h)
|
||||
# endif
|
||||
|
||||
# if defined (__sun) && (defined (_XOPEN_SOURCE) || (_XOPEN_VERSION - 0 == 4))
|
||||
extern wint_t btowc();
|
||||
extern int fwprintf();
|
||||
extern int fwscanf();
|
||||
extern int fwide();
|
||||
extern int mbsinit();
|
||||
extern size_t mbrlen();
|
||||
extern size_t mbrtowc();
|
||||
extern size_t mbsrtowcs();
|
||||
extern int swprintf();
|
||||
extern int swscanf();
|
||||
extern int vfwprintf();
|
||||
extern int vwprintf();
|
||||
extern int vswprintf();
|
||||
extern size_t wcrtomb();
|
||||
extern size_t wcsrtombs();
|
||||
extern wchar_t *wcsstr();
|
||||
extern int wctob();
|
||||
extern wchar_t *wmemchr();
|
||||
extern int wmemcmp();
|
||||
extern wchar_t *wmemcpy();
|
||||
extern wchar_t *wmemmove();
|
||||
extern wchar_t *wmemset();
|
||||
extern int wprintf();
|
||||
extern int wscanf();
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if defined (__MSL__) && (__MSL__ <= 0x51FF) /* dwa 2/28/99 - not yet implemented by MSL */
|
||||
# define _STLP_WCHAR_MSL_EXCLUDE 1
|
||||
namespace std {
|
||||
extern "C" size_t wcsftime(wchar_t * str, size_t max_size, const wchar_t * format_str, const struct tm * timeptr);
|
||||
}
|
||||
# define _STLP_NO_NATIVE_MBSTATE_T 1
|
||||
# elif defined (__BORLANDC__)
|
||||
# if !defined (_STLP_USE_NO_IOSTREAMS)
|
||||
# define _STLP_NO_NATIVE_MBSTATE_T
|
||||
# endif
|
||||
# define _STLP_WCHAR_BORLAND_EXCLUDE 1
|
||||
# endif
|
||||
|
||||
# ifndef _STLP_INTERNAL_MBSTATE_T
|
||||
# include <stl/_mbstate_t.h>
|
||||
# endif
|
||||
|
||||
# if !defined (_STLP_NO_WCHAR_T)
|
||||
# ifndef WCHAR_MIN
|
||||
# define WCHAR_MIN 0
|
||||
/* SUNpro has some bugs with casts. wchar_t is size of int there anyway. */
|
||||
# if defined (__SUNPRO_CC) || defined (__DJGPP)
|
||||
# define WCHAR_MAX (~0)
|
||||
# else
|
||||
# define WCHAR_MAX ((wchar_t)~0)
|
||||
# endif
|
||||
# endif
|
||||
# if defined (__DMC__) || (defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB < 1400)) || defined(_WIN32_WCE)
|
||||
/* Compilers that do not define WCHAR_MIN and WCHAR_MAX to be testable at
|
||||
* preprocessing time. */
|
||||
# undef WCHAR_MIN
|
||||
# define WCHAR_MIN 0
|
||||
# undef WCHAR_MAX
|
||||
# define WCHAR_MAX 0xffff
|
||||
# endif
|
||||
# if defined (__GNUC__) && defined (__alpha__)
|
||||
/* Definition of WCHAR_MIN and MAX are wrong for alpha platform
|
||||
* as gcc consider wchar_t as an unsigned type but WCHAR_MIN is defined as
|
||||
* a negative value. Static assertion is here to check that a future alpha
|
||||
* SDK or a future gcc won't change the situation making this workaround
|
||||
* useless.
|
||||
*/
|
||||
/* Check that gcc still consider wchar_t as unsigned */
|
||||
_STLP_STATIC_ASSERT(((wchar_t)-1 > 0))
|
||||
/* Check that WCHAR_MIN value hasn't been fixed */
|
||||
_STLP_STATIC_ASSERT((WCHAR_MIN < 0))
|
||||
# undef WCHAR_MIN
|
||||
# define WCHAR_MIN 0
|
||||
# undef WCHAR_MAX
|
||||
# define WCHAR_MAX 0xffffffff
|
||||
# endif
|
||||
# if defined(__HP_aCC) && (__HP_aCC >= 60000)
|
||||
/* Starting with B.11.31, HP-UX/ia64 provides C99-compliant definitions
|
||||
* of WCHAR_MIN/MAX macros without having to define
|
||||
* _INCLUDE_STDC__SOURCE_199901 macro (which aCC compiler does not
|
||||
* predefine). Let STLport provide B.11.31 definitions on any version of
|
||||
* HP-UX/ia64.
|
||||
*/
|
||||
# undef WCHAR_MIN
|
||||
# define WCHAR_MIN 0
|
||||
# undef WCHAR_MAX
|
||||
# define WCHAR_MAX UINT_MAX
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_IMPORT_VENDOR_CSTD)
|
||||
|
||||
# if defined (__SUNPRO_CC) && !defined (_STLP_HAS_NO_NEW_C_HEADERS)
|
||||
using _STLP_VENDOR_CSTD::wint_t;
|
||||
# endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
# if defined (_STLP_NO_WCHAR_T)
|
||||
typedef int wint_t;
|
||||
# else
|
||||
// gcc 3.0 has a glitch : wint_t only sucked into the global namespace if _GLIBCPP_USE_WCHAR_T is defined
|
||||
// __MWERKS__ has definition in wchar_t.h (MSL C++), but ones differ from definition
|
||||
// in stdio.h; I prefer settings from last file.
|
||||
# if (defined (__GNUC__) && ! defined (_GLIBCPP_USE_WCHAR_T))
|
||||
using ::wint_t;
|
||||
# else
|
||||
using _STLP_VENDOR_CSTD::wint_t;
|
||||
# endif
|
||||
# endif
|
||||
|
||||
using _STLP_VENDOR_CSTD::size_t;
|
||||
|
||||
# if !defined (_STLP_NO_NATIVE_MBSTATE_T) && !defined (_STLP_USE_OWN_MBSTATE_T)
|
||||
using _STLP_VENDOR_MB_NAMESPACE::mbstate_t;
|
||||
|
||||
# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) && !defined(_STLP_WCHAR_BORLAND_EXCLUDE) && \
|
||||
(!defined(__MSL__) || __MSL__ > 0x6001)
|
||||
# if defined (__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 3) || ((__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION >= 8))) || \
|
||||
!(defined (__KCC) || defined (__GNUC__)) && !defined(_STLP_WCE_NET)
|
||||
using _STLP_VENDOR_MB_NAMESPACE::btowc;
|
||||
# if (!defined(__MSL__) || __MSL__ > 0x7001)
|
||||
using _STLP_VENDOR_MB_NAMESPACE::mbsinit;
|
||||
# endif
|
||||
# endif
|
||||
# if defined (__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 3) || ((__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION >= 8))) || \
|
||||
!defined (__GNUC__) && !defined(_STLP_WCE_NET)
|
||||
using _STLP_VENDOR_MB_NAMESPACE::mbrlen;
|
||||
using _STLP_VENDOR_MB_NAMESPACE::mbrtowc;
|
||||
using _STLP_VENDOR_MB_NAMESPACE::mbsrtowcs;
|
||||
using _STLP_VENDOR_MB_NAMESPACE::wcrtomb;
|
||||
using _STLP_VENDOR_MB_NAMESPACE::wcsrtombs;
|
||||
# endif
|
||||
# endif /* BORLAND && !__MSL__ || __MSL__ > 0x6001 */
|
||||
|
||||
# endif /* _STLP_NO_NATIVE_MBSTATE_T */
|
||||
|
||||
# if !defined (_STLP_NO_NATIVE_WIDE_FUNCTIONS) && ! defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
|
||||
|
||||
# if !defined (_STLP_WCHAR_BORLAND_EXCLUDE) && ! defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
|
||||
using _STLP_VENDOR_CSTD::fgetwc;
|
||||
using _STLP_VENDOR_CSTD::fgetws;
|
||||
using _STLP_VENDOR_CSTD::fputwc;
|
||||
using _STLP_VENDOR_CSTD::fputws;
|
||||
# endif
|
||||
|
||||
# if !(defined (_STLP_WCHAR_SUNPRO_EXCLUDE) || defined (_STLP_WCHAR_BORLAND_EXCLUDE) || \
|
||||
defined(_STLP_WCHAR_HPACC_EXCLUDE) )
|
||||
# if !defined (__DECCXX)
|
||||
using _STLP_VENDOR_CSTD::fwide;
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD::fwprintf;
|
||||
using _STLP_VENDOR_CSTD::fwscanf;
|
||||
using _STLP_VENDOR_CSTD::getwchar;
|
||||
# endif
|
||||
|
||||
# if !defined(_STLP_WCHAR_BORLAND_EXCLUDE)
|
||||
# ifndef _STLP_WCE_NET
|
||||
using _STLP_VENDOR_CSTD::getwc;
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD::ungetwc;
|
||||
# ifndef _STLP_WCE_NET
|
||||
using _STLP_VENDOR_CSTD::putwc;
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD::putwchar;
|
||||
# endif
|
||||
|
||||
# if !(defined (_STLP_WCHAR_SUNPRO_EXCLUDE) || defined (_STLP_WCHAR_BORLAND_EXCLUDE) || \
|
||||
defined (_STLP_WCHAR_HPACC_EXCLUDE) )
|
||||
# if defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB <= 1300) || \
|
||||
defined (__MINGW32__)
|
||||
# undef swprintf
|
||||
# define swprintf _snwprintf
|
||||
# undef vswprintf
|
||||
# define vswprintf _vsnwprintf
|
||||
using ::swprintf;
|
||||
using ::vswprintf;
|
||||
# else
|
||||
using _STLP_VENDOR_CSTD::swprintf;
|
||||
using _STLP_VENDOR_CSTD::vswprintf;
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD::swscanf;
|
||||
using _STLP_VENDOR_CSTD::vfwprintf;
|
||||
using _STLP_VENDOR_CSTD::vwprintf;
|
||||
|
||||
# if (!defined(__MSL__) || __MSL__ > 0x7001 ) && !defined(_STLP_WCE_NET) && \
|
||||
!defined(_STLP_USE_UCLIBC) /* at least in uClibc 0.9.26 */
|
||||
|
||||
using _STLP_VENDOR_CSTD::wcsftime;
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD::wcstok;
|
||||
|
||||
# endif
|
||||
|
||||
# if !defined (_STLP_WCE_NET)
|
||||
using _STLP_VENDOR_CSTD::wcscoll;
|
||||
using _STLP_VENDOR_CSTD::wcsxfrm;
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD::wcscat;
|
||||
using _STLP_VENDOR_CSTD::wcsrchr;
|
||||
using _STLP_VENDOR_CSTD::wcscmp;
|
||||
|
||||
using _STLP_VENDOR_CSTD::wcscpy;
|
||||
using _STLP_VENDOR_CSTD::wcscspn;
|
||||
|
||||
using _STLP_VENDOR_CSTD::wcslen;
|
||||
using _STLP_VENDOR_CSTD::wcsncat;
|
||||
using _STLP_VENDOR_CSTD::wcsncmp;
|
||||
using _STLP_VENDOR_CSTD::wcsncpy;
|
||||
using _STLP_VENDOR_CSTD::wcspbrk;
|
||||
using _STLP_VENDOR_CSTD::wcschr;
|
||||
|
||||
using _STLP_VENDOR_CSTD::wcsspn;
|
||||
|
||||
# if !defined (_STLP_WCHAR_BORLAND_EXCLUDE)
|
||||
using _STLP_VENDOR_CSTD::wcstod;
|
||||
using _STLP_VENDOR_CSTD::wcstol;
|
||||
# endif
|
||||
|
||||
# if !(defined (_STLP_WCHAR_SUNPRO_EXCLUDE) || defined (_STLP_WCHAR_HPACC_EXCLUDE) )
|
||||
using _STLP_VENDOR_CSTD::wcsstr;
|
||||
using _STLP_VENDOR_CSTD::wmemchr;
|
||||
|
||||
# if !defined (_STLP_WCHAR_BORLAND_EXCLUDE)
|
||||
# if !defined (_STLP_WCE_NET)
|
||||
using _STLP_VENDOR_CSTD::wctob;
|
||||
# endif
|
||||
# if !defined (__DMC__)
|
||||
using _STLP_VENDOR_CSTD::wmemcmp;
|
||||
using _STLP_VENDOR_CSTD::wmemmove;
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD::wprintf;
|
||||
using _STLP_VENDOR_CSTD::wscanf;
|
||||
# endif
|
||||
|
||||
# if defined (__BORLANDC__) && !defined (__linux__)
|
||||
inline wchar_t* _STLP_wmemcpy(wchar_t* __wdst, const wchar_t* __wsrc, size_t __n)
|
||||
{ return __STATIC_CAST(wchar_t*, _STLP_VENDOR_CSTD::wmemcpy(__wdst, __wsrc, __n)); }
|
||||
inline wchar_t* _STLP_wmemset(wchar_t* __wdst, wchar_t __wc, size_t __n)
|
||||
{ return __STATIC_CAST(wchar_t*, _STLP_VENDOR_CSTD::memset(__wdst, __wc, __n)); }
|
||||
# undef wmemcpy
|
||||
# undef wmemset
|
||||
inline wchar_t* wmemcpy(wchar_t* __wdst, const wchar_t* __wsrc, size_t __n)
|
||||
{ return _STLP_wmemcpy(__wdst, __wsrc, __n); }
|
||||
inline wchar_t* wmemset(wchar_t* __wdst, wchar_t __wc, size_t __n)
|
||||
{ return _STLP_wmemset(__wdst, __wc, __n); }
|
||||
# elif defined (__DMC__)
|
||||
inline wchar_t* wmemcpy(wchar_t* __RESTRICT __wdst, const wchar_t* __RESTRICT __wsrc, size_t __n)
|
||||
{ return __STATIC_CAST(wchar_t*, memcpy(__wdst, __wsrc, __n * sizeof(wchar_t))); }
|
||||
inline wchar_t* wmemmove(wchar_t* __RESTRICT __wdst, const wchar_t * __RESTRICT __wc, size_t __n)
|
||||
{ return __STATIC_CAST(wchar_t*, memmove(__wdst, __wc, __n * sizeof(wchar_t))); }
|
||||
inline wchar_t* wmemset(wchar_t* __wdst, wchar_t __wc, size_t __n)
|
||||
{ for (size_t i = 0; i < __n; i++) __wdst[i] = __wc; return __wdst; }
|
||||
# else
|
||||
using _STLP_VENDOR_CSTD::wmemcpy;
|
||||
using _STLP_VENDOR_CSTD::wmemset;
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# endif /* _STLP_NO_NATIVE_WIDE_FUNCTIONS */
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# endif /* _STLP_IMPORT_VENDOR_CSTD */
|
||||
|
||||
# undef _STLP_WCHAR_SUNPRO_EXCLUDE
|
||||
# undef _STLP_WCHAR_MSL_EXCLUDE
|
||||
|
||||
# endif /* !defined(_STLP_WCE_EVC3) */
|
||||
|
||||
#endif /* _STLP_INTERNAL_CWCHAR */
|
||||
89
extern/STLport/5.2.1/stlport/stl/_cwctype.h
vendored
Normal file
89
extern/STLport/5.2.1/stlport/stl/_cwctype.h
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_CWCTYPE
|
||||
#define _STLP_INTERNAL_CWCTYPE
|
||||
|
||||
#if defined (__BORLANDC__) && !defined (_STLP_INTERNAL_CCTYPE)
|
||||
# include <stl/_cctype.h>
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_WCE_EVC3)
|
||||
# if defined (_STLP_USE_NEW_C_HEADERS)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <cwctype>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(cwctype)
|
||||
# endif
|
||||
# if defined (__MSL__)
|
||||
namespace std {
|
||||
typedef wchar_t wctrans_t;
|
||||
wint_t towctrans(wint_t c, wctrans_t value);
|
||||
wctrans_t wctrans(const char *name);
|
||||
}
|
||||
using std::wctrans_t;
|
||||
using std::towctrans;
|
||||
using std::wctrans;
|
||||
# endif
|
||||
# else
|
||||
# include <wctype.h>
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_IMPORT_VENDOR_CSTD) && !defined (__hpux)
|
||||
|
||||
# if defined (_STLP_USE_GLIBC) && !(defined (_GLIBCPP_USE_WCHAR_T) || defined (_GLIBCXX_USE_WCHAR_T)) || \
|
||||
defined (__sun) || defined (__FreeBSD__) || \
|
||||
defined (__CYGWIN__) || \
|
||||
defined (__MINGW32__) && ((__MINGW32_MAJOR_VERSION < 3) || (__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION <= 0))
|
||||
//We take wide functions from global namespace:
|
||||
# define _STLP_VENDOR_CSTD_WFUNC
|
||||
# else
|
||||
# define _STLP_VENDOR_CSTD_WFUNC _STLP_VENDOR_CSTD
|
||||
# endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
using _STLP_VENDOR_CSTD_WFUNC::wctype_t;
|
||||
using _STLP_VENDOR_CSTD_WFUNC::wint_t;
|
||||
# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
|
||||
# if !defined (__BORLANDC__) && !defined (__MSL__)
|
||||
using _STLP_VENDOR_CSTD_WFUNC::wctrans_t;
|
||||
# if !defined (__DMC__) && (!defined(_WIN32_WCE) || (_WIN32_WCE < 400))
|
||||
using _STLP_VENDOR_CSTD_WFUNC::towctrans;
|
||||
using _STLP_VENDOR_CSTD_WFUNC::wctrans;
|
||||
using _STLP_VENDOR_CSTD_WFUNC::wctype;
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD_WFUNC::iswctype;
|
||||
# endif
|
||||
using _STLP_VENDOR_CSTD_WFUNC::iswalnum;
|
||||
using _STLP_VENDOR_CSTD_WFUNC::iswalpha;
|
||||
using _STLP_VENDOR_CSTD_WFUNC::iswcntrl;
|
||||
|
||||
using _STLP_VENDOR_CSTD_WFUNC::iswdigit;
|
||||
using _STLP_VENDOR_CSTD_WFUNC::iswgraph;
|
||||
using _STLP_VENDOR_CSTD_WFUNC::iswlower;
|
||||
using _STLP_VENDOR_CSTD_WFUNC::iswprint;
|
||||
using _STLP_VENDOR_CSTD_WFUNC::iswpunct;
|
||||
using _STLP_VENDOR_CSTD_WFUNC::iswspace;
|
||||
using _STLP_VENDOR_CSTD_WFUNC::iswupper;
|
||||
using _STLP_VENDOR_CSTD_WFUNC::iswxdigit;
|
||||
|
||||
using _STLP_VENDOR_CSTD_WFUNC::towlower;
|
||||
using _STLP_VENDOR_CSTD_WFUNC::towupper;
|
||||
# endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */
|
||||
_STLP_END_NAMESPACE
|
||||
# endif /* _STLP_IMPORT_VENDOR_CSTD */
|
||||
#endif /* _STLP_WCE_EVC3 */
|
||||
|
||||
#endif /* _STLP_INTERNAL_CWCTYPE */
|
||||
823
extern/STLport/5.2.1/stlport/stl/_deque.c
vendored
Normal file
823
extern/STLport/5.2.1/stlport/stl/_deque.c
vendored
Normal file
@@ -0,0 +1,823 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_DEQUE_C
|
||||
#define _STLP_DEQUE_C
|
||||
|
||||
#ifndef _STLP_INTERNAL_DEQUE_H
|
||||
# include <stl/_deque.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
// Non-inline member functions from _Deque_base.
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
_Deque_base<_Tp,_Alloc >::~_Deque_base() {
|
||||
if (_M_map._M_data) {
|
||||
_M_destroy_nodes(_M_start._M_node, this->_M_finish._M_node + 1);
|
||||
_M_map.deallocate(_M_map._M_data, _M_map_size._M_data);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
void _Deque_base<_Tp,_Alloc>::_M_initialize_map(size_t __num_elements) {
|
||||
size_t __num_nodes = __num_elements / this->buffer_size() + 1 ;
|
||||
|
||||
_M_map_size._M_data = (max)((size_t) _S_initial_map_size, __num_nodes + 2);
|
||||
_M_map._M_data = _M_map.allocate(_M_map_size._M_data);
|
||||
|
||||
_Tp** __nstart = _M_map._M_data + (_M_map_size._M_data - __num_nodes) / 2;
|
||||
_Tp** __nfinish = __nstart + __num_nodes;
|
||||
|
||||
_STLP_TRY {
|
||||
_M_create_nodes(__nstart, __nfinish);
|
||||
}
|
||||
_STLP_UNWIND((_M_map.deallocate(_M_map._M_data, _M_map_size._M_data),
|
||||
_M_map._M_data = 0, _M_map_size._M_data = 0))
|
||||
_M_start._M_set_node(__nstart);
|
||||
this->_M_finish._M_set_node(__nfinish - 1);
|
||||
_M_start._M_cur = _M_start._M_first;
|
||||
this->_M_finish._M_cur = this->_M_finish._M_first + __num_elements % this->buffer_size();
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
void _Deque_base<_Tp,_Alloc>::_M_create_nodes(_Tp** __nstart,
|
||||
_Tp** __nfinish) {
|
||||
_Tp** __cur = __nstart;
|
||||
_STLP_TRY {
|
||||
for (; __cur < __nfinish; ++__cur)
|
||||
*__cur = _M_map_size.allocate(this->buffer_size());
|
||||
}
|
||||
_STLP_UNWIND(_M_destroy_nodes(__nstart, __cur))
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
void _Deque_base<_Tp,_Alloc>::_M_destroy_nodes(_Tp** __nstart,
|
||||
_Tp** __nfinish) {
|
||||
for (_Tp** __n = __nstart; __n < __nfinish; ++__n)
|
||||
_M_map_size.deallocate(*__n, this->buffer_size());
|
||||
}
|
||||
|
||||
#if defined (_STLP_USE_PTR_SPECIALIZATIONS)
|
||||
# define deque _STLP_PTR_IMPL_NAME(deque)
|
||||
#elif defined (_STLP_DEBUG)
|
||||
# define deque _STLP_NON_DBG_NAME(deque)
|
||||
#else
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_NESTED_TYPE_PARAM_BUG)
|
||||
// qualified references
|
||||
# define __iterator__ _Deque_iterator<_Tp, _Nonconst_traits<_Tp> >
|
||||
# define const_iterator _Deque_iterator<_Tp, _Const_traits<_Tp> >
|
||||
# define iterator __iterator__
|
||||
# define size_type size_t
|
||||
# define value_type _Tp
|
||||
#else
|
||||
# define __iterator__ _STLP_TYPENAME_ON_RETURN_TYPE deque<_Tp, _Alloc>::iterator
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
deque<_Tp, _Alloc >&
|
||||
deque<_Tp, _Alloc >::operator= (const deque<_Tp, _Alloc >& __x) {
|
||||
const size_type __len = size();
|
||||
if (&__x != this) {
|
||||
if (__len >= __x.size())
|
||||
erase(_STLP_STD::copy(__x.begin(), __x.end(), this->_M_start), this->_M_finish);
|
||||
else {
|
||||
const_iterator __mid = __x.begin() + difference_type(__len);
|
||||
_STLP_STD::copy(__x.begin(), __mid, this->_M_start);
|
||||
insert(this->_M_finish, __mid, __x.end());
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp, _Alloc >::_M_fill_insert(iterator __pos,
|
||||
size_type __n, const value_type& __x) {
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
typedef typename __move_traits<_Tp>::implemented _Movable;
|
||||
#endif
|
||||
if (__pos._M_cur == this->_M_start._M_cur) {
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
_STLP_TRY {
|
||||
uninitialized_fill(__new_start, this->_M_start, __x);
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
|
||||
this->_M_start = __new_start;
|
||||
}
|
||||
else if (__pos._M_cur == this->_M_finish._M_cur) {
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
_STLP_TRY {
|
||||
uninitialized_fill(this->_M_finish, __new_finish, __x);
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node+1, __new_finish._M_node+1))
|
||||
this->_M_finish = __new_finish;
|
||||
}
|
||||
else
|
||||
_M_fill_insert_aux(__pos, __n, __x, _Movable());
|
||||
}
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES)
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp, _Alloc>::insert(iterator __pos,
|
||||
const value_type* __first, const value_type* __last) {
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
typedef typename __move_traits<_Tp>::implemented _Movable;
|
||||
#endif
|
||||
size_type __n = __last - __first;
|
||||
if (__pos._M_cur == this->_M_start._M_cur) {
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
_STLP_TRY {
|
||||
_STLP_PRIV __ucopy(__first, __last, __new_start);
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
|
||||
this->_M_start = __new_start;
|
||||
}
|
||||
else if (__pos._M_cur == this->_M_finish._M_cur) {
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
_STLP_TRY {
|
||||
_STLP_PRIV __ucopy(__first, __last, this->_M_finish);
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1,
|
||||
__new_finish._M_node + 1))
|
||||
this->_M_finish = __new_finish;
|
||||
}
|
||||
else
|
||||
_M_insert_range_aux(__pos, __first, __last, __n, _Movable());
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::insert(iterator __pos,
|
||||
const_iterator __first, const_iterator __last) {
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
typedef typename __move_traits<_Tp>::implemented _Movable;
|
||||
#endif
|
||||
size_type __n = __last - __first;
|
||||
if (__pos._M_cur == this->_M_start._M_cur) {
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
_STLP_TRY {
|
||||
_STLP_PRIV __ucopy(__first, __last, __new_start);
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
|
||||
this->_M_start = __new_start;
|
||||
}
|
||||
else if (__pos._M_cur == this->_M_finish._M_cur) {
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
_STLP_TRY {
|
||||
_STLP_PRIV __ucopy(__first, __last, this->_M_finish);
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1,
|
||||
__new_finish._M_node + 1))
|
||||
this->_M_finish = __new_finish;
|
||||
}
|
||||
else
|
||||
_M_insert_range_aux(__pos, __first, __last, __n, _Movable());
|
||||
}
|
||||
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
__iterator__ deque<_Tp,_Alloc>::_M_erase(iterator __pos,
|
||||
const __true_type& /*_Movable*/) {
|
||||
difference_type __index = __pos - this->_M_start;
|
||||
if (size_type(__index) < this->size() >> 1) {
|
||||
//We move the start of the deque one position to the right
|
||||
//starting from the rightmost element to move.
|
||||
iterator __src = __pos, __dst = __pos;
|
||||
_STLP_STD::_Destroy(&(*__dst));
|
||||
if (__src != this->_M_start) {
|
||||
for (--__src; __dst != this->_M_start; --__src, --__dst) {
|
||||
_STLP_STD::_Move_Construct(&(*__dst), *__src);
|
||||
_STLP_STD::_Destroy_Moved(&(*__src));
|
||||
}
|
||||
}
|
||||
_M_pop_front_aux();
|
||||
}
|
||||
else {
|
||||
iterator __src = __pos, __dst = __pos;
|
||||
_STLP_STD::_Destroy(&(*__dst));
|
||||
for (++__src; __src != this->_M_finish; ++__src, ++__dst) {
|
||||
_STLP_STD::_Move_Construct(&(*__dst), *__src);
|
||||
_STLP_STD::_Destroy_Moved(&(*__src));
|
||||
}
|
||||
//Duplication of the pop_back code without the destroy which has already been done:
|
||||
if (this->_M_finish._M_cur != this->_M_finish._M_first) {
|
||||
--this->_M_finish._M_cur;
|
||||
}
|
||||
else {
|
||||
_M_pop_back_aux();
|
||||
}
|
||||
}
|
||||
return this->_M_start + __index;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
__iterator__ deque<_Tp,_Alloc>::_M_erase(iterator __pos,
|
||||
const __false_type& /*_Movable*/) {
|
||||
iterator __next = __pos;
|
||||
++__next;
|
||||
difference_type __index = __pos - this->_M_start;
|
||||
if (size_type(__index) < this->size() >> 1) {
|
||||
copy_backward(this->_M_start, __pos, __next);
|
||||
pop_front();
|
||||
}
|
||||
else {
|
||||
_STLP_STD::copy(__next, this->_M_finish, __pos);
|
||||
pop_back();
|
||||
}
|
||||
return this->_M_start + __index;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
__iterator__ deque<_Tp,_Alloc>::_M_erase(iterator __first, iterator __last,
|
||||
const __true_type& /*_Movable*/) {
|
||||
difference_type __n = __last - __first;
|
||||
difference_type __elems_before = __first - this->_M_start;
|
||||
if (__elems_before <= difference_type(this->size() - __n) / 2) {
|
||||
iterator __src = __first, __dst = __last;
|
||||
if (__src != this->_M_start) {
|
||||
for (--__src, --__dst; (__src >= this->_M_start) && (__dst >= __first); --__src, --__dst) {
|
||||
_STLP_STD::_Destroy(&(*__dst));
|
||||
_STLP_STD::_Move_Construct(&(*__dst), *__src);
|
||||
}
|
||||
if (__dst >= __first) {
|
||||
//There are more elements to erase than elements to move
|
||||
_STLP_STD::_Destroy_Range(__first, ++__dst);
|
||||
_STLP_STD::_Destroy_Moved_Range(this->_M_start, __first);
|
||||
}
|
||||
else {
|
||||
//There are more elements to move than elements to erase
|
||||
for (; __src >= this->_M_start; --__src, --__dst) {
|
||||
_STLP_STD::_Destroy_Moved(&(*__dst));
|
||||
_STLP_STD::_Move_Construct(&(*__dst), *__src);
|
||||
}
|
||||
_STLP_STD::_Destroy_Moved_Range(this->_M_start, ++__dst);
|
||||
}
|
||||
}
|
||||
else {
|
||||
_STLP_STD::_Destroy_Range(this->_M_start, __last);
|
||||
}
|
||||
iterator __new_start = this->_M_start + __n;
|
||||
this->_M_destroy_nodes(this->_M_start._M_node, __new_start._M_node);
|
||||
this->_M_start = __new_start;
|
||||
}
|
||||
else {
|
||||
if (__last != this->_M_finish) {
|
||||
iterator __src = __last, __dst = __first;
|
||||
for (; (__src != this->_M_finish) && (__dst != __last); ++__src, ++__dst) {
|
||||
_STLP_STD::_Destroy(&(*__dst));
|
||||
_STLP_STD::_Move_Construct(&(*__dst), *__src);
|
||||
}
|
||||
if (__dst != __last) {
|
||||
//There are more elements to erase than elements to move
|
||||
_STLP_STD::_Destroy_Range(__dst, __last);
|
||||
_STLP_STD::_Destroy_Moved_Range(__last, this->_M_finish);
|
||||
}
|
||||
else {
|
||||
//There are more elements to move than elements to erase
|
||||
for (; __src != this->_M_finish; ++__src, ++__dst) {
|
||||
_STLP_STD::_Destroy_Moved(&(*__dst));
|
||||
_STLP_STD::_Move_Construct(&(*__dst), *__src);
|
||||
}
|
||||
_STLP_STD::_Destroy_Moved_Range(__dst, this->_M_finish);
|
||||
}
|
||||
}
|
||||
else {
|
||||
_STLP_STD::_Destroy_Range(__first, this->_M_finish);
|
||||
}
|
||||
iterator __new_finish = this->_M_finish - __n;
|
||||
this->_M_destroy_nodes(__new_finish._M_node + 1, this->_M_finish._M_node + 1);
|
||||
this->_M_finish = __new_finish;
|
||||
}
|
||||
return this->_M_start + __elems_before;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
__iterator__ deque<_Tp,_Alloc>::_M_erase(iterator __first, iterator __last,
|
||||
const __false_type& /*_Movable*/) {
|
||||
difference_type __n = __last - __first;
|
||||
difference_type __elems_before = __first - this->_M_start;
|
||||
if (__elems_before <= difference_type(this->size() - __n) / 2) {
|
||||
copy_backward(this->_M_start, __first, __last);
|
||||
iterator __new_start = this->_M_start + __n;
|
||||
_STLP_STD::_Destroy_Range(this->_M_start, __new_start);
|
||||
this->_M_destroy_nodes(this->_M_start._M_node, __new_start._M_node);
|
||||
this->_M_start = __new_start;
|
||||
}
|
||||
else {
|
||||
_STLP_STD::copy(__last, this->_M_finish, __first);
|
||||
iterator __new_finish = this->_M_finish - __n;
|
||||
_STLP_STD::_Destroy_Range(__new_finish, this->_M_finish);
|
||||
this->_M_destroy_nodes(__new_finish._M_node + 1, this->_M_finish._M_node + 1);
|
||||
this->_M_finish = __new_finish;
|
||||
}
|
||||
return this->_M_start + __elems_before;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::clear() {
|
||||
for (_Map_pointer __node = this->_M_start._M_node + 1;
|
||||
__node < this->_M_finish._M_node;
|
||||
++__node) {
|
||||
_STLP_STD::_Destroy_Range(*__node, *__node + this->buffer_size());
|
||||
this->_M_map_size.deallocate(*__node, this->buffer_size());
|
||||
}
|
||||
|
||||
if (this->_M_start._M_node != this->_M_finish._M_node) {
|
||||
_STLP_STD::_Destroy_Range(this->_M_start._M_cur, this->_M_start._M_last);
|
||||
_STLP_STD::_Destroy_Range(this->_M_finish._M_first, this->_M_finish._M_cur);
|
||||
this->_M_map_size.deallocate(this->_M_finish._M_first, this->buffer_size());
|
||||
}
|
||||
else
|
||||
_STLP_STD::_Destroy_Range(this->_M_start._M_cur, this->_M_finish._M_cur);
|
||||
|
||||
this->_M_finish = this->_M_start;
|
||||
}
|
||||
|
||||
// Precondition: this->_M_start and this->_M_finish have already been initialized,
|
||||
// but none of the deque's elements have yet been constructed.
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::_M_fill_initialize(const value_type& __val,
|
||||
const __false_type& /*_TrivialInit*/) {
|
||||
_Map_pointer __cur = this->_M_start._M_node;
|
||||
_STLP_TRY {
|
||||
for (; __cur < this->_M_finish._M_node; ++__cur)
|
||||
uninitialized_fill(*__cur, *__cur + this->buffer_size(), __val);
|
||||
uninitialized_fill(this->_M_finish._M_first, this->_M_finish._M_cur, __val);
|
||||
}
|
||||
_STLP_UNWIND(_STLP_STD::_Destroy_Range(this->_M_start, iterator(*__cur, __cur)))
|
||||
}
|
||||
|
||||
|
||||
// Called only if this->_M_finish._M_cur == this->_M_finish._M_last - 1.
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::_M_push_back_aux_v(const value_type& __t) {
|
||||
_M_reserve_map_at_back();
|
||||
*(this->_M_finish._M_node + 1) = this->_M_map_size.allocate(this->buffer_size());
|
||||
_STLP_TRY {
|
||||
_Copy_Construct(this->_M_finish._M_cur, __t);
|
||||
this->_M_finish._M_set_node(this->_M_finish._M_node + 1);
|
||||
this->_M_finish._M_cur = this->_M_finish._M_first;
|
||||
}
|
||||
_STLP_UNWIND(this->_M_map_size.deallocate(*(this->_M_finish._M_node + 1),
|
||||
this->buffer_size()))
|
||||
}
|
||||
|
||||
#if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
|
||||
// Called only if this->_M_finish._M_cur == this->_M_finish._M_last - 1.
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::_M_push_back_aux() {
|
||||
_M_reserve_map_at_back();
|
||||
*(this->_M_finish._M_node + 1) = this->_M_map_size.allocate(this->buffer_size());
|
||||
_STLP_TRY {
|
||||
_STLP_STD::_Construct(this->_M_finish._M_cur);
|
||||
this->_M_finish._M_set_node(this->_M_finish._M_node + 1);
|
||||
this->_M_finish._M_cur = this->_M_finish._M_first;
|
||||
}
|
||||
_STLP_UNWIND(this->_M_map_size.deallocate(*(this->_M_finish._M_node + 1),
|
||||
this->buffer_size()))
|
||||
}
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
|
||||
|
||||
// Called only if this->_M_start._M_cur == this->_M_start._M_first.
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::_M_push_front_aux_v(const value_type& __t) {
|
||||
_M_reserve_map_at_front();
|
||||
*(this->_M_start._M_node - 1) = this->_M_map_size.allocate(this->buffer_size());
|
||||
_STLP_TRY {
|
||||
this->_M_start._M_set_node(this->_M_start._M_node - 1);
|
||||
this->_M_start._M_cur = this->_M_start._M_last - 1;
|
||||
_Copy_Construct(this->_M_start._M_cur, __t);
|
||||
}
|
||||
_STLP_UNWIND((++this->_M_start,
|
||||
this->_M_map_size.deallocate(*(this->_M_start._M_node - 1), this->buffer_size())))
|
||||
}
|
||||
|
||||
|
||||
#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
|
||||
// Called only if this->_M_start._M_cur == this->_M_start._M_first.
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::_M_push_front_aux() {
|
||||
_M_reserve_map_at_front();
|
||||
*(this->_M_start._M_node - 1) = this->_M_map_size.allocate(this->buffer_size());
|
||||
_STLP_TRY {
|
||||
this->_M_start._M_set_node(this->_M_start._M_node - 1);
|
||||
this->_M_start._M_cur = this->_M_start._M_last - 1;
|
||||
_STLP_STD::_Construct(this->_M_start._M_cur);
|
||||
}
|
||||
_STLP_UNWIND((++this->_M_start, this->_M_map_size.deallocate(*(this->_M_start._M_node - 1),
|
||||
this->buffer_size())))
|
||||
}
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
|
||||
|
||||
// Called only if this->_M_finish._M_cur == this->_M_finish._M_first.
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::_M_pop_back_aux() {
|
||||
this->_M_map_size.deallocate(this->_M_finish._M_first, this->buffer_size());
|
||||
this->_M_finish._M_set_node(this->_M_finish._M_node - 1);
|
||||
this->_M_finish._M_cur = this->_M_finish._M_last - 1;
|
||||
}
|
||||
|
||||
// Note that if the deque has at least one element (a precondition for this member
|
||||
// function), and if this->_M_start._M_cur == this->_M_start._M_last, then the deque
|
||||
// must have at least two nodes.
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::_M_pop_front_aux() {
|
||||
if (this->_M_start._M_cur != this->_M_start._M_last - 1)
|
||||
++this->_M_start._M_cur;
|
||||
else {
|
||||
this->_M_map_size.deallocate(this->_M_start._M_first, this->buffer_size());
|
||||
this->_M_start._M_set_node(this->_M_start._M_node + 1);
|
||||
this->_M_start._M_cur = this->_M_start._M_first;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
__iterator__ deque<_Tp,_Alloc>::_M_fill_insert_aux(iterator __pos, size_type __n,
|
||||
const value_type& __x,
|
||||
const __true_type& /*_Movable*/) {
|
||||
const difference_type __elems_before = __pos - this->_M_start;
|
||||
size_type __length = this->size();
|
||||
value_type __x_copy = __x;
|
||||
if (__elems_before <= difference_type(__length / 2)) {
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
__pos = this->_M_start + __elems_before;
|
||||
_STLP_TRY {
|
||||
iterator __dst = __new_start;
|
||||
iterator __src = this->_M_start;
|
||||
for (; __src != __pos; ++__dst, ++__src) {
|
||||
_STLP_STD::_Move_Construct(&(*__dst), *__src);
|
||||
_STLP_STD::_Destroy_Moved(&(*__src));
|
||||
}
|
||||
this->_M_start = __new_start;
|
||||
uninitialized_fill(__dst, __src, __x_copy);
|
||||
__pos = __dst;
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
|
||||
}
|
||||
else {
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
const difference_type __elems_after = difference_type(__length) - __elems_before;
|
||||
__pos = this->_M_finish - __elems_after;
|
||||
_STLP_TRY {
|
||||
iterator __dst = __new_finish;
|
||||
iterator __src = this->_M_finish;
|
||||
for (--__src, --__dst; __src >= __pos; --__src, --__dst) {
|
||||
_STLP_STD::_Move_Construct(&(*__dst), *__src);
|
||||
_STLP_STD::_Destroy_Moved(&(*__src));
|
||||
}
|
||||
this->_M_finish = __new_finish;
|
||||
uninitialized_fill(__pos, __pos + __n, __x_copy);
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
|
||||
}
|
||||
return __pos;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
__iterator__ deque<_Tp,_Alloc>::_M_fill_insert_aux(iterator __pos, size_type __n,
|
||||
const value_type& __x,
|
||||
const __false_type& /*_Movable*/) {
|
||||
const difference_type __elems_before = __pos - this->_M_start;
|
||||
size_type __length = this->size();
|
||||
value_type __x_copy = __x;
|
||||
if (__elems_before <= difference_type(__length / 2)) {
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
iterator __old_start = this->_M_start;
|
||||
__pos = this->_M_start + __elems_before;
|
||||
_STLP_TRY {
|
||||
if (__elems_before >= difference_type(__n)) {
|
||||
iterator __start_n = this->_M_start + difference_type(__n);
|
||||
_STLP_PRIV __ucopy(this->_M_start, __start_n, __new_start);
|
||||
this->_M_start = __new_start;
|
||||
_STLP_STD::copy(__start_n, __pos, __old_start);
|
||||
_STLP_STD::fill(__pos - difference_type(__n), __pos, __x_copy);
|
||||
__pos -= difference_type(__n);
|
||||
}
|
||||
else {
|
||||
_STLP_PRIV __uninitialized_copy_fill(this->_M_start, __pos, __new_start,
|
||||
this->_M_start, __x_copy);
|
||||
this->_M_start = __new_start;
|
||||
fill(__old_start, __pos, __x_copy);
|
||||
}
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
|
||||
}
|
||||
else {
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
iterator __old_finish = this->_M_finish;
|
||||
const difference_type __elems_after =
|
||||
difference_type(__length) - __elems_before;
|
||||
__pos = this->_M_finish - __elems_after;
|
||||
_STLP_TRY {
|
||||
if (__elems_after > difference_type(__n)) {
|
||||
iterator __finish_n = this->_M_finish - difference_type(__n);
|
||||
_STLP_PRIV __ucopy(__finish_n, this->_M_finish, this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
copy_backward(__pos, __finish_n, __old_finish);
|
||||
fill(__pos, __pos + difference_type(__n), __x_copy);
|
||||
}
|
||||
else {
|
||||
_STLP_PRIV __uninitialized_fill_copy(this->_M_finish, __pos + difference_type(__n),
|
||||
__x_copy, __pos, this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
fill(__pos, __old_finish, __x_copy);
|
||||
}
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
|
||||
}
|
||||
return __pos;
|
||||
}
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::_M_insert_range_aux(iterator __pos,
|
||||
const value_type* __first, const value_type* __last,
|
||||
size_type __n, const __true_type& /*_Movable*/) {
|
||||
const difference_type __elems_before = __pos - this->_M_start;
|
||||
size_type __length = size();
|
||||
if (__elems_before <= difference_type(__length / 2)) {
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
__pos = this->_M_start + __elems_before;
|
||||
_STLP_TRY {
|
||||
iterator __dst = __new_start;
|
||||
iterator __src = this->_M_start;
|
||||
for (; __src != __pos; ++__dst, ++__src) {
|
||||
_STLP_STD::_Move_Construct(&(*__dst), *__src);
|
||||
_STLP_STD::_Destroy_Moved(&(*__src));
|
||||
}
|
||||
this->_M_start = __new_start;
|
||||
_STLP_PRIV __ucopy(__first, __last, __dst);
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
|
||||
}
|
||||
else {
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
const difference_type __elems_after = difference_type(__length) - __elems_before;
|
||||
__pos = this->_M_finish - __elems_after;
|
||||
_STLP_TRY {
|
||||
iterator __dst = __new_finish;
|
||||
iterator __src = this->_M_finish;
|
||||
for (--__src, --__dst; __src >= __pos; --__src, --__dst) {
|
||||
_STLP_STD::_Move_Construct(&(*__dst), *__src);
|
||||
_STLP_STD::_Destroy_Moved(&(*__src));
|
||||
}
|
||||
this->_M_finish = __new_finish;
|
||||
_STLP_PRIV __ucopy(__first, __last, __pos);
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::_M_insert_range_aux(iterator __pos,
|
||||
const value_type* __first, const value_type* __last,
|
||||
size_type __n, const __false_type& /*_Movable*/) {
|
||||
const difference_type __elems_before = __pos - this->_M_start;
|
||||
size_type __length = size();
|
||||
if (__elems_before <= difference_type(__length / 2)) {
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
iterator __old_start = this->_M_start;
|
||||
__pos = this->_M_start + __elems_before;
|
||||
_STLP_TRY {
|
||||
if (__elems_before >= difference_type(__n)) {
|
||||
iterator __start_n = this->_M_start + difference_type(__n);
|
||||
_STLP_PRIV __ucopy(this->_M_start, __start_n, __new_start);
|
||||
this->_M_start = __new_start;
|
||||
_STLP_STD::copy(__start_n, __pos, __old_start);
|
||||
_STLP_STD::copy(__first, __last, __pos - difference_type(__n));
|
||||
}
|
||||
else {
|
||||
const value_type* __mid = __first + (difference_type(__n) - __elems_before);
|
||||
_STLP_PRIV __uninitialized_copy_copy(this->_M_start, __pos, __first, __mid, __new_start);
|
||||
this->_M_start = __new_start;
|
||||
_STLP_STD::copy(__mid, __last, __old_start);
|
||||
}
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
|
||||
}
|
||||
else {
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
iterator __old_finish = this->_M_finish;
|
||||
const difference_type __elems_after =
|
||||
difference_type(__length) - __elems_before;
|
||||
__pos = this->_M_finish - __elems_after;
|
||||
_STLP_TRY {
|
||||
|
||||
if (__elems_after > difference_type(__n)) {
|
||||
iterator __finish_n = this->_M_finish - difference_type(__n);
|
||||
_STLP_PRIV __ucopy(__finish_n, this->_M_finish, this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
_STLP_STD::copy_backward(__pos, __finish_n, __old_finish);
|
||||
_STLP_STD::copy(__first, __last, __pos);
|
||||
}
|
||||
else {
|
||||
const value_type* __mid = __first + __elems_after;
|
||||
_STLP_PRIV __uninitialized_copy_copy(__mid, __last, __pos, this->_M_finish, this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
_STLP_STD::copy(__first, __mid, __pos);
|
||||
}
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::_M_insert_range_aux(iterator __pos,
|
||||
const_iterator __first, const_iterator __last,
|
||||
size_type __n, const __true_type& /*_Movable*/) {
|
||||
const difference_type __elems_before = __pos - this->_M_start;
|
||||
size_type __length = size();
|
||||
if (__elems_before <= difference_type(__length / 2)) {
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
__pos = this->_M_start + __elems_before;
|
||||
_STLP_TRY {
|
||||
iterator __dst = __new_start;
|
||||
iterator __src = this->_M_start;
|
||||
for (; __src != __pos; ++__dst, ++__src) {
|
||||
_STLP_STD::_Move_Construct(&(*__dst), *__src);
|
||||
_STLP_STD::_Destroy_Moved(&(*__src));
|
||||
}
|
||||
this->_M_start = __new_start;
|
||||
_STLP_PRIV __ucopy(__first, __last, __dst);
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
|
||||
}
|
||||
else {
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
const difference_type __elems_after = difference_type(__length) - __elems_before;
|
||||
__pos = this->_M_finish - __elems_after;
|
||||
_STLP_TRY {
|
||||
iterator __dst = __new_finish;
|
||||
iterator __src = this->_M_finish;
|
||||
for (--__src, --__dst; __src >= __pos; --__src, --__dst) {
|
||||
_STLP_STD::_Move_Construct(&(*__dst), *__src);
|
||||
_STLP_STD::_Destroy_Moved(&(*__src));
|
||||
}
|
||||
this->_M_finish = __new_finish;
|
||||
_STLP_PRIV __ucopy(__first, __last, __pos);
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::_M_insert_range_aux(iterator __pos,
|
||||
const_iterator __first, const_iterator __last,
|
||||
size_type __n, const __false_type& /*_Movable*/) {
|
||||
const difference_type __elems_before = __pos - this->_M_start;
|
||||
size_type __length = size();
|
||||
if (__elems_before < difference_type(__length / 2)) {
|
||||
iterator __new_start = _M_reserve_elements_at_front(__n);
|
||||
iterator __old_start = this->_M_start;
|
||||
__pos = this->_M_start + __elems_before;
|
||||
_STLP_TRY {
|
||||
if (__elems_before >= difference_type(__n)) {
|
||||
iterator __start_n = this->_M_start + __n;
|
||||
_STLP_PRIV __ucopy(this->_M_start, __start_n, __new_start);
|
||||
this->_M_start = __new_start;
|
||||
_STLP_STD::copy(__start_n, __pos, __old_start);
|
||||
_STLP_STD::copy(__first, __last, __pos - difference_type(__n));
|
||||
}
|
||||
else {
|
||||
const_iterator __mid = __first + (__n - __elems_before);
|
||||
_STLP_PRIV __uninitialized_copy_copy(this->_M_start, __pos, __first, __mid, __new_start);
|
||||
this->_M_start = __new_start;
|
||||
_STLP_STD::copy(__mid, __last, __old_start);
|
||||
}
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
|
||||
}
|
||||
else {
|
||||
iterator __new_finish = _M_reserve_elements_at_back(__n);
|
||||
iterator __old_finish = this->_M_finish;
|
||||
const difference_type __elems_after = __length - __elems_before;
|
||||
__pos = this->_M_finish - __elems_after;
|
||||
_STLP_TRY {
|
||||
if (__elems_after > difference_type(__n)) {
|
||||
iterator __finish_n = this->_M_finish - difference_type(__n);
|
||||
_STLP_PRIV __ucopy(__finish_n, this->_M_finish, this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
_STLP_STD::copy_backward(__pos, __finish_n, __old_finish);
|
||||
_STLP_STD::copy(__first, __last, __pos);
|
||||
}
|
||||
else {
|
||||
const_iterator __mid = __first + __elems_after;
|
||||
_STLP_PRIV __uninitialized_copy_copy(__mid, __last, __pos, this->_M_finish, this->_M_finish);
|
||||
this->_M_finish = __new_finish;
|
||||
_STLP_STD::copy(__first, __mid, __pos);
|
||||
}
|
||||
}
|
||||
_STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
|
||||
}
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::_M_new_elements_at_front(size_type __new_elems) {
|
||||
size_type __new_nodes
|
||||
= (__new_elems + this->buffer_size() - 1) / this->buffer_size();
|
||||
_M_reserve_map_at_front(__new_nodes);
|
||||
size_type __i = 1;
|
||||
_STLP_TRY {
|
||||
for (; __i <= __new_nodes; ++__i)
|
||||
*(this->_M_start._M_node - __i) = this->_M_map_size.allocate(this->buffer_size());
|
||||
}
|
||||
_STLP_UNWIND(for (size_type __j = 1; __j < __i; ++__j)
|
||||
this->_M_map_size.deallocate(*(this->_M_start._M_node - __j), this->buffer_size()))
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::_M_new_elements_at_back(size_type __new_elems) {
|
||||
size_type __new_nodes
|
||||
= (__new_elems + this->buffer_size() - 1) / this->buffer_size();
|
||||
_M_reserve_map_at_back(__new_nodes);
|
||||
size_type __i = 1;
|
||||
_STLP_TRY {
|
||||
for (; __i <= __new_nodes; ++__i)
|
||||
*(this->_M_finish._M_node + __i) = this->_M_map_size.allocate(this->buffer_size());
|
||||
}
|
||||
_STLP_UNWIND(for (size_type __j = 1; __j < __i; ++__j)
|
||||
this->_M_map_size.deallocate(*(this->_M_finish._M_node + __j), this->buffer_size()))
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc >
|
||||
void deque<_Tp,_Alloc>::_M_reallocate_map(size_type __nodes_to_add,
|
||||
bool __add_at_front) {
|
||||
size_type __old_num_nodes = this->_M_finish._M_node - this->_M_start._M_node + 1;
|
||||
size_type __new_num_nodes = __old_num_nodes + __nodes_to_add;
|
||||
|
||||
_Map_pointer __new_nstart;
|
||||
if (this->_M_map_size._M_data > 2 * __new_num_nodes) {
|
||||
__new_nstart = this->_M_map._M_data + (this->_M_map_size._M_data - __new_num_nodes) / 2
|
||||
+ (__add_at_front ? __nodes_to_add : 0);
|
||||
if (__new_nstart < this->_M_start._M_node)
|
||||
_STLP_STD::copy(this->_M_start._M_node, this->_M_finish._M_node + 1, __new_nstart);
|
||||
else
|
||||
_STLP_STD::copy_backward(this->_M_start._M_node, this->_M_finish._M_node + 1,
|
||||
__new_nstart + __old_num_nodes);
|
||||
}
|
||||
else {
|
||||
size_type __new_map_size =
|
||||
this->_M_map_size._M_data + (max)((size_t)this->_M_map_size._M_data, __nodes_to_add) + 2;
|
||||
|
||||
_Map_pointer __new_map = this->_M_map.allocate(__new_map_size);
|
||||
__new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2
|
||||
+ (__add_at_front ? __nodes_to_add : 0);
|
||||
_STLP_STD::copy(this->_M_start._M_node, this->_M_finish._M_node + 1, __new_nstart);
|
||||
this->_M_map.deallocate(this->_M_map._M_data, this->_M_map_size._M_data);
|
||||
|
||||
this->_M_map._M_data = __new_map;
|
||||
this->_M_map_size._M_data = __new_map_size;
|
||||
}
|
||||
|
||||
this->_M_start._M_set_node(__new_nstart);
|
||||
this->_M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
|
||||
}
|
||||
|
||||
#if defined (deque)
|
||||
# undef deque
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#undef __iterator__
|
||||
#undef iterator
|
||||
#undef const_iterator
|
||||
#undef size_type
|
||||
#undef value_type
|
||||
|
||||
#endif /* _STLP_DEQUE_C */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
1115
extern/STLport/5.2.1/stlport/stl/_deque.h
vendored
Normal file
1115
extern/STLport/5.2.1/stlport/stl/_deque.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
42
extern/STLport/5.2.1/stlport/stl/_epilog.h
vendored
Normal file
42
extern/STLport/5.2.1/stlport/stl/_epilog.h
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/* NOTE : this header has no guards and is MEANT for multiple inclusion!
|
||||
* If you are using "header protection" option with your compiler,
|
||||
* please also find #pragma which disables it and put it here, to
|
||||
* allow reentrancy of this header.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_PROLOG_HEADER_INCLUDED
|
||||
# error STLport epilog header can not be included as long as prolog has not be included.
|
||||
#endif
|
||||
|
||||
/* If the platform provides any specific epilog actions,
|
||||
* like #pragmas, do include platform-specific prolog file
|
||||
*/
|
||||
#if defined (_STLP_HAS_SPECIFIC_PROLOG_EPILOG)
|
||||
# include <stl/config/_epilog.h>
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_NO_POST_COMPATIBLE_SECTION)
|
||||
# include <stl/_config_compat_post.h>
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_USE_OWN_NAMESPACE)
|
||||
|
||||
# if !defined (_STLP_DONT_REDEFINE_STD)
|
||||
/* We redefine "std" to STLPORT, so that user code may use std:: transparently
|
||||
* The STLPORT macro contains the STLport namespace name containing all the std
|
||||
* stuff.
|
||||
*/
|
||||
# if defined (std)
|
||||
/*
|
||||
* Looks like the compiler native library on which STLport rely defined the std macro.
|
||||
* This might introduce major incompatibility so report the problem to the STLport
|
||||
* forum or comment the following #error at your own risk.
|
||||
*/
|
||||
# error Incompatible native Std library.
|
||||
# endif /* std */
|
||||
# define std STLPORT
|
||||
# endif /* _STLP_DONT_REDEFINE_STD */
|
||||
|
||||
#endif
|
||||
|
||||
#undef _STLP_PROLOG_HEADER_INCLUDED /* defined in _prolog.h */
|
||||
193
extern/STLport/5.2.1/stlport/stl/_exception.h
vendored
Normal file
193
extern/STLport/5.2.1/stlport/stl/_exception.h
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
|
||||
// The header <exception> contains low-level functions that interact
|
||||
// with a compiler's exception-handling mechanism. It is assumed to
|
||||
// be supplied with the compiler, rather than with the library, because
|
||||
// it is inherently tied very closely to the compiler itself.
|
||||
|
||||
// On platforms where <exception> does not exist, this header defines
|
||||
// an exception base class. This is *not* a substitute for everything
|
||||
// in <exception>, but it suffices to support a bare minimum of STL
|
||||
// functionality.
|
||||
|
||||
#ifndef _STLP_INTERNAL_EXCEPTION
|
||||
#define _STLP_INTERNAL_EXCEPTION
|
||||
|
||||
#if !defined (_STLP_NO_EXCEPTION_HEADER)
|
||||
|
||||
# if defined ( _UNCAUGHT_EXCEPTION )
|
||||
# undef _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_BROKEN_EXCEPTION_CLASS)
|
||||
# define exception _STLP_NULLIFIED_BROKEN_EXCEPTION_CLASS
|
||||
# define bad_exception _STLP_NULLIFIED_BROKEN_BAD_EXCEPTION_CLASS
|
||||
# if defined (_STLP_NO_NEW_NEW_HEADER)
|
||||
# include _STLP_NATIVE_CPP_RUNTIME_HEADER(Exception.h)
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_RUNTIME_HEADER(Exception)
|
||||
# endif
|
||||
# undef exception
|
||||
# undef bad_exception
|
||||
# else
|
||||
# if defined (_STLP_NO_NEW_NEW_HEADER)
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <exception.h>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception.h)
|
||||
# endif
|
||||
# else
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <exception>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_RUNTIME_HEADER(exception)
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_HAS_SPECIFIC_PROLOG_EPILOG) && defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB < 1300)
|
||||
// dwa 02/04/00
|
||||
// The header <yvals.h> which ships with vc6 and is included by its native <exception>
|
||||
// actually turns on warnings, so we have to turn them back off.
|
||||
# include <stl/config/_warnings_off.h>
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_USE_OWN_NAMESPACE)
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
# if !defined (_STLP_BROKEN_EXCEPTION_CLASS)
|
||||
# if !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_WIN64)
|
||||
using _STLP_VENDOR_EXCEPT_STD::exception;
|
||||
# else
|
||||
using ::exception;
|
||||
# endif
|
||||
using _STLP_VENDOR_EXCEPT_STD::bad_exception;
|
||||
# endif
|
||||
|
||||
# if !defined (_STLP_NO_USING_FOR_GLOBAL_FUNCTIONS)
|
||||
// fbp : many platforms present strange mix of
|
||||
// those in various namespaces
|
||||
# if !defined (_STLP_VENDOR_UNEXPECTED_STD)
|
||||
# define _STLP_VENDOR_UNEXPECTED_STD _STLP_VENDOR_EXCEPT_STD
|
||||
# else
|
||||
/* The following definitions are for backward compatibility as _STLP_VENDOR_TERMINATE_STD
|
||||
* and _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD has been introduce after _STLP_VENDOR_UNEXPECTED_STD
|
||||
* and _STLP_VENDOR_UNEXPECTED_STD was the macro used in their place before that introduction.
|
||||
*/
|
||||
# if !defined (_STLP_VENDOR_TERMINATE_STD)
|
||||
# define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_UNEXPECTED_STD
|
||||
# endif
|
||||
# if !defined (_STLP_VENDOR_UNCAUGHT_EXCEPTION_STD)
|
||||
# define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_UNEXPECTED_STD
|
||||
# endif
|
||||
# endif
|
||||
# if !defined (_STLP_VENDOR_TERMINATE_STD)
|
||||
# define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_EXCEPT_STD
|
||||
# endif
|
||||
# if !defined (_STLP_VENDOR_UNCAUGHT_EXCEPTION_STD)
|
||||
# define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_EXCEPT_STD
|
||||
# endif
|
||||
# if !defined (_STLP_VENDOR_TERMINATE_STD)
|
||||
# define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_EXCEPT_STD
|
||||
# endif
|
||||
# if !defined (_STLP_VENDOR_UNCAUGHT_EXCEPTION_STD)
|
||||
# define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_EXCEPT_STD
|
||||
# endif
|
||||
// weird errors
|
||||
# if !defined (_STLP_NO_UNEXPECTED_EXCEPT_SUPPORT)
|
||||
# if defined (__ICL) && (__ICL >= 900) && (_STLP_MSVC_LIB < 1300)
|
||||
//See config/_intel.h for reason about this workaround
|
||||
using std::unexpected;
|
||||
# else
|
||||
using _STLP_VENDOR_UNEXPECTED_STD::unexpected;
|
||||
# endif
|
||||
using _STLP_VENDOR_UNEXPECTED_STD::unexpected_handler;
|
||||
using _STLP_VENDOR_UNEXPECTED_STD::set_unexpected;
|
||||
# endif
|
||||
using _STLP_VENDOR_TERMINATE_STD::terminate;
|
||||
using _STLP_VENDOR_TERMINATE_STD::terminate_handler;
|
||||
using _STLP_VENDOR_TERMINATE_STD::set_terminate;
|
||||
|
||||
# if !defined (_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT)
|
||||
using _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD::uncaught_exception;
|
||||
# endif
|
||||
# endif /* !_STLP_NO_USING_FOR_GLOBAL_FUNCTIONS */
|
||||
_STLP_END_NAMESPACE
|
||||
# endif /* _STLP_OWN_NAMESPACE */
|
||||
#else /* _STLP_NO_EXCEPTION_HEADER */
|
||||
|
||||
/* fbp : absence of <exception> usually means that those
|
||||
* functions are not going to be called by compiler.
|
||||
* Still, define them for the user.
|
||||
* dums: Policy modification, if the function do not behave like the Standard
|
||||
* defined it we do not grant it in the STLport namespace. We will have
|
||||
* compile time error rather than runtime error.
|
||||
*/
|
||||
#if 0
|
||||
/*
|
||||
typedef void (*unexpected_handler)();
|
||||
unexpected_handler set_unexpected(unexpected_handler f) _STLP_NOTHROW_INHERENTLY;
|
||||
void unexpected();
|
||||
|
||||
typedef void (*terminate_handler)();
|
||||
terminate_handler set_terminate(terminate_handler f) _STLP_NOTHROW_INHERENTLY;
|
||||
void terminate();
|
||||
|
||||
bool uncaught_exception(); // not implemented under mpw as of Jan/1999
|
||||
*/
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_NO_EXCEPTION_HEADER */
|
||||
|
||||
#if defined (_STLP_NO_EXCEPTION_HEADER) || defined (_STLP_BROKEN_EXCEPTION_CLASS)
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
// section 18.6.1
|
||||
class _STLP_CLASS_DECLSPEC exception {
|
||||
public:
|
||||
# ifndef _STLP_USE_NO_IOSTREAMS
|
||||
exception() _STLP_NOTHROW;
|
||||
virtual ~exception() _STLP_NOTHROW;
|
||||
virtual const char* what() const _STLP_NOTHROW;
|
||||
# else
|
||||
exception() _STLP_NOTHROW {}
|
||||
virtual ~exception() _STLP_NOTHROW {}
|
||||
virtual const char* what() const _STLP_NOTHROW {return "class exception";}
|
||||
# endif
|
||||
};
|
||||
|
||||
// section 18.6.2.1
|
||||
class _STLP_CLASS_DECLSPEC bad_exception : public exception {
|
||||
public:
|
||||
# ifndef _STLP_USE_NO_IOSTREAMS
|
||||
bad_exception() _STLP_NOTHROW;
|
||||
~bad_exception() _STLP_NOTHROW;
|
||||
const char* what() const _STLP_NOTHROW;
|
||||
# else
|
||||
bad_exception() _STLP_NOTHROW {}
|
||||
~bad_exception() _STLP_NOTHROW {}
|
||||
const char* what() const _STLP_NOTHROW {return "class bad_exception";}
|
||||
# endif
|
||||
};
|
||||
|
||||
// forward declaration
|
||||
class __Named_exception;
|
||||
_STLP_END_NAMESPACE
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_EXCEPTION */
|
||||
53
extern/STLport/5.2.1/stlport/stl/_facets_fwd.h
vendored
Normal file
53
extern/STLport/5.2.1/stlport/stl/_facets_fwd.h
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef _STLP_FACETS_FWD_H
|
||||
#define _STLP_FACETS_FWD_H
|
||||
|
||||
|
||||
#include <stl/_iosfwd.h>
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
|
||||
template <class _CharT, class _InputIter>
|
||||
#else
|
||||
template <class _CharT, class _InputIter = istreambuf_iterator<_CharT, char_traits<_CharT> > >
|
||||
#endif
|
||||
class money_get;
|
||||
|
||||
#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
|
||||
template <class _CharT, class _OutputIter>
|
||||
#else
|
||||
template <class _CharT, class _OutputIter = ostreambuf_iterator<_CharT, char_traits<_CharT> > >
|
||||
#endif
|
||||
class money_put;
|
||||
|
||||
#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
|
||||
template <class _CharT, class _InputIter>
|
||||
#else
|
||||
template <class _CharT, class _InputIter = istreambuf_iterator<_CharT, char_traits<_CharT> > >
|
||||
#endif
|
||||
class num_get;
|
||||
|
||||
#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
|
||||
template <class _CharT, class _OutputIter>
|
||||
#else
|
||||
template <class _CharT, class _OutputIter = ostreambuf_iterator<_CharT, char_traits<_CharT> > >
|
||||
#endif
|
||||
class num_put;
|
||||
|
||||
#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
|
||||
template <class _Ch, class _InIt>
|
||||
#else
|
||||
template <class _Ch, class _InIt = istreambuf_iterator<_Ch, char_traits<_Ch> > >
|
||||
#endif
|
||||
class time_get;
|
||||
|
||||
#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES)
|
||||
template <class _Ch, class _OutIt>
|
||||
#else
|
||||
template <class _Ch, class _OutIt = ostreambuf_iterator<_Ch, char_traits<_Ch> > >
|
||||
#endif
|
||||
class time_put;
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
766
extern/STLport/5.2.1/stlport/stl/_fstream.c
vendored
Normal file
766
extern/STLport/5.2.1/stlport/stl/_fstream.c
vendored
Normal file
@@ -0,0 +1,766 @@
|
||||
/*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_FSTREAM_C
|
||||
#define _STLP_FSTREAM_C
|
||||
|
||||
#ifndef _STLP_INTERNAL_FSTREAM_H
|
||||
# include <stl/_fstream.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_LIMITS
|
||||
# include <stl/_limits.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
# if defined ( _STLP_NESTED_TYPE_PARAM_BUG )
|
||||
// no wchar_t is supported for this mode
|
||||
# define __BF_int_type__ int
|
||||
# define __BF_pos_type__ streampos
|
||||
# define __BF_off_type__ streamoff
|
||||
# else
|
||||
# define __BF_int_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_filebuf<_CharT, _Traits>::int_type
|
||||
# define __BF_pos_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_filebuf<_CharT, _Traits>::pos_type
|
||||
# define __BF_off_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_filebuf<_CharT, _Traits>::off_type
|
||||
# endif
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Public basic_filebuf<> member functions
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_filebuf<_CharT, _Traits>::basic_filebuf()
|
||||
: basic_streambuf<_CharT, _Traits>(), _M_base(),
|
||||
_M_constant_width(false), _M_always_noconv(false),
|
||||
_M_int_buf_dynamic(false),
|
||||
_M_in_input_mode(false), _M_in_output_mode(false),
|
||||
_M_in_error_mode(false), _M_in_putback_mode(false),
|
||||
_M_int_buf(0), _M_int_buf_EOS(0),
|
||||
_M_ext_buf(0), _M_ext_buf_EOS(0),
|
||||
_M_ext_buf_converted(0), _M_ext_buf_end(0),
|
||||
_M_state(_STLP_DEFAULT_CONSTRUCTED(_State_type)),
|
||||
_M_end_state(_STLP_DEFAULT_CONSTRUCTED(_State_type)),
|
||||
_M_mmap_base(0), _M_mmap_len(0),
|
||||
_M_saved_eback(0), _M_saved_gptr(0), _M_saved_egptr(0),
|
||||
_M_codecvt(0),
|
||||
_M_width(1), _M_max_width(1)
|
||||
{
|
||||
this->_M_setup_codecvt(locale(), false);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_filebuf<_CharT, _Traits>::~basic_filebuf() {
|
||||
this->close();
|
||||
_M_deallocate_buffers();
|
||||
}
|
||||
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
_STLP_TYPENAME_ON_RETURN_TYPE basic_filebuf<_CharT, _Traits>::int_type
|
||||
basic_filebuf<_CharT, _Traits>::underflow() {
|
||||
return _Underflow<_CharT, _Traits>::_M_doit(this);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_filebuf<_CharT, _Traits>*
|
||||
basic_filebuf<_CharT, _Traits>::close() {
|
||||
bool __ok = this->is_open();
|
||||
|
||||
if (_M_in_output_mode) {
|
||||
__ok = __ok && !_Traits::eq_int_type(this->overflow(traits_type::eof()),
|
||||
traits_type::eof());
|
||||
__ok == __ok && this->_M_unshift();
|
||||
}
|
||||
else if (_M_in_input_mode)
|
||||
this->_M_exit_input_mode();
|
||||
|
||||
// Note order of arguments. We close the file even if __ok is false.
|
||||
__ok = _M_base._M_close() && __ok;
|
||||
|
||||
// Restore the initial state, except that we don't deallocate the buffer
|
||||
// or mess with the cached codecvt information.
|
||||
_M_state = _M_end_state = _State_type();
|
||||
_M_ext_buf_converted = _M_ext_buf_end = 0;
|
||||
|
||||
_M_mmap_base = 0;
|
||||
_M_mmap_len = 0;
|
||||
|
||||
this->setg(0, 0, 0);
|
||||
this->setp(0, 0);
|
||||
|
||||
_M_saved_eback = _M_saved_gptr = _M_saved_egptr = 0;
|
||||
|
||||
_M_in_input_mode = _M_in_output_mode = _M_in_error_mode = _M_in_putback_mode
|
||||
= false;
|
||||
|
||||
return __ok ? this : 0;
|
||||
}
|
||||
|
||||
// This member function is called whenever we exit input mode.
|
||||
// It unmaps the memory-mapped file, if any, and sets
|
||||
// _M_in_input_mode to false.
|
||||
template <class _CharT, class _Traits>
|
||||
void basic_filebuf<_CharT, _Traits>::_M_exit_input_mode() {
|
||||
if (_M_mmap_base != 0) {
|
||||
_M_base._M_unmap(_M_mmap_base, _M_mmap_len);
|
||||
_M_mmap_base = 0;
|
||||
_M_mmap_len = 0;
|
||||
}
|
||||
_M_in_input_mode = false;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// basic_filebuf<> overridden protected virtual member functions
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
streamsize basic_filebuf<_CharT, _Traits>::showmanyc() {
|
||||
// Is there any possibility that reads can succeed?
|
||||
if (!this->is_open() || _M_in_output_mode || _M_in_error_mode)
|
||||
return -1;
|
||||
else if (_M_in_putback_mode)
|
||||
return this->egptr() - this->gptr();
|
||||
else if (_M_constant_width) {
|
||||
streamoff __pos = _M_base._M_seek(0, ios_base::cur);
|
||||
streamoff __size = _M_base._M_file_size();
|
||||
return __pos >= 0 && __size > __pos ? __size - __pos : 0;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Make a putback position available, if necessary, by switching to a
|
||||
// special internal buffer used only for putback. The buffer is
|
||||
// [_M_pback_buf, _M_pback_buf + _S_pback_buf_size), but the base
|
||||
// class only sees a piece of it at a time. (We want to make sure
|
||||
// that we don't try to read a character that hasn't been initialized.)
|
||||
// The end of the putback buffer is always _M_pback_buf + _S_pback_buf_size,
|
||||
// but the beginning is usually not _M_pback_buf.
|
||||
template <class _CharT, class _Traits>
|
||||
__BF_int_type__
|
||||
basic_filebuf<_CharT, _Traits>::pbackfail(int_type __c) {
|
||||
const int_type __eof = traits_type::eof();
|
||||
|
||||
// If we aren't already in input mode, pushback is impossible.
|
||||
if (!_M_in_input_mode)
|
||||
return __eof;
|
||||
|
||||
// We can use the ordinary get buffer if there's enough space, and
|
||||
// if it's a buffer that we're allowed to write to.
|
||||
if (this->gptr() != this->eback() &&
|
||||
(traits_type::eq_int_type(__c, __eof) ||
|
||||
traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]) ||
|
||||
!_M_mmap_base)) {
|
||||
this->gbump(-1);
|
||||
if (traits_type::eq_int_type(__c, __eof) ||
|
||||
traits_type::eq(traits_type::to_char_type(__c), *this->gptr()))
|
||||
return traits_type::to_int_type(*this->gptr());
|
||||
}
|
||||
else if (!traits_type::eq_int_type(__c, __eof)) {
|
||||
// Are we in the putback buffer already?
|
||||
_CharT* __pback_end = _M_pback_buf + __STATIC_CAST(int,_S_pback_buf_size);
|
||||
if (_M_in_putback_mode) {
|
||||
// Do we have more room in the putback buffer?
|
||||
if (this->eback() != _M_pback_buf)
|
||||
this->setg(this->egptr() - 1, this->egptr() - 1, __pback_end);
|
||||
else
|
||||
return __eof; // No more room in the buffer, so fail.
|
||||
}
|
||||
else { // We're not yet in the putback buffer.
|
||||
_M_saved_eback = this->eback();
|
||||
_M_saved_gptr = this->gptr();
|
||||
_M_saved_egptr = this->egptr();
|
||||
this->setg(__pback_end - 1, __pback_end - 1, __pback_end);
|
||||
_M_in_putback_mode = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
return __eof;
|
||||
|
||||
// We have made a putback position available. Assign to it, and return.
|
||||
*this->gptr() = traits_type::to_char_type(__c);
|
||||
return __c;
|
||||
}
|
||||
|
||||
// This member function flushes the put area, and also outputs the
|
||||
// character __c (unless __c is eof). Invariant: we always leave room
|
||||
// in the internal buffer for one character more than the base class knows
|
||||
// about. We see the internal buffer as [_M_int_buf, _M_int_buf_EOS), but
|
||||
// the base class only sees [_M_int_buf, _M_int_buf_EOS - 1).
|
||||
template <class _CharT, class _Traits>
|
||||
__BF_int_type__
|
||||
basic_filebuf<_CharT, _Traits>::overflow(int_type __c) {
|
||||
// Switch to output mode, if necessary.
|
||||
if (!_M_in_output_mode)
|
||||
if (!_M_switch_to_output_mode())
|
||||
return traits_type::eof();
|
||||
|
||||
_CharT* __ibegin = this->_M_int_buf;
|
||||
_CharT* __iend = this->pptr();
|
||||
this->setp(_M_int_buf, _M_int_buf_EOS - 1);
|
||||
|
||||
// Put __c at the end of the internal buffer.
|
||||
if (!traits_type::eq_int_type(__c, traits_type::eof()))
|
||||
*__iend++ = _Traits::to_char_type(__c);
|
||||
|
||||
// For variable-width encodings, output may take more than one pass.
|
||||
while (__ibegin != __iend) {
|
||||
const _CharT* __inext = __ibegin;
|
||||
char* __enext = _M_ext_buf;
|
||||
typename _Codecvt::result __status
|
||||
= _M_codecvt->out(_M_state, __ibegin, __iend, __inext,
|
||||
_M_ext_buf, _M_ext_buf_EOS, __enext);
|
||||
if (__status == _Codecvt::noconv) {
|
||||
return _Noconv_output<_Traits>::_M_doit(this, __ibegin, __iend)
|
||||
? traits_type::not_eof(__c)
|
||||
: _M_output_error();
|
||||
}
|
||||
|
||||
// For a constant-width encoding we know that the external buffer
|
||||
// is large enough, so failure to consume the entire internal buffer
|
||||
// or to produce the correct number of external characters, is an error.
|
||||
// For a variable-width encoding, however, we require only that we
|
||||
// consume at least one internal character
|
||||
else if (__status != _Codecvt::error &&
|
||||
(((__inext == __iend) &&
|
||||
(__enext - _M_ext_buf == _M_width * (__iend - __ibegin))) ||
|
||||
(!_M_constant_width && __inext != __ibegin))) {
|
||||
// We successfully converted part or all of the internal buffer.
|
||||
ptrdiff_t __n = __enext - _M_ext_buf;
|
||||
if (_M_write(_M_ext_buf, __n))
|
||||
__ibegin += __inext - __ibegin;
|
||||
else
|
||||
return _M_output_error();
|
||||
}
|
||||
else
|
||||
return _M_output_error();
|
||||
}
|
||||
|
||||
return traits_type::not_eof(__c);
|
||||
}
|
||||
|
||||
// This member function must be called before any I/O has been
|
||||
// performed on the stream, otherwise it has no effect.
|
||||
//
|
||||
// __buf == 0 && __n == 0 means to make this stream unbuffered.
|
||||
// __buf != 0 && __n > 0 means to use __buf as the stream's internal
|
||||
// buffer, rather than the buffer that would otherwise be allocated
|
||||
// automatically. __buf must be a pointer to an array of _CharT whose
|
||||
// size is at least __n.
|
||||
template <class _CharT, class _Traits>
|
||||
basic_streambuf<_CharT, _Traits>*
|
||||
basic_filebuf<_CharT, _Traits>::setbuf(_CharT* __buf, streamsize __n) {
|
||||
if (!_M_in_input_mode &&! _M_in_output_mode && !_M_in_error_mode &&
|
||||
_M_int_buf == 0) {
|
||||
if (__buf == 0 && __n == 0)
|
||||
_M_allocate_buffers(0, 1);
|
||||
else if (__buf != 0 && __n > 0)
|
||||
_M_allocate_buffers(__buf, __n);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
#if defined (_STLP_ASSERTIONS)
|
||||
// helper class.
|
||||
template <class _CharT>
|
||||
struct _Filebuf_Tmp_Buf {
|
||||
_CharT* _M_ptr;
|
||||
_Filebuf_Tmp_Buf(ptrdiff_t __n) : _M_ptr(0) { _M_ptr = new _CharT[__n]; }
|
||||
~_Filebuf_Tmp_Buf() { delete[] _M_ptr; }
|
||||
};
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
__BF_pos_type__
|
||||
basic_filebuf<_CharT, _Traits>::seekoff(off_type __off,
|
||||
ios_base::seekdir __whence,
|
||||
ios_base::openmode /* dummy */) {
|
||||
if (!this->is_open())
|
||||
return pos_type(-1);
|
||||
|
||||
if (!_M_constant_width && __off != 0)
|
||||
return pos_type(-1);
|
||||
|
||||
if (!_M_seek_init(__off != 0 || __whence != ios_base::cur))
|
||||
return pos_type(-1);
|
||||
|
||||
// Seek to beginning or end, regardless of whether we're in input mode.
|
||||
if (__whence == ios_base::beg || __whence == ios_base::end)
|
||||
return _M_seek_return(_M_base._M_seek(_M_width * __off, __whence),
|
||||
_State_type());
|
||||
|
||||
// Seek relative to current position. Complicated if we're in input mode.
|
||||
_STLP_ASSERT(__whence == ios_base::cur)
|
||||
if (!_M_in_input_mode)
|
||||
return _M_seek_return(_M_base._M_seek(_M_width * __off, __whence),
|
||||
_State_type());
|
||||
|
||||
if (_M_mmap_base != 0) {
|
||||
// __off is relative to gptr(). We need to do a bit of arithmetic
|
||||
// to get an offset relative to the external file pointer.
|
||||
streamoff __adjust = _M_mmap_len - (this->gptr() - (_CharT*) _M_mmap_base);
|
||||
|
||||
// if __off == 0, we do not need to exit input mode and to shift file pointer
|
||||
return __off == 0 ? pos_type(_M_base._M_seek(0, ios_base::cur) - __adjust)
|
||||
: _M_seek_return(_M_base._M_seek(__off - __adjust, ios_base::cur), _State_type());
|
||||
}
|
||||
|
||||
if (_M_constant_width) { // Get or set the position.
|
||||
streamoff __iadj = _M_width * (this->gptr() - this->eback());
|
||||
|
||||
// Compensate for offset relative to gptr versus offset relative
|
||||
// to external pointer. For a text-oriented stream, where the
|
||||
// compensation is more than just pointer arithmetic, we may get
|
||||
// but not set the current position.
|
||||
|
||||
if (__iadj <= _M_ext_buf_end - _M_ext_buf) {
|
||||
streamoff __eadj = _M_base._M_get_offset(_M_ext_buf + __STATIC_CAST(ptrdiff_t, __iadj), _M_ext_buf_end);
|
||||
|
||||
return __off == 0 ? pos_type(_M_base._M_seek(0, ios_base::cur) - __eadj)
|
||||
: _M_seek_return(_M_base._M_seek(__off - __eadj, ios_base::cur), _State_type());
|
||||
}
|
||||
}
|
||||
else { // Get the position. Encoding is var width.
|
||||
// Get position in internal buffer.
|
||||
ptrdiff_t __ipos = this->gptr() - this->eback();
|
||||
|
||||
// Get corresponding position in external buffer.
|
||||
_State_type __state = _M_state;
|
||||
int __epos = _M_codecvt->length(__state, _M_ext_buf, _M_ext_buf_converted,
|
||||
__ipos);
|
||||
#if defined (_STLP_ASSERTIONS)
|
||||
// Sanity check (expensive): make sure __epos is the right answer.
|
||||
_STLP_ASSERT(__epos >= 0)
|
||||
_State_type __tmp_state = _M_state;
|
||||
_Filebuf_Tmp_Buf<_CharT> __buf(__ipos);
|
||||
_CharT* __ibegin = __buf._M_ptr;
|
||||
_CharT* __inext = __ibegin;
|
||||
const char* __dummy;
|
||||
typename _Codecvt::result __status
|
||||
= _M_codecvt->in(__tmp_state,
|
||||
_M_ext_buf, _M_ext_buf + __epos, __dummy,
|
||||
__ibegin, __ibegin + __ipos, __inext);
|
||||
// The result code is necessarily ok because:
|
||||
// - noconv: impossible for a variable encoding
|
||||
// - error: length method is supposed to count until it reach max value or find an error so we cannot have
|
||||
// an error again when decoding an external buffer up to length return value.
|
||||
// - partial: idem error, it is also a reason for length to stop counting.
|
||||
_STLP_ASSERT(__status == _Codecvt::ok)
|
||||
_STLP_ASSERT(__inext == __ibegin + __ipos)
|
||||
_STLP_ASSERT(equal(this->eback(), this->gptr(), __ibegin, _STLP_PRIV _Eq_traits<traits_type>()))
|
||||
#endif
|
||||
// Get the current position (at the end of the external buffer),
|
||||
// then adjust it. Again, it might be a text-oriented stream.
|
||||
streamoff __cur = _M_base._M_seek(0, ios_base::cur);
|
||||
streamoff __adj = _M_base._M_get_offset(_M_ext_buf, _M_ext_buf + __epos) -
|
||||
_M_base._M_get_offset(_M_ext_buf, _M_ext_buf_end);
|
||||
if (__cur != -1 && __cur + __adj >= 0)
|
||||
return __off == 0 ? pos_type(__cur + __adj)
|
||||
: _M_seek_return(__cur + __adj, __state);
|
||||
}
|
||||
|
||||
return pos_type(-1);
|
||||
}
|
||||
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
__BF_pos_type__
|
||||
basic_filebuf<_CharT, _Traits>::seekpos(pos_type __pos,
|
||||
ios_base::openmode /* dummy */) {
|
||||
if (this->is_open()) {
|
||||
if (!_M_seek_init(true))
|
||||
return pos_type(-1);
|
||||
|
||||
streamoff __off = off_type(__pos);
|
||||
if (__off != -1 && _M_base._M_seek(__off, ios_base::beg) != -1) {
|
||||
_M_state = __pos.state();
|
||||
return _M_seek_return(__off, __pos.state());
|
||||
}
|
||||
}
|
||||
|
||||
return pos_type(-1);
|
||||
}
|
||||
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
int basic_filebuf<_CharT, _Traits>::sync() {
|
||||
if (_M_in_output_mode)
|
||||
return traits_type::eq_int_type(this->overflow(traits_type::eof()),
|
||||
traits_type::eof()) ? -1 : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Change the filebuf's locale. This member function has no effect
|
||||
// unless it is called before any I/O is performed on the stream.
|
||||
template <class _CharT, class _Traits>
|
||||
void basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc) {
|
||||
if (!_M_in_input_mode && !_M_in_output_mode && !_M_in_error_mode) {
|
||||
this->_M_setup_codecvt(__loc);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// basic_filebuf<> helper functions.
|
||||
|
||||
//----------------------------------------
|
||||
// Helper functions for switching between modes.
|
||||
|
||||
// This member function is called if we're performing the first I/O
|
||||
// operation on a filebuf, or if we're performing an input operation
|
||||
// immediately after a seek.
|
||||
template <class _CharT, class _Traits>
|
||||
bool basic_filebuf<_CharT, _Traits>::_M_switch_to_input_mode() {
|
||||
if (this->is_open() && (((int)_M_base.__o_mode() & (int)ios_base::in) !=0)
|
||||
&& (_M_in_output_mode == 0) && (_M_in_error_mode == 0)) {
|
||||
if (!_M_int_buf && !_M_allocate_buffers())
|
||||
return false;
|
||||
|
||||
_M_ext_buf_converted = _M_ext_buf;
|
||||
_M_ext_buf_end = _M_ext_buf;
|
||||
|
||||
_M_end_state = _M_state;
|
||||
|
||||
_M_in_input_mode = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// This member function is called if we're performing the first I/O
|
||||
// operation on a filebuf, or if we're performing an output operation
|
||||
// immediately after a seek.
|
||||
template <class _CharT, class _Traits>
|
||||
bool basic_filebuf<_CharT, _Traits>::_M_switch_to_output_mode() {
|
||||
if (this->is_open() && (_M_base.__o_mode() & (int)ios_base::out) &&
|
||||
_M_in_input_mode == 0 && _M_in_error_mode == 0) {
|
||||
|
||||
if (!_M_int_buf && !_M_allocate_buffers())
|
||||
return false;
|
||||
|
||||
// In append mode, every write does an implicit seek to the end
|
||||
// of the file. Whenever leaving output mode, the end of file
|
||||
// get put in the initial shift state.
|
||||
if (_M_base.__o_mode() & ios_base::app)
|
||||
_M_state = _State_type();
|
||||
|
||||
this->setp(_M_int_buf, _M_int_buf_EOS - 1);
|
||||
_M_in_output_mode = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------
|
||||
// Helper functions for input
|
||||
|
||||
// This member function is called if there is an error during input.
|
||||
// It puts the filebuf in error mode, clear the get area buffer, and
|
||||
// returns eof.
|
||||
// returns eof. Error mode is sticky; it is cleared only by close or
|
||||
// seek.
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
__BF_int_type__
|
||||
basic_filebuf<_CharT, _Traits>::_M_input_error() {
|
||||
this->_M_exit_input_mode();
|
||||
_M_in_output_mode = false;
|
||||
_M_in_error_mode = true;
|
||||
this->setg(0, 0, 0);
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
__BF_int_type__
|
||||
basic_filebuf<_CharT, _Traits>::_M_underflow_aux() {
|
||||
// We have the state and file position from the end of the internal
|
||||
// buffer. This round, they become the beginning of the internal buffer.
|
||||
_M_state = _M_end_state;
|
||||
|
||||
// Fill the external buffer. Start with any leftover characters that
|
||||
// didn't get converted last time.
|
||||
if (_M_ext_buf_end > _M_ext_buf_converted)
|
||||
|
||||
_M_ext_buf_end = _STLP_STD::copy(_M_ext_buf_converted, _M_ext_buf_end, _M_ext_buf);
|
||||
// boris : copy_backward did not work
|
||||
//_M_ext_buf_end = copy_backward(_M_ext_buf_converted, _M_ext_buf_end,
|
||||
//_M_ext_buf+ (_M_ext_buf_end - _M_ext_buf_converted));
|
||||
else
|
||||
_M_ext_buf_end = _M_ext_buf;
|
||||
|
||||
// Now fill the external buffer with characters from the file. This is
|
||||
// a loop because occasionally we don't get enough external characters
|
||||
// to make progress.
|
||||
for (;;) {
|
||||
ptrdiff_t __n = _M_base._M_read(_M_ext_buf_end, _M_ext_buf_EOS - _M_ext_buf_end);
|
||||
if (__n < 0) {
|
||||
// Read failed, maybe we should set err bit on associated stream...
|
||||
this->setg(0, 0, 0);
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
_M_ext_buf_end += __n;
|
||||
|
||||
// If external buffer is empty there is nothing to do.
|
||||
if (_M_ext_buf == _M_ext_buf_end) {
|
||||
this->setg(0, 0, 0);
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
// Convert the external buffer to internal characters.
|
||||
const char* __enext;
|
||||
_CharT* __inext;
|
||||
|
||||
typename _Codecvt::result __status
|
||||
= _M_codecvt->in(_M_end_state,
|
||||
_M_ext_buf, _M_ext_buf_end, __enext,
|
||||
_M_int_buf, _M_int_buf_EOS, __inext);
|
||||
|
||||
/* Error conditions:
|
||||
* (1) Return value of error.
|
||||
* (2) Producing internal characters without consuming external characters.
|
||||
* (3) In fixed-width encodings, producing an internal sequence whose length
|
||||
* is inconsistent with that of the internal sequence.
|
||||
* (4) Failure to produce any characters if we have enough characters in
|
||||
* the external buffer, where "enough" means the largest possible width
|
||||
* of a single character. */
|
||||
if (__status == _Codecvt::noconv)
|
||||
return _Noconv_input<_Traits>::_M_doit(this);
|
||||
else if (__status == _Codecvt::error ||
|
||||
(__inext != _M_int_buf && __enext == _M_ext_buf) ||
|
||||
(_M_constant_width && (__inext - _M_int_buf) * _M_width != (__enext - _M_ext_buf)) ||
|
||||
(__inext == _M_int_buf && __enext - _M_ext_buf >= _M_max_width))
|
||||
return _M_input_error();
|
||||
else if (__inext != _M_int_buf) {
|
||||
_M_ext_buf_converted = _M_ext_buf + (__enext - _M_ext_buf);
|
||||
this->setg(_M_int_buf, _M_int_buf, __inext);
|
||||
return traits_type::to_int_type(*_M_int_buf);
|
||||
}
|
||||
/* We need to go around the loop again to get more external characters.
|
||||
* But if the previous read failed then don't try again for now.
|
||||
* Don't enter error mode for a failed read. Error mode is sticky,
|
||||
* and we might succeed if we try again. */
|
||||
if (__n <= 0) {
|
||||
this->setg(0, 0, 0);
|
||||
return traits_type::eof();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// Helper functions for output
|
||||
|
||||
// This member function is called if there is an error during output.
|
||||
// It puts the filebuf in error mode, clear the put area buffer, and
|
||||
// returns eof. Error mode is sticky; it is cleared only by close or
|
||||
// seek.
|
||||
template <class _CharT, class _Traits>
|
||||
__BF_int_type__
|
||||
basic_filebuf<_CharT, _Traits>::_M_output_error() {
|
||||
_M_in_output_mode = false;
|
||||
_M_in_input_mode = false;
|
||||
_M_in_error_mode = true;
|
||||
this->setp(0, 0);
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
|
||||
// Write whatever sequence of characters is necessary to get back to
|
||||
// the initial shift state. This function overwrites the external
|
||||
// buffer, changes the external file position, and changes the state.
|
||||
// Precondition: the internal buffer is empty.
|
||||
template <class _CharT, class _Traits>
|
||||
bool basic_filebuf<_CharT, _Traits>::_M_unshift() {
|
||||
if (_M_in_output_mode && !_M_constant_width) {
|
||||
typename _Codecvt::result __status;
|
||||
do {
|
||||
char* __enext = _M_ext_buf;
|
||||
__status = _M_codecvt->unshift(_M_state,
|
||||
_M_ext_buf, _M_ext_buf_EOS, __enext);
|
||||
if (__status == _Codecvt::noconv ||
|
||||
(__enext == _M_ext_buf && __status == _Codecvt::ok))
|
||||
return true;
|
||||
else if (__status == _Codecvt::error)
|
||||
return false;
|
||||
else if (!_M_write(_M_ext_buf, __enext - _M_ext_buf))
|
||||
return false;
|
||||
} while (__status == _Codecvt::partial);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------
|
||||
// Helper functions for buffer allocation and deallocation
|
||||
|
||||
// This member function is called when we're initializing a filebuf's
|
||||
// internal and external buffers. The argument is the size of the
|
||||
// internal buffer; the external buffer is sized using the character
|
||||
// width in the current encoding. Preconditions: the buffers are currently
|
||||
// null. __n >= 1. __buf is either a null pointer or a pointer to an
|
||||
// array show size is at least __n.
|
||||
|
||||
// We need __n >= 1 for two different reasons. For input, the base
|
||||
// class always needs a buffer because of the semantics of underflow().
|
||||
// For output, we want to have an internal buffer that's larger by one
|
||||
// element than the buffer that the base class knows about. (See
|
||||
// basic_filebuf<>::overflow() for the reason.)
|
||||
template <class _CharT, class _Traits>
|
||||
bool basic_filebuf<_CharT, _Traits>::_M_allocate_buffers(_CharT* __buf, streamsize __n) {
|
||||
//The major hypothesis in the following implementation is that size_t is unsigned.
|
||||
//We also need streamsize byte representation to be larger or equal to the int
|
||||
//representation to correctly store the encoding information.
|
||||
_STLP_STATIC_ASSERT(!numeric_limits<size_t>::is_signed &&
|
||||
sizeof(streamsize) >= sizeof(int))
|
||||
|
||||
if (__buf == 0) {
|
||||
streamsize __bufsize = __n * sizeof(_CharT);
|
||||
//We first check that the streamsize representation can't overflow a size_t one.
|
||||
//If it can, we check that __bufsize is not higher than the size_t max value.
|
||||
if ((sizeof(streamsize) > sizeof(size_t)) &&
|
||||
(__bufsize > __STATIC_CAST(streamsize, (numeric_limits<size_t>::max)())))
|
||||
return false;
|
||||
_M_int_buf = __STATIC_CAST(_CharT*, malloc(__STATIC_CAST(size_t, __bufsize)));
|
||||
if (!_M_int_buf)
|
||||
return false;
|
||||
_M_int_buf_dynamic = true;
|
||||
}
|
||||
else {
|
||||
_M_int_buf = __buf;
|
||||
_M_int_buf_dynamic = false;
|
||||
}
|
||||
|
||||
streamsize __ebufsiz = (max)(__n * __STATIC_CAST(streamsize, _M_width),
|
||||
__STATIC_CAST(streamsize, _M_codecvt->max_length()));
|
||||
|
||||
_M_ext_buf = 0;
|
||||
if ((sizeof(streamsize) < sizeof(size_t)) ||
|
||||
((sizeof(streamsize) == sizeof(size_t)) && numeric_limits<streamsize>::is_signed) ||
|
||||
(__ebufsiz <= __STATIC_CAST(streamsize, (numeric_limits<size_t>::max)()))) {
|
||||
_M_ext_buf = __STATIC_CAST(char*, malloc(__STATIC_CAST(size_t, __ebufsiz)));
|
||||
}
|
||||
|
||||
if (!_M_ext_buf) {
|
||||
_M_deallocate_buffers();
|
||||
return false;
|
||||
}
|
||||
|
||||
_M_int_buf_EOS = _M_int_buf + __STATIC_CAST(ptrdiff_t, __n);
|
||||
_M_ext_buf_EOS = _M_ext_buf + __STATIC_CAST(ptrdiff_t, __ebufsiz);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Abbreviation for the most common case.
|
||||
template <class _CharT, class _Traits>
|
||||
bool basic_filebuf<_CharT, _Traits>::_M_allocate_buffers() {
|
||||
// Choose a buffer that's at least 4096 characters long and that's a
|
||||
// multiple of the page size.
|
||||
streamsize __default_bufsiz =
|
||||
((_M_base.__page_size() + 4095UL) / _M_base.__page_size()) * _M_base.__page_size();
|
||||
return _M_allocate_buffers(0, __default_bufsiz);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
void basic_filebuf<_CharT, _Traits>::_M_deallocate_buffers() {
|
||||
if (_M_int_buf_dynamic)
|
||||
free(_M_int_buf);
|
||||
free(_M_ext_buf);
|
||||
_M_int_buf = 0;
|
||||
_M_int_buf_EOS = 0;
|
||||
_M_ext_buf = 0;
|
||||
_M_ext_buf_EOS = 0;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------
|
||||
// Helper functiosn for seek and imbue
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
bool basic_filebuf<_CharT, _Traits>::_M_seek_init(bool __do_unshift) {
|
||||
// If we're in error mode, leave it.
|
||||
_M_in_error_mode = false;
|
||||
|
||||
// Flush the output buffer if we're in output mode, and (conditionally)
|
||||
// emit an unshift sequence.
|
||||
if (_M_in_output_mode) {
|
||||
bool __ok = !traits_type::eq_int_type(this->overflow(traits_type::eof()),
|
||||
traits_type::eof());
|
||||
if (__do_unshift)
|
||||
__ok = __ok && this->_M_unshift();
|
||||
if (!__ok) {
|
||||
_M_in_output_mode = false;
|
||||
_M_in_error_mode = true;
|
||||
this->setp(0, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Discard putback characters, if any.
|
||||
if (_M_in_input_mode && _M_in_putback_mode)
|
||||
_M_exit_putback_mode();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Change the filebuf's locale. This member function has no effect
|
||||
* unless it is called before any I/O is performed on the stream.
|
||||
* This function is called on construction and on an imbue call. In the
|
||||
* case of the construction the codecvt facet might be a custom one if
|
||||
* the basic_filebuf user has instanciate it with a custom char_traits.
|
||||
* The user will have to call imbue before any I/O operation.
|
||||
*/
|
||||
template <class _CharT, class _Traits>
|
||||
void basic_filebuf<_CharT, _Traits>::_M_setup_codecvt(const locale& __loc, bool __on_imbue) {
|
||||
if (has_facet<_Codecvt>(__loc)) {
|
||||
_M_codecvt = &use_facet<_Codecvt>(__loc) ;
|
||||
int __encoding = _M_codecvt->encoding();
|
||||
|
||||
_M_width = (max)(__encoding, 1);
|
||||
_M_max_width = _M_codecvt->max_length();
|
||||
_M_constant_width = __encoding > 0;
|
||||
_M_always_noconv = _M_codecvt->always_noconv();
|
||||
}
|
||||
else {
|
||||
_M_codecvt = 0;
|
||||
_M_width = _M_max_width = 1;
|
||||
_M_constant_width = _M_always_noconv = false;
|
||||
if (__on_imbue) {
|
||||
//This call will generate an exception reporting the problem.
|
||||
use_facet<_Codecvt>(__loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# undef __BF_int_type__
|
||||
# undef __BF_pos_type__
|
||||
# undef __BF_off_type__
|
||||
|
||||
#endif /* _STLP_FSTREAM_C */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
714
extern/STLport/5.2.1/stlport/stl/_fstream.h
vendored
Normal file
714
extern/STLport/5.2.1/stlport/stl/_fstream.h
vendored
Normal file
@@ -0,0 +1,714 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
// This header defines classes basic_filebuf, basic_ifstream,
|
||||
// basic_ofstream, and basic_fstream. These classes represent
|
||||
// streambufs and streams whose sources or destinations are files.
|
||||
|
||||
#ifndef _STLP_INTERNAL_FSTREAM_H
|
||||
#define _STLP_INTERNAL_FSTREAM_H
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && !defined(_STANDARD_C_PLUS_PLUS)
|
||||
# error This header file requires the -LANG:std option
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_STREAMBUF
|
||||
# include <stl/_streambuf.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ISTREAM
|
||||
# include <stl/_istream.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_CODECVT_H
|
||||
# include <stl/_codecvt.h>
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_USE_WIN32_IO)
|
||||
typedef void* _STLP_fd;
|
||||
#elif defined (_STLP_USE_UNIX_EMULATION_IO) || defined (_STLP_USE_STDIO_IO) || defined (_STLP_USE_UNIX_IO)
|
||||
typedef int _STLP_fd;
|
||||
#else
|
||||
# error "Configure i/o !"
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class _Filebuf_base, a private base class to factor out the system-
|
||||
// dependent code from basic_filebuf<>.
|
||||
|
||||
class _STLP_CLASS_DECLSPEC _Filebuf_base {
|
||||
public: // Opening and closing files.
|
||||
_Filebuf_base();
|
||||
|
||||
bool _M_open(const char*, ios_base::openmode, long __protection);
|
||||
bool _M_open(const char*, ios_base::openmode);
|
||||
bool _M_open(int __id, ios_base::openmode = ios_base::__default_mode);
|
||||
#if defined (_STLP_USE_WIN32_IO)
|
||||
bool _M_open(_STLP_fd __id, ios_base::openmode = ios_base::__default_mode);
|
||||
#endif /* _STLP_USE_WIN32_IO */
|
||||
bool _M_close();
|
||||
|
||||
public: // Low-level I/O, like Unix read/write
|
||||
ptrdiff_t _M_read(char* __buf, ptrdiff_t __n);
|
||||
streamoff _M_seek(streamoff __offset, ios_base::seekdir __dir);
|
||||
streamoff _M_file_size();
|
||||
bool _M_write(char* __buf, ptrdiff_t __n);
|
||||
|
||||
public: // Memory-mapped I/O.
|
||||
void* _M_mmap(streamoff __offset, streamoff __len);
|
||||
void _M_unmap(void* __mmap_base, streamoff __len);
|
||||
|
||||
public:
|
||||
// Returns a value n such that, if pos is the file pointer at the
|
||||
// beginning of the range [first, last), pos + n is the file pointer at
|
||||
// the end. On many operating systems n == __last - __first.
|
||||
// In Unix, writing n characters always bumps the file position by n.
|
||||
// In Windows text mode, however, it bumps the file position by n + m,
|
||||
// where m is the number of newlines in the range. That's because an
|
||||
// internal \n corresponds to an external two-character sequence.
|
||||
streamoff _M_get_offset(char* __first, char* __last) {
|
||||
#if defined (_STLP_UNIX) || defined (_STLP_MAC)
|
||||
return __last - __first;
|
||||
#else // defined (_STLP_WIN32)
|
||||
return ( (_M_openmode & ios_base::binary) != 0 )
|
||||
? (__last - __first)
|
||||
: count(__first, __last, '\n') + (__last - __first);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Returns true if we're in binary mode or if we're using an OS or file
|
||||
// system where there is no distinction between text and binary mode.
|
||||
bool _M_in_binary_mode() const {
|
||||
#if defined (_STLP_UNIX) || defined (_STLP_MAC) || defined(__BEOS__) || defined (__amigaos__)
|
||||
return true;
|
||||
#elif defined (_STLP_WIN32) || defined (_STLP_VM)
|
||||
return (_M_openmode & ios_base::binary) != 0;
|
||||
#else
|
||||
# error "Port!"
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _S_initialize();
|
||||
|
||||
protected: // Static data members.
|
||||
static size_t _M_page_size;
|
||||
|
||||
protected: // Data members.
|
||||
_STLP_fd _M_file_id;
|
||||
#if defined (_STLP_USE_STDIO_IO)
|
||||
// for stdio, the whole FILE* is being kept here
|
||||
FILE* _M_file;
|
||||
#endif
|
||||
ios_base::openmode _M_openmode ;
|
||||
unsigned char _M_is_open ;
|
||||
unsigned char _M_should_close ;
|
||||
unsigned char _M_regular_file ;
|
||||
|
||||
#if defined (_STLP_USE_WIN32_IO)
|
||||
_STLP_fd _M_view_id;
|
||||
#endif
|
||||
|
||||
public :
|
||||
static size_t _STLP_CALL __page_size() { return _M_page_size; }
|
||||
int __o_mode() const { return (int)_M_openmode; }
|
||||
bool __is_open() const { return (_M_is_open !=0 ); }
|
||||
bool __should_close() const { return (_M_should_close != 0); }
|
||||
bool __regular_file() const { return (_M_regular_file != 0); }
|
||||
_STLP_fd __get_fd() const { return _M_file_id; }
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class basic_filebuf<>.
|
||||
|
||||
// Forward declaration of two helper classes.
|
||||
template <class _Traits> class _Noconv_input;
|
||||
template <class _Traits> class _Noconv_output;
|
||||
|
||||
// There is a specialized version of underflow, for basic_filebuf<char>,
|
||||
// in fstream.cpp.
|
||||
template <class _CharT, class _Traits>
|
||||
class _Underflow;
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
class basic_filebuf : public basic_streambuf<_CharT, _Traits> {
|
||||
public: // Types.
|
||||
typedef _CharT char_type;
|
||||
typedef typename _Traits::int_type int_type;
|
||||
typedef typename _Traits::pos_type pos_type;
|
||||
typedef typename _Traits::off_type off_type;
|
||||
typedef _Traits traits_type;
|
||||
|
||||
typedef typename _Traits::state_type _State_type;
|
||||
typedef basic_streambuf<_CharT, _Traits> _Base;
|
||||
typedef basic_filebuf<_CharT, _Traits> _Self;
|
||||
|
||||
public: // Constructors, destructor.
|
||||
basic_filebuf();
|
||||
~basic_filebuf();
|
||||
|
||||
public: // Opening and closing files.
|
||||
bool is_open() const { return _M_base.__is_open(); }
|
||||
|
||||
_Self* open(const char* __s, ios_base::openmode __m) {
|
||||
return _M_base._M_open(__s, __m) ? this : 0;
|
||||
}
|
||||
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
// These two version of open() and file descriptor getter are extensions.
|
||||
_Self* open(const char* __s, ios_base::openmode __m,
|
||||
long __protection) {
|
||||
return _M_base._M_open(__s, __m, __protection) ? this : 0;
|
||||
}
|
||||
|
||||
_STLP_fd fd() const { return _M_base.__get_fd(); }
|
||||
|
||||
_Self* open(int __id, ios_base::openmode _Init_mode = ios_base::__default_mode) {
|
||||
return this->_M_open(__id, _Init_mode);
|
||||
}
|
||||
|
||||
# if defined (_STLP_USE_WIN32_IO)
|
||||
_Self* open(_STLP_fd __id, ios_base::openmode _Init_mode = ios_base::__default_mode) {
|
||||
return _M_base._M_open(__id, _Init_mode) ? this : 0;
|
||||
}
|
||||
# endif /* _STLP_USE_WIN32_IO */
|
||||
|
||||
#endif
|
||||
|
||||
_Self* _M_open(int __id, ios_base::openmode _Init_mode = ios_base::__default_mode) {
|
||||
return _M_base._M_open(__id, _Init_mode) ? this : 0;
|
||||
}
|
||||
|
||||
_Self* close();
|
||||
|
||||
protected: // Virtual functions from basic_streambuf.
|
||||
virtual streamsize showmanyc();
|
||||
virtual int_type underflow();
|
||||
|
||||
virtual int_type pbackfail(int_type = traits_type::eof());
|
||||
virtual int_type overflow(int_type = traits_type::eof());
|
||||
|
||||
virtual basic_streambuf<_CharT, _Traits>* setbuf(char_type*, streamsize);
|
||||
virtual pos_type seekoff(off_type, ios_base::seekdir,
|
||||
ios_base::openmode = ios_base::in | ios_base::out);
|
||||
virtual pos_type seekpos(pos_type,
|
||||
ios_base::openmode = ios_base::in | ios_base::out);
|
||||
|
||||
virtual int sync();
|
||||
virtual void imbue(const locale&);
|
||||
|
||||
private: // Helper functions.
|
||||
|
||||
// Precondition: we are currently in putback input mode. Effect:
|
||||
// switches back to ordinary input mode.
|
||||
void _M_exit_putback_mode() {
|
||||
this->setg(_M_saved_eback, _M_saved_gptr, _M_saved_egptr);
|
||||
_M_in_putback_mode = false;
|
||||
}
|
||||
bool _M_switch_to_input_mode();
|
||||
void _M_exit_input_mode();
|
||||
bool _M_switch_to_output_mode();
|
||||
|
||||
int_type _M_input_error();
|
||||
int_type _M_underflow_aux();
|
||||
friend class _Underflow<_CharT, _Traits>;
|
||||
|
||||
int_type _M_output_error();
|
||||
bool _M_unshift();
|
||||
|
||||
bool _M_allocate_buffers(_CharT* __buf, streamsize __n);
|
||||
bool _M_allocate_buffers();
|
||||
void _M_deallocate_buffers();
|
||||
|
||||
pos_type _M_seek_return(off_type __off, _State_type __state) {
|
||||
if (__off != -1) {
|
||||
if (_M_in_input_mode)
|
||||
_M_exit_input_mode();
|
||||
_M_in_input_mode = false;
|
||||
_M_in_output_mode = false;
|
||||
_M_in_putback_mode = false;
|
||||
_M_in_error_mode = false;
|
||||
this->setg(0, 0, 0);
|
||||
this->setp(0, 0);
|
||||
}
|
||||
|
||||
pos_type __result(__off);
|
||||
__result.state(__state);
|
||||
return __result;
|
||||
}
|
||||
|
||||
bool _M_seek_init(bool __do_unshift);
|
||||
|
||||
void _M_setup_codecvt(const locale&, bool __on_imbue = true);
|
||||
|
||||
private: // Data members used in all modes.
|
||||
|
||||
_Filebuf_base _M_base;
|
||||
|
||||
private: // Locale-related information.
|
||||
|
||||
unsigned char _M_constant_width;
|
||||
unsigned char _M_always_noconv;
|
||||
|
||||
// private: // Mode flags.
|
||||
unsigned char _M_int_buf_dynamic; // True if internal buffer is heap allocated,
|
||||
// false if it was supplied by the user.
|
||||
unsigned char _M_in_input_mode;
|
||||
unsigned char _M_in_output_mode;
|
||||
unsigned char _M_in_error_mode;
|
||||
unsigned char _M_in_putback_mode;
|
||||
|
||||
// Internal buffer: characters seen by the filebuf's clients.
|
||||
_CharT* _M_int_buf;
|
||||
_CharT* _M_int_buf_EOS;
|
||||
|
||||
// External buffer: characters corresponding to the external file.
|
||||
char* _M_ext_buf;
|
||||
char* _M_ext_buf_EOS;
|
||||
|
||||
// The range [_M_ext_buf, _M_ext_buf_converted) contains the external
|
||||
// characters corresponding to the sequence in the internal buffer. The
|
||||
// range [_M_ext_buf_converted, _M_ext_buf_end) contains characters that
|
||||
// have been read into the external buffer but have not been converted
|
||||
// to an internal sequence.
|
||||
char* _M_ext_buf_converted;
|
||||
char* _M_ext_buf_end;
|
||||
|
||||
// State corresponding to beginning of internal buffer.
|
||||
_State_type _M_state;
|
||||
|
||||
private: // Data members used only in input mode.
|
||||
|
||||
// Similar to _M_state except that it corresponds to
|
||||
// the end of the internal buffer instead of the beginning.
|
||||
_State_type _M_end_state;
|
||||
|
||||
// This is a null pointer unless we are in mmap input mode.
|
||||
void* _M_mmap_base;
|
||||
streamoff _M_mmap_len;
|
||||
|
||||
private: // Data members used only in putback mode.
|
||||
_CharT* _M_saved_eback;
|
||||
_CharT* _M_saved_gptr;
|
||||
_CharT* _M_saved_egptr;
|
||||
|
||||
typedef codecvt<_CharT, char, _State_type> _Codecvt;
|
||||
const _Codecvt* _M_codecvt;
|
||||
|
||||
int _M_width; // Width of the encoding (if constant), else 1
|
||||
int _M_max_width; // Largest possible width of single character.
|
||||
|
||||
|
||||
enum { _S_pback_buf_size = 8 };
|
||||
_CharT _M_pback_buf[_S_pback_buf_size];
|
||||
|
||||
// for _Noconv_output
|
||||
public:
|
||||
bool _M_write(char* __buf, ptrdiff_t __n) {return _M_base._M_write(__buf, __n); }
|
||||
|
||||
public:
|
||||
int_type
|
||||
_M_do_noconv_input() {
|
||||
_M_ext_buf_converted = _M_ext_buf_end;
|
||||
/* this-> */ _Base::setg((char_type*)_M_ext_buf, (char_type*)_M_ext_buf, (char_type*)_M_ext_buf_end);
|
||||
return traits_type::to_int_type(*_M_ext_buf);
|
||||
}
|
||||
};
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_filebuf<char, char_traits<char> >;
|
||||
# if ! defined (_STLP_NO_WCHAR_T)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_filebuf<wchar_t, char_traits<wchar_t> >;
|
||||
# endif
|
||||
#endif /* _STLP_USE_TEMPLATE_EXPORT */
|
||||
|
||||
//
|
||||
// This class had to be designed very carefully to work
|
||||
// with Visual C++.
|
||||
//
|
||||
template <class _Traits>
|
||||
class _Noconv_output {
|
||||
public:
|
||||
typedef typename _Traits::char_type char_type;
|
||||
static bool _STLP_CALL _M_doit(basic_filebuf<char_type, _Traits >*,
|
||||
char_type*, char_type*)
|
||||
{ return false; }
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC _Noconv_output< char_traits<char> > {
|
||||
public:
|
||||
static bool _STLP_CALL
|
||||
_M_doit(basic_filebuf<char, char_traits<char> >* __buf,
|
||||
char* __first, char* __last) {
|
||||
ptrdiff_t __n = __last - __first;
|
||||
return (__buf->_M_write(__first, __n));
|
||||
}
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// basic_filebuf<> helper functions.
|
||||
|
||||
|
||||
//----------------------------------------
|
||||
// Helper functions for switching between modes.
|
||||
|
||||
//
|
||||
// This class had to be designed very carefully to work
|
||||
// with Visual C++.
|
||||
//
|
||||
template <class _Traits>
|
||||
class _Noconv_input {
|
||||
public:
|
||||
typedef typename _Traits::int_type int_type;
|
||||
typedef typename _Traits::char_type char_type;
|
||||
|
||||
static inline int_type _STLP_CALL
|
||||
_M_doit(basic_filebuf<char_type, _Traits>*)
|
||||
{ return _Traits::eof(); }
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _Noconv_input<char_traits<char> > {
|
||||
public:
|
||||
static inline int _STLP_CALL
|
||||
_M_doit(basic_filebuf<char, char_traits<char> >* __buf) {
|
||||
return __buf->_M_do_noconv_input();
|
||||
}
|
||||
};
|
||||
|
||||
// underflow() may be called for one of two reasons. (1) We've
|
||||
// been going through the special putback buffer, and we need to move back
|
||||
// to the regular internal buffer. (2) We've exhausted the internal buffer,
|
||||
// and we need to replentish it.
|
||||
template <class _CharT, class _Traits>
|
||||
class _Underflow {
|
||||
public:
|
||||
typedef typename _Traits::int_type int_type;
|
||||
typedef _Traits traits_type;
|
||||
|
||||
// There is a specialized version of underflow, for basic_filebuf<char>,
|
||||
// in fstream.cpp.
|
||||
static int_type _STLP_CALL _M_doit(basic_filebuf<_CharT, _Traits>* __this) {
|
||||
if (!__this->_M_in_input_mode) {
|
||||
if (!__this->_M_switch_to_input_mode())
|
||||
return traits_type::eof();
|
||||
}
|
||||
else if (__this->_M_in_putback_mode) {
|
||||
__this->_M_exit_putback_mode();
|
||||
if (__this->gptr() != __this->egptr()) {
|
||||
int_type __c = traits_type::to_int_type(*__this->gptr());
|
||||
return __c;
|
||||
}
|
||||
}
|
||||
|
||||
return __this->_M_underflow_aux();
|
||||
}
|
||||
};
|
||||
|
||||
// Specialization of underflow: if the character type is char, maybe
|
||||
// we can use mmap instead of read.
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC _Underflow< char, char_traits<char> >
|
||||
{
|
||||
public:
|
||||
typedef char_traits<char>::int_type int_type;
|
||||
typedef char_traits<char> traits_type;
|
||||
static int_type _STLP_CALL _M_doit(basic_filebuf<char, traits_type >* __this);
|
||||
};
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_NO_WCHAR_T)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS _Underflow<wchar_t, char_traits<wchar_t> >;
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class basic_ifstream<>
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
class basic_ifstream : public basic_istream<_CharT, _Traits> {
|
||||
public: // Types
|
||||
typedef _CharT char_type;
|
||||
typedef typename _Traits::int_type int_type;
|
||||
typedef typename _Traits::pos_type pos_type;
|
||||
typedef typename _Traits::off_type off_type;
|
||||
typedef _Traits traits_type;
|
||||
|
||||
typedef basic_ios<_CharT, _Traits> _Basic_ios;
|
||||
typedef basic_istream<_CharT, _Traits> _Base;
|
||||
typedef basic_filebuf<_CharT, _Traits> _Buf;
|
||||
|
||||
public: // Constructors, destructor.
|
||||
|
||||
basic_ifstream() :
|
||||
basic_ios<_CharT, _Traits>(), basic_istream<_CharT, _Traits>(0), _M_buf() {
|
||||
this->init(&_M_buf);
|
||||
}
|
||||
|
||||
explicit basic_ifstream(const char* __s, ios_base::openmode __mod = ios_base::in) :
|
||||
basic_ios<_CharT, _Traits>(), basic_istream<_CharT, _Traits>(0),
|
||||
_M_buf() {
|
||||
this->init(&_M_buf);
|
||||
if (!_M_buf.open(__s, __mod | ios_base::in))
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
explicit basic_ifstream(int __id, ios_base::openmode __mod = ios_base::in) :
|
||||
basic_ios<_CharT, _Traits>(), basic_istream<_CharT, _Traits>(0), _M_buf() {
|
||||
this->init(&_M_buf);
|
||||
if (!_M_buf.open(__id, __mod | ios_base::in))
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
basic_ifstream(const char* __s, ios_base::openmode __m,
|
||||
long __protection) :
|
||||
basic_ios<_CharT, _Traits>(), basic_istream<_CharT, _Traits>(0), _M_buf() {
|
||||
this->init(&_M_buf);
|
||||
if (!_M_buf.open(__s, __m | ios_base::in, __protection))
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
# if defined (_STLP_USE_WIN32_IO)
|
||||
explicit basic_ifstream(_STLP_fd __id, ios_base::openmode __mod = ios_base::in) :
|
||||
basic_ios<_CharT, _Traits>(), basic_istream<_CharT, _Traits>(0), _M_buf() {
|
||||
this->init(&_M_buf);
|
||||
if (!_M_buf.open(__id, __mod | ios_base::in))
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
# endif /* _STLP_USE_WIN32_IO */
|
||||
#endif
|
||||
|
||||
~basic_ifstream() {}
|
||||
|
||||
public: // File and buffer operations.
|
||||
basic_filebuf<_CharT, _Traits>* rdbuf() const
|
||||
{ return __CONST_CAST(_Buf*,&_M_buf); }
|
||||
|
||||
bool is_open() {
|
||||
return this->rdbuf()->is_open();
|
||||
}
|
||||
|
||||
void open(const char* __s, ios_base::openmode __mod = ios_base::in) {
|
||||
if (!this->rdbuf()->open(__s, __mod | ios_base::in))
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
void close() {
|
||||
if (!this->rdbuf()->close())
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
private:
|
||||
basic_filebuf<_CharT, _Traits> _M_buf;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class basic_ofstream<>
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
class basic_ofstream : public basic_ostream<_CharT, _Traits> {
|
||||
public: // Types
|
||||
typedef _CharT char_type;
|
||||
typedef typename _Traits::int_type int_type;
|
||||
typedef typename _Traits::pos_type pos_type;
|
||||
typedef typename _Traits::off_type off_type;
|
||||
typedef _Traits traits_type;
|
||||
|
||||
typedef basic_ios<_CharT, _Traits> _Basic_ios;
|
||||
typedef basic_ostream<_CharT, _Traits> _Base;
|
||||
typedef basic_filebuf<_CharT, _Traits> _Buf;
|
||||
|
||||
public: // Constructors, destructor.
|
||||
basic_ofstream() :
|
||||
basic_ios<_CharT, _Traits>(),
|
||||
basic_ostream<_CharT, _Traits>(0), _M_buf() {
|
||||
this->init(&_M_buf);
|
||||
}
|
||||
explicit basic_ofstream(const char* __s, ios_base::openmode __mod = ios_base::out)
|
||||
: basic_ios<_CharT, _Traits>(), basic_ostream<_CharT, _Traits>(0), _M_buf() {
|
||||
this->init(&_M_buf);
|
||||
if (!_M_buf.open(__s, __mod | ios_base::out))
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
explicit basic_ofstream(int __id, ios_base::openmode __mod = ios_base::out)
|
||||
: basic_ios<_CharT, _Traits>(), basic_ostream<_CharT, _Traits>(0),
|
||||
_M_buf() {
|
||||
this->init(&_M_buf);
|
||||
if (!_M_buf.open(__id, __mod | ios_base::out))
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
basic_ofstream(const char* __s, ios_base::openmode __m, long __protection) :
|
||||
basic_ios<_CharT, _Traits>(), basic_ostream<_CharT, _Traits>(0), _M_buf() {
|
||||
this->init(&_M_buf);
|
||||
if (!_M_buf.open(__s, __m | ios_base::out, __protection))
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
# if defined (_STLP_USE_WIN32_IO)
|
||||
explicit basic_ofstream(_STLP_fd __id, ios_base::openmode __mod = ios_base::out)
|
||||
: basic_ios<_CharT, _Traits>(), basic_ostream<_CharT, _Traits>(0),
|
||||
_M_buf() {
|
||||
this->init(&_M_buf);
|
||||
if (!_M_buf.open(__id, __mod | ios_base::out))
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
# endif /* _STLP_USE_WIN32_IO */
|
||||
#endif
|
||||
|
||||
~basic_ofstream() {}
|
||||
|
||||
public: // File and buffer operations.
|
||||
basic_filebuf<_CharT, _Traits>* rdbuf() const
|
||||
{ return __CONST_CAST(_Buf*,&_M_buf); }
|
||||
|
||||
bool is_open() {
|
||||
return this->rdbuf()->is_open();
|
||||
}
|
||||
|
||||
void open(const char* __s, ios_base::openmode __mod= ios_base::out) {
|
||||
if (!this->rdbuf()->open(__s, __mod | ios_base::out))
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
void close() {
|
||||
if (!this->rdbuf()->close())
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
private:
|
||||
basic_filebuf<_CharT, _Traits> _M_buf;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class basic_fstream<>
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
class basic_fstream : public basic_iostream<_CharT, _Traits> {
|
||||
public: // Types
|
||||
typedef _CharT char_type;
|
||||
typedef typename _Traits::int_type int_type;
|
||||
typedef typename _Traits::pos_type pos_type;
|
||||
typedef typename _Traits::off_type off_type;
|
||||
typedef _Traits traits_type;
|
||||
|
||||
typedef basic_ios<_CharT, _Traits> _Basic_ios;
|
||||
typedef basic_iostream<_CharT, _Traits> _Base;
|
||||
typedef basic_filebuf<_CharT, _Traits> _Buf;
|
||||
|
||||
public: // Constructors, destructor.
|
||||
|
||||
basic_fstream()
|
||||
: basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() {
|
||||
this->init(&_M_buf);
|
||||
}
|
||||
|
||||
explicit basic_fstream(const char* __s,
|
||||
ios_base::openmode __mod = ios_base::in | ios_base::out) :
|
||||
basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() {
|
||||
this->init(&_M_buf);
|
||||
if (!_M_buf.open(__s, __mod))
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
explicit basic_fstream(int __id,
|
||||
ios_base::openmode __mod = ios_base::in | ios_base::out) :
|
||||
basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() {
|
||||
this->init(&_M_buf);
|
||||
if (!_M_buf.open(__id, __mod))
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
basic_fstream(const char* __s, ios_base::openmode __m, long __protection) :
|
||||
basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() {
|
||||
this->init(&_M_buf);
|
||||
if (!_M_buf.open(__s, __m, __protection))
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
# if defined (_STLP_USE_WIN32_IO)
|
||||
explicit basic_fstream(_STLP_fd __id,
|
||||
ios_base::openmode __mod = ios_base::in | ios_base::out) :
|
||||
basic_ios<_CharT, _Traits>(), basic_iostream<_CharT, _Traits>(0), _M_buf() {
|
||||
this->init(&_M_buf);
|
||||
if (!_M_buf.open(__id, __mod))
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
# endif /* _STLP_USE_WIN32_IO */
|
||||
#endif
|
||||
~basic_fstream() {}
|
||||
|
||||
public: // File and buffer operations.
|
||||
|
||||
basic_filebuf<_CharT, _Traits>* rdbuf() const
|
||||
{ return __CONST_CAST(_Buf*,&_M_buf); }
|
||||
|
||||
bool is_open() {
|
||||
return this->rdbuf()->is_open();
|
||||
}
|
||||
|
||||
void open(const char* __s,
|
||||
ios_base::openmode __mod =
|
||||
ios_base::in | ios_base::out) {
|
||||
if (!this->rdbuf()->open(__s, __mod))
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
void close() {
|
||||
if (!this->rdbuf()->close())
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
private:
|
||||
basic_filebuf<_CharT, _Traits> _M_buf;
|
||||
|
||||
#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1300 && _STLP_MSVC <= 1310)
|
||||
typedef basic_fstream<_CharT, _Traits> _Self;
|
||||
//explicitely defined as private to avoid warnings:
|
||||
basic_fstream(_Self const&);
|
||||
_Self& operator = (_Self const&);
|
||||
#endif
|
||||
};
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_fstream.c>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_ifstream<char, char_traits<char> >;
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_ofstream<char, char_traits<char> >;
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_fstream<char, char_traits<char> >;
|
||||
# if ! defined (_STLP_NO_WCHAR_T)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_ifstream<wchar_t, char_traits<wchar_t> >;
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_ofstream<wchar_t, char_traits<wchar_t> >;
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_fstream<wchar_t, char_traits<wchar_t> >;
|
||||
# endif
|
||||
#endif /* _STLP_USE_TEMPLATE_EXPORT */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_FSTREAM */
|
||||
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
433
extern/STLport/5.2.1/stlport/stl/_function.h
vendored
Normal file
433
extern/STLport/5.2.1/stlport/stl/_function.h
vendored
Normal file
@@ -0,0 +1,433 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996-1998
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_FUNCTION_H
|
||||
#define _STLP_INTERNAL_FUNCTION_H
|
||||
|
||||
#ifndef _STLP_TYPE_TRAITS_H
|
||||
# include <stl/type_traits.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
|
||||
# include <stl/_function_base.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _Tp>
|
||||
struct not_equal_to : public binary_function<_Tp, _Tp, bool> {
|
||||
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x != __y; }
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct greater : public binary_function<_Tp, _Tp, bool> {
|
||||
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x > __y; }
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct greater_equal : public binary_function<_Tp, _Tp, bool> {
|
||||
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x >= __y; }
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct less_equal : public binary_function<_Tp, _Tp, bool> {
|
||||
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x <= __y; }
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct divides : public binary_function<_Tp, _Tp, _Tp> {
|
||||
_Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x / __y; }
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct modulus : public binary_function<_Tp, _Tp, _Tp> {
|
||||
_Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x % __y; }
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct negate : public unary_function<_Tp, _Tp> {
|
||||
_Tp operator()(const _Tp& __x) const { return -__x; }
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct logical_and : public binary_function<_Tp, _Tp, bool> {
|
||||
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x && __y; }
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct logical_or : public binary_function<_Tp, _Tp,bool> {
|
||||
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x || __y; }
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct logical_not : public unary_function<_Tp, bool> {
|
||||
bool operator()(const _Tp& __x) const { return !__x; }
|
||||
};
|
||||
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
// identity_element (not part of the C++ standard).
|
||||
template <class _Tp> inline _Tp identity_element(plus<_Tp>) { return _Tp(0); }
|
||||
template <class _Tp> inline _Tp identity_element(multiplies<_Tp>) { return _Tp(1); }
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_BASE_TYPEDEF_BUG)
|
||||
// this workaround is needed for SunPro 4.0.1
|
||||
// suggested by "Martin Abernethy" <gma@paston.co.uk>:
|
||||
|
||||
// We have to introduce the XXary_predicate_aux structures in order to
|
||||
// access the argument and return types of predicate functions supplied
|
||||
// as type parameters. SUN C++ 4.0.1 compiler gives errors for template type parameters
|
||||
// of the form 'name1::name2', where name1 is itself a type parameter.
|
||||
template <class _Pair>
|
||||
struct __pair_aux : private _Pair {
|
||||
typedef typename _Pair::first_type first_type;
|
||||
typedef typename _Pair::second_type second_type;
|
||||
};
|
||||
|
||||
template <class _Operation>
|
||||
struct __unary_fun_aux : private _Operation {
|
||||
typedef typename _Operation::argument_type argument_type;
|
||||
typedef typename _Operation::result_type result_type;
|
||||
};
|
||||
|
||||
template <class _Operation>
|
||||
struct __binary_fun_aux : private _Operation {
|
||||
typedef typename _Operation::first_argument_type first_argument_type;
|
||||
typedef typename _Operation::second_argument_type second_argument_type;
|
||||
typedef typename _Operation::result_type result_type;
|
||||
};
|
||||
|
||||
# define __UNARY_ARG(__Operation,__type) __unary_fun_aux<__Operation>::__type
|
||||
# define __BINARY_ARG(__Operation,__type) __binary_fun_aux<__Operation>::__type
|
||||
# define __PAIR_ARG(__Pair,__type) __pair_aux<__Pair>::__type
|
||||
#else
|
||||
# define __UNARY_ARG(__Operation,__type) __Operation::__type
|
||||
# define __BINARY_ARG(__Operation,__type) __Operation::__type
|
||||
# define __PAIR_ARG(__Pair,__type) __Pair::__type
|
||||
#endif
|
||||
|
||||
template <class _Predicate>
|
||||
class unary_negate
|
||||
: public unary_function<typename __UNARY_ARG(_Predicate, argument_type), bool> {
|
||||
typedef unary_function<typename __UNARY_ARG(_Predicate, argument_type), bool> _Base;
|
||||
public:
|
||||
typedef typename _Base::argument_type argument_type;
|
||||
private:
|
||||
typedef typename __call_traits<argument_type>::const_param_type _ArgParamType;
|
||||
protected:
|
||||
_Predicate _M_pred;
|
||||
public:
|
||||
explicit unary_negate(const _Predicate& __x) : _M_pred(__x) {}
|
||||
bool operator()(_ArgParamType __x) const {
|
||||
return !_M_pred(__x);
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Predicate>
|
||||
inline unary_negate<_Predicate>
|
||||
not1(const _Predicate& __pred) {
|
||||
return unary_negate<_Predicate>(__pred);
|
||||
}
|
||||
|
||||
template <class _Predicate>
|
||||
class binary_negate
|
||||
: public binary_function<typename __BINARY_ARG(_Predicate, first_argument_type),
|
||||
typename __BINARY_ARG(_Predicate, second_argument_type),
|
||||
bool> {
|
||||
typedef binary_function<typename __BINARY_ARG(_Predicate, first_argument_type),
|
||||
typename __BINARY_ARG(_Predicate, second_argument_type),
|
||||
bool> _Base;
|
||||
public:
|
||||
typedef typename _Base::first_argument_type first_argument_type;
|
||||
typedef typename _Base::second_argument_type second_argument_type;
|
||||
private:
|
||||
typedef typename __call_traits<first_argument_type>::const_param_type _FstArgParamType;
|
||||
typedef typename __call_traits<second_argument_type>::const_param_type _SndArgParamType;
|
||||
protected:
|
||||
_Predicate _M_pred;
|
||||
public:
|
||||
explicit binary_negate(const _Predicate& __x) : _M_pred(__x) {}
|
||||
bool operator()(_FstArgParamType __x, _SndArgParamType __y) const {
|
||||
return !_M_pred(__x, __y);
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Predicate>
|
||||
inline binary_negate<_Predicate>
|
||||
not2(const _Predicate& __pred) {
|
||||
return binary_negate<_Predicate>(__pred);
|
||||
}
|
||||
|
||||
template <class _Operation>
|
||||
class binder1st :
|
||||
public unary_function<typename __BINARY_ARG(_Operation, second_argument_type),
|
||||
typename __BINARY_ARG(_Operation, result_type) > {
|
||||
typedef unary_function<typename __BINARY_ARG(_Operation, second_argument_type),
|
||||
typename __BINARY_ARG(_Operation, result_type) > _Base;
|
||||
public:
|
||||
typedef typename _Base::argument_type argument_type;
|
||||
typedef typename _Base::result_type result_type;
|
||||
private:
|
||||
typedef typename __call_traits<argument_type>::param_type _ArgParamType;
|
||||
typedef typename __call_traits<argument_type>::const_param_type _ConstArgParamType;
|
||||
typedef typename __call_traits<typename _Operation::first_argument_type>::const_param_type _ValueParamType;
|
||||
protected:
|
||||
//op is a Standard name (20.3.6.1), do no make it STLport naming convention compliant.
|
||||
_Operation op;
|
||||
typename _Operation::first_argument_type _M_value;
|
||||
public:
|
||||
binder1st(const _Operation& __x, _ValueParamType __y)
|
||||
: op(__x), _M_value(__y) {}
|
||||
|
||||
result_type operator()(_ConstArgParamType __x) const
|
||||
{ return op(_M_value, __x); }
|
||||
// DR 109 Missing binders for non-const sequence elements
|
||||
result_type operator()(_ArgParamType __x) const
|
||||
{ return op(_M_value, __x); }
|
||||
};
|
||||
|
||||
template <class _Operation, class _Tp>
|
||||
inline binder1st<_Operation>
|
||||
bind1st(const _Operation& __fn, const _Tp& __x) {
|
||||
typedef typename _Operation::first_argument_type _Arg1_type;
|
||||
return binder1st<_Operation>(__fn, _Arg1_type(__x));
|
||||
}
|
||||
|
||||
template <class _Operation>
|
||||
class binder2nd
|
||||
: public unary_function<typename __BINARY_ARG(_Operation, first_argument_type),
|
||||
typename __BINARY_ARG(_Operation, result_type)> {
|
||||
typedef unary_function<typename __BINARY_ARG(_Operation, first_argument_type),
|
||||
typename __BINARY_ARG(_Operation, result_type)> _Base;
|
||||
public:
|
||||
typedef typename _Base::argument_type argument_type;
|
||||
typedef typename _Base::result_type result_type;
|
||||
private:
|
||||
typedef typename __call_traits<argument_type>::param_type _ArgParamType;
|
||||
typedef typename __call_traits<argument_type>::const_param_type _ConstArgParamType;
|
||||
typedef typename __call_traits<typename _Operation::second_argument_type>::const_param_type _ValueParamType;
|
||||
protected:
|
||||
//op is a Standard name (20.3.6.3), do no make it STLport naming convention compliant.
|
||||
_Operation op;
|
||||
typename _Operation::second_argument_type value;
|
||||
public:
|
||||
binder2nd(const _Operation& __x, _ValueParamType __y)
|
||||
: op(__x), value(__y) {}
|
||||
|
||||
result_type operator()(_ConstArgParamType __x) const
|
||||
{ return op(__x, value); }
|
||||
// DR 109 Missing binders for non-const sequence elements
|
||||
result_type operator()(_ArgParamType __x) const
|
||||
{ return op(__x, value); }
|
||||
};
|
||||
|
||||
template <class _Operation, class _Tp>
|
||||
inline binder2nd<_Operation>
|
||||
bind2nd(const _Operation& __fn, const _Tp& __x) {
|
||||
typedef typename _Operation::second_argument_type _Arg2_type;
|
||||
return binder2nd<_Operation>(__fn, _Arg2_type(__x));
|
||||
}
|
||||
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
// unary_compose and binary_compose (extensions, not part of the standard).
|
||||
|
||||
template <class _Operation1, class _Operation2>
|
||||
class unary_compose :
|
||||
public unary_function<typename __UNARY_ARG(_Operation2, argument_type),
|
||||
typename __UNARY_ARG(_Operation1, result_type)> {
|
||||
typedef unary_function<typename __UNARY_ARG(_Operation2, argument_type),
|
||||
typename __UNARY_ARG(_Operation1, result_type)> _Base;
|
||||
public:
|
||||
typedef typename _Base::argument_type argument_type;
|
||||
typedef typename _Base::result_type result_type;
|
||||
private:
|
||||
typedef typename __call_traits<argument_type>::const_param_type _ArgParamType;
|
||||
protected:
|
||||
_Operation1 _M_fn1;
|
||||
_Operation2 _M_fn2;
|
||||
public:
|
||||
unary_compose(const _Operation1& __x, const _Operation2& __y)
|
||||
: _M_fn1(__x), _M_fn2(__y) {}
|
||||
|
||||
result_type operator()(_ArgParamType __x) const {
|
||||
return _M_fn1(_M_fn2(__x));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Operation1, class _Operation2>
|
||||
inline unary_compose<_Operation1,_Operation2>
|
||||
compose1(const _Operation1& __fn1, const _Operation2& __fn2) {
|
||||
return unary_compose<_Operation1,_Operation2>(__fn1, __fn2);
|
||||
}
|
||||
|
||||
template <class _Operation1, class _Operation2, class _Operation3>
|
||||
class binary_compose :
|
||||
public unary_function<typename __UNARY_ARG(_Operation2, argument_type),
|
||||
typename __BINARY_ARG(_Operation1, result_type)> {
|
||||
typedef unary_function<typename __UNARY_ARG(_Operation2, argument_type),
|
||||
typename __BINARY_ARG(_Operation1, result_type)> _Base;
|
||||
public:
|
||||
typedef typename _Base::argument_type argument_type;
|
||||
typedef typename _Base::result_type result_type;
|
||||
private:
|
||||
typedef typename __call_traits<argument_type>::const_param_type _ArgParamType;
|
||||
protected:
|
||||
_Operation1 _M_fn1;
|
||||
_Operation2 _M_fn2;
|
||||
_Operation3 _M_fn3;
|
||||
public:
|
||||
binary_compose(const _Operation1& __x, const _Operation2& __y,
|
||||
const _Operation3& __z)
|
||||
: _M_fn1(__x), _M_fn2(__y), _M_fn3(__z) { }
|
||||
|
||||
result_type operator()(_ArgParamType __x) const {
|
||||
return _M_fn1(_M_fn2(__x), _M_fn3(__x));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Operation1, class _Operation2, class _Operation3>
|
||||
inline binary_compose<_Operation1, _Operation2, _Operation3>
|
||||
compose2(const _Operation1& __fn1, const _Operation2& __fn2,
|
||||
const _Operation3& __fn3) {
|
||||
return binary_compose<_Operation1,_Operation2,_Operation3>(__fn1, __fn2, __fn3);
|
||||
}
|
||||
|
||||
// identity is an extension: it is not part of the standard.
|
||||
template <class _Tp> struct identity : public _STLP_PRIV _Identity<_Tp> {};
|
||||
// select1st and select2nd are extensions: they are not part of the standard.
|
||||
template <class _Pair> struct select1st : public _STLP_PRIV _Select1st<_Pair> {};
|
||||
template <class _Pair> struct select2nd : public _STLP_PRIV _Select2nd<_Pair> {};
|
||||
|
||||
template <class _Arg1, class _Arg2>
|
||||
struct project1st : public _STLP_PRIV _Project1st<_Arg1, _Arg2> {};
|
||||
|
||||
template <class _Arg1, class _Arg2>
|
||||
struct project2nd : public _STLP_PRIV _Project2nd<_Arg1, _Arg2> {};
|
||||
|
||||
|
||||
// constant_void_fun, constant_unary_fun, and constant_binary_fun are
|
||||
// extensions: they are not part of the standard. (The same, of course,
|
||||
// is true of the helper functions constant0, constant1, and constant2.)
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Result>
|
||||
struct _Constant_void_fun {
|
||||
typedef _Result result_type;
|
||||
result_type _M_val;
|
||||
|
||||
_Constant_void_fun(const result_type& __v) : _M_val(__v) {}
|
||||
const result_type& operator()() const { return _M_val; }
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _Result>
|
||||
struct constant_void_fun : public _STLP_PRIV _Constant_void_fun<_Result> {
|
||||
constant_void_fun(const _Result& __v)
|
||||
: _STLP_PRIV _Constant_void_fun<_Result>(__v) {}
|
||||
};
|
||||
|
||||
template <class _Result, _STLP_DFL_TMPL_PARAM( _Argument , _Result) >
|
||||
struct constant_unary_fun : public _STLP_PRIV _Constant_unary_fun<_Result, _Argument> {
|
||||
constant_unary_fun(const _Result& __v)
|
||||
: _STLP_PRIV _Constant_unary_fun<_Result, _Argument>(__v) {}
|
||||
};
|
||||
|
||||
template <class _Result, _STLP_DFL_TMPL_PARAM( _Arg1 , _Result), _STLP_DFL_TMPL_PARAM( _Arg2 , _Arg1) >
|
||||
struct constant_binary_fun
|
||||
: public _STLP_PRIV _Constant_binary_fun<_Result, _Arg1, _Arg2> {
|
||||
constant_binary_fun(const _Result& __v)
|
||||
: _STLP_PRIV _Constant_binary_fun<_Result, _Arg1, _Arg2>(__v) {}
|
||||
};
|
||||
|
||||
template <class _Result>
|
||||
inline constant_void_fun<_Result> constant0(const _Result& __val) {
|
||||
return constant_void_fun<_Result>(__val);
|
||||
}
|
||||
|
||||
template <class _Result>
|
||||
inline constant_unary_fun<_Result,_Result> constant1(const _Result& __val) {
|
||||
return constant_unary_fun<_Result,_Result>(__val);
|
||||
}
|
||||
|
||||
template <class _Result>
|
||||
inline constant_binary_fun<_Result,_Result,_Result>
|
||||
constant2(const _Result& __val) {
|
||||
return constant_binary_fun<_Result,_Result,_Result>(__val);
|
||||
}
|
||||
|
||||
// subtractive_rng is an extension: it is not part of the standard.
|
||||
// Note: this code assumes that int is 32 bits.
|
||||
class subtractive_rng : public unary_function<_STLP_UINT32_T, _STLP_UINT32_T> {
|
||||
private:
|
||||
_STLP_UINT32_T _M_table[55];
|
||||
_STLP_UINT32_T _M_index1;
|
||||
_STLP_UINT32_T _M_index2;
|
||||
public:
|
||||
_STLP_UINT32_T operator()(_STLP_UINT32_T __limit) {
|
||||
_M_index1 = (_M_index1 + 1) % 55;
|
||||
_M_index2 = (_M_index2 + 1) % 55;
|
||||
_M_table[_M_index1] = _M_table[_M_index1] - _M_table[_M_index2];
|
||||
return _M_table[_M_index1] % __limit;
|
||||
}
|
||||
|
||||
void _M_initialize(_STLP_UINT32_T __seed) {
|
||||
_STLP_UINT32_T __k = 1;
|
||||
_M_table[54] = __seed;
|
||||
_STLP_UINT32_T __i;
|
||||
for (__i = 0; __i < 54; __i++) {
|
||||
_STLP_UINT32_T __ii = (21 * (__i + 1) % 55) - 1;
|
||||
_M_table[__ii] = __k;
|
||||
__k = __seed - __k;
|
||||
__seed = _M_table[__ii];
|
||||
}
|
||||
for (int __loop = 0; __loop < 4; __loop++) {
|
||||
for (__i = 0; __i < 55; __i++)
|
||||
_M_table[__i] = _M_table[__i] - _M_table[(1 + __i + 30) % 55];
|
||||
}
|
||||
_M_index1 = 0;
|
||||
_M_index2 = 31;
|
||||
}
|
||||
|
||||
subtractive_rng(unsigned int __seed) { _M_initialize(__seed); }
|
||||
subtractive_rng() { _M_initialize(161803398ul); }
|
||||
};
|
||||
|
||||
#endif /* _STLP_NO_EXTENSIONS */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#include <stl/_function_adaptors.h>
|
||||
|
||||
#endif /* _STLP_INTERNAL_FUNCTION_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
783
extern/STLport/5.2.1/stlport/stl/_function_adaptors.h
vendored
Normal file
783
extern/STLport/5.2.1/stlport/stl/_function_adaptors.h
vendored
Normal file
@@ -0,0 +1,783 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996-1998
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* Copyright (c) 2000
|
||||
* Pavel Kuznetsov
|
||||
*
|
||||
* Copyright (c) 2001
|
||||
* Meridian'93
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
// This file has noo macro protection as it is meant to be included several times
|
||||
// from other header.
|
||||
// Adaptor function objects: pointers to member functions.
|
||||
|
||||
// There are a total of 16 = 2^4 function objects in this family.
|
||||
// (1) Member functions taking no arguments vs member functions taking
|
||||
// one argument.
|
||||
// (2) Call through pointer vs call through reference.
|
||||
// (3) Member function with void return type vs member function with
|
||||
// non-void return type.
|
||||
// (4) Const vs non-const member function.
|
||||
|
||||
// Note that choice (3) is nothing more than a workaround: according
|
||||
// to the draft, compilers should handle void and non-void the same way.
|
||||
// This feature is not yet widely implemented, though. You can only use
|
||||
// member functions returning void if your compiler supports partial
|
||||
// specialization.
|
||||
|
||||
// All of this complexity is in the function objects themselves. You can
|
||||
// ignore it by using the helper function mem_fun and mem_fun_ref,
|
||||
// which create whichever type of adaptor is appropriate.
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
//This implementation will only be used if needed, that is to say when there is the return void bug
|
||||
//and when there is no partial template specialization
|
||||
#if defined (_STLP_DONT_RETURN_VOID) && defined (_STLP_NO_CLASS_PARTIAL_SPECIALIZATION) && defined (_STLP_MEMBER_TEMPLATE_CLASSES)
|
||||
|
||||
template<class _Result, class _Tp>
|
||||
class _Mem_fun0_ptr : public unary_function<_Tp*, _Result> {
|
||||
protected:
|
||||
typedef _Result (_Tp::*__fun_type) ();
|
||||
explicit _Mem_fun0_ptr(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
_Result operator ()(_Tp* __p) const { return (__p->*_M_f)(); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Result, class _Tp, class _Arg>
|
||||
class _Mem_fun1_ptr : public binary_function<_Tp*,_Arg,_Result> {
|
||||
protected:
|
||||
typedef _Result (_Tp::*__fun_type) (_Arg);
|
||||
explicit _Mem_fun1_ptr(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
_Result operator ()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Result, class _Tp>
|
||||
class _Const_mem_fun0_ptr : public unary_function<const _Tp*,_Result> {
|
||||
protected:
|
||||
typedef _Result (_Tp::*__fun_type) () const;
|
||||
explicit _Const_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
_Result operator ()(const _Tp* __p) const { return (__p->*_M_f)(); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Result, class _Tp, class _Arg>
|
||||
class _Const_mem_fun1_ptr : public binary_function<const _Tp*,_Arg,_Result> {
|
||||
protected:
|
||||
typedef _Result (_Tp::*__fun_type) (_Arg) const;
|
||||
explicit _Const_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
_Result operator ()(const _Tp* __p, _Arg __x) const {
|
||||
return (__p->*_M_f)(__x); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Result, class _Tp>
|
||||
class _Mem_fun0_ref : public unary_function<_Tp,_Result> {
|
||||
protected:
|
||||
typedef _Result (_Tp::*__fun_type) ();
|
||||
explicit _Mem_fun0_ref(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
_Result operator ()(_Tp& __p) const { return (__p.*_M_f)(); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Result, class _Tp, class _Arg>
|
||||
class _Mem_fun1_ref : public binary_function<_Tp,_Arg,_Result> {
|
||||
protected:
|
||||
typedef _Result (_Tp::*__fun_type) (_Arg);
|
||||
explicit _Mem_fun1_ref(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
_Result operator ()(_Tp& __p, _Arg __x) const { return (__p.*_M_f)(__x); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Result, class _Tp>
|
||||
class _Const_mem_fun0_ref : public unary_function<_Tp,_Result> {
|
||||
protected:
|
||||
typedef _Result (_Tp::*__fun_type) () const;
|
||||
explicit _Const_mem_fun0_ref(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
_Result operator ()(const _Tp& __p) const { return (__p.*_M_f)(); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Result, class _Tp, class _Arg>
|
||||
class _Const_mem_fun1_ref : public binary_function<_Tp,_Arg,_Result> {
|
||||
protected:
|
||||
typedef _Result (_Tp::*__fun_type) (_Arg) const;
|
||||
explicit _Const_mem_fun1_ref(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
_Result operator ()(const _Tp& __p, _Arg __x) const { return (__p.*_M_f)(__x); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Result>
|
||||
struct _Mem_fun_traits {
|
||||
template<class _Tp>
|
||||
struct _Args0 {
|
||||
typedef _Mem_fun0_ptr<_Result,_Tp> _Ptr;
|
||||
typedef _Const_mem_fun0_ptr<_Result,_Tp> _Ptr_const;
|
||||
typedef _Mem_fun0_ref<_Result,_Tp> _Ref;
|
||||
typedef _Const_mem_fun0_ref<_Result,_Tp> _Ref_const;
|
||||
};
|
||||
|
||||
template<class _Tp, class _Arg>
|
||||
struct _Args1 {
|
||||
typedef _Mem_fun1_ptr<_Result,_Tp,_Arg> _Ptr;
|
||||
typedef _Const_mem_fun1_ptr<_Result,_Tp,_Arg> _Ptr_const;
|
||||
typedef _Mem_fun1_ref<_Result,_Tp,_Arg> _Ref;
|
||||
typedef _Const_mem_fun1_ref<_Result,_Tp,_Arg> _Ref_const;
|
||||
};
|
||||
};
|
||||
|
||||
template<class _Arg, class _Result>
|
||||
class _Ptr_fun1_base : public unary_function<_Arg, _Result> {
|
||||
protected:
|
||||
typedef _Result (*__fun_type) (_Arg);
|
||||
explicit _Ptr_fun1_base(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
_Result operator()(_Arg __x) const { return _M_f(__x); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Arg1, class _Arg2, class _Result>
|
||||
class _Ptr_fun2_base : public binary_function<_Arg1,_Arg2,_Result> {
|
||||
protected:
|
||||
typedef _Result (*__fun_type) (_Arg1, _Arg2);
|
||||
explicit _Ptr_fun2_base(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
_Result operator()(_Arg1 __x, _Arg2 __y) const { return _M_f(__x, __y); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Result>
|
||||
struct _Ptr_fun_traits {
|
||||
template<class _Arg> struct _Args1 {
|
||||
typedef _Ptr_fun1_base<_Arg,_Result> _Fun;
|
||||
};
|
||||
|
||||
template<class _Arg1, class _Arg2> struct _Args2 {
|
||||
typedef _Ptr_fun2_base<_Arg1,_Arg2,_Result> _Fun;
|
||||
};
|
||||
};
|
||||
|
||||
/* Specializations for void return type */
|
||||
template<class _Tp>
|
||||
class _Void_mem_fun0_ptr : public unary_function<_Tp*,void> {
|
||||
protected:
|
||||
typedef void (_Tp::*__fun_type) ();
|
||||
explicit _Void_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
void operator ()(_Tp* __p) const { (__p->*_M_f)(); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Tp, class _Arg>
|
||||
class _Void_mem_fun1_ptr : public binary_function<_Tp*,_Arg,void> {
|
||||
protected:
|
||||
typedef void (_Tp::*__fun_type) (_Arg);
|
||||
explicit _Void_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
void operator ()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Tp>
|
||||
class _Void_const_mem_fun0_ptr : public unary_function<const _Tp*,void> {
|
||||
protected:
|
||||
typedef void (_Tp::*__fun_type) () const;
|
||||
explicit _Void_const_mem_fun0_ptr(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
void operator ()(const _Tp* __p) const { (__p->*_M_f)(); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Tp, class _Arg>
|
||||
class _Void_const_mem_fun1_ptr : public binary_function<const _Tp*,_Arg,void> {
|
||||
protected:
|
||||
typedef void (_Tp::*__fun_type) (_Arg) const;
|
||||
explicit _Void_const_mem_fun1_ptr(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
void operator ()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Tp>
|
||||
class _Void_mem_fun0_ref : public unary_function<_Tp,void> {
|
||||
protected:
|
||||
typedef void (_Tp::*__fun_type) ();
|
||||
explicit _Void_mem_fun0_ref(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
void operator ()(_Tp& __p) const { (__p.*_M_f)(); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Tp, class _Arg>
|
||||
class _Void_mem_fun1_ref : public binary_function<_Tp,_Arg,void> {
|
||||
protected:
|
||||
typedef void (_Tp::*__fun_type) (_Arg);
|
||||
explicit _Void_mem_fun1_ref(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
void operator ()(_Tp& __p, _Arg __x) const { (__p.*_M_f)(__x); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Tp>
|
||||
class _Void_const_mem_fun0_ref : public unary_function<_Tp,void> {
|
||||
protected:
|
||||
typedef void (_Tp::*__fun_type) () const;
|
||||
explicit _Void_const_mem_fun0_ref(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
void operator ()(const _Tp& __p) const { (__p.*_M_f)(); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template<class _Tp, class _Arg>
|
||||
class _Void_const_mem_fun1_ref : public binary_function<_Tp,_Arg,void> {
|
||||
protected:
|
||||
typedef void (_Tp::*__fun_type) (_Arg) const;
|
||||
explicit _Void_const_mem_fun1_ref(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
void operator ()(const _Tp& __p, _Arg __x) const { (__p.*_M_f)(__x); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct _Mem_fun_traits<void> {
|
||||
template<class _Tp> struct _Args0 {
|
||||
typedef _Void_mem_fun0_ptr<_Tp> _Ptr;
|
||||
typedef _Void_const_mem_fun0_ptr<_Tp> _Ptr_const;
|
||||
typedef _Void_mem_fun0_ref<_Tp> _Ref;
|
||||
typedef _Void_const_mem_fun0_ref<_Tp> _Ref_const;
|
||||
};
|
||||
|
||||
template<class _Tp, class _Arg> struct _Args1 {
|
||||
typedef _Void_mem_fun1_ptr<_Tp,_Arg> _Ptr;
|
||||
typedef _Void_const_mem_fun1_ptr<_Tp,_Arg> _Ptr_const;
|
||||
typedef _Void_mem_fun1_ref<_Tp,_Arg> _Ref;
|
||||
typedef _Void_const_mem_fun1_ref<_Tp,_Arg> _Ref_const;
|
||||
};
|
||||
};
|
||||
|
||||
template<class _Arg>
|
||||
class _Ptr_void_fun1_base : public unary_function<_Arg, void> {
|
||||
protected:
|
||||
typedef void (*__fun_type) (_Arg);
|
||||
explicit _Ptr_void_fun1_base(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
void operator()(_Arg __x) const { _M_f(__x); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Arg1, class _Arg2>
|
||||
class _Ptr_void_fun2_base : public binary_function<_Arg1,_Arg2,void> {
|
||||
protected:
|
||||
typedef void (*__fun_type) (_Arg1, _Arg2);
|
||||
explicit _Ptr_void_fun2_base(__fun_type __f) : _M_f(__f) {}
|
||||
|
||||
public:
|
||||
void operator()(_Arg1 __x, _Arg2 __y) const { _M_f(__x, __y); }
|
||||
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct _Ptr_fun_traits<void> {
|
||||
template<class _Arg> struct _Args1 {
|
||||
typedef _Ptr_void_fun1_base<_Arg> _Fun;
|
||||
};
|
||||
|
||||
template<class _Arg1, class _Arg2> struct _Args2 {
|
||||
typedef _Ptr_void_fun2_base<_Arg1,_Arg2> _Fun;
|
||||
};
|
||||
};
|
||||
|
||||
// pavel: need extra level of inheritance here since MSVC++ does not
|
||||
// accept traits-based fake partial specialization for template
|
||||
// arguments other than first
|
||||
|
||||
template<class _Result, class _Arg>
|
||||
class _Ptr_fun1 :
|
||||
public _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Arg>::_Fun {
|
||||
protected:
|
||||
typedef typename _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Arg>::_Fun _Base;
|
||||
explicit _Ptr_fun1(typename _Base::__fun_type __f) : _Base(__f) {}
|
||||
};
|
||||
|
||||
template<class _Result, class _Arg1, class _Arg2>
|
||||
class _Ptr_fun2 :
|
||||
public _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args2<_Arg1,_Arg2>::_Fun {
|
||||
protected:
|
||||
typedef typename _Ptr_fun_traits<_Result>::_STLP_TEMPLATE _Args2<_Arg1,_Arg2>::_Fun _Base;
|
||||
explicit _Ptr_fun2(typename _Base::__fun_type __f) : _Base(__f) {}
|
||||
};
|
||||
|
||||
template <class _Result, class _Tp>
|
||||
class mem_fun_t :
|
||||
public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr {
|
||||
typedef typename
|
||||
_Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr _Base;
|
||||
public:
|
||||
explicit mem_fun_t(typename _Base::__fun_type __f) : _Base(__f) {}
|
||||
};
|
||||
|
||||
template <class _Result, class _Tp>
|
||||
class const_mem_fun_t :
|
||||
public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr_const {
|
||||
typedef typename
|
||||
_Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ptr_const _Base;
|
||||
public:
|
||||
explicit const_mem_fun_t(typename _Base::__fun_type __f) : _Base(__f) {}
|
||||
};
|
||||
|
||||
template <class _Result, class _Tp>
|
||||
class mem_fun_ref_t :
|
||||
public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref {
|
||||
typedef typename
|
||||
_Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref _Base;
|
||||
public:
|
||||
explicit mem_fun_ref_t(typename _Base::__fun_type __f) : _Base(__f) {}
|
||||
};
|
||||
|
||||
template <class _Result, class _Tp>
|
||||
class const_mem_fun_ref_t :
|
||||
public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref_const {
|
||||
typedef typename
|
||||
_Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args0<_Tp>::_Ref_const _Base;
|
||||
public:
|
||||
explicit const_mem_fun_ref_t(typename _Base::__fun_type __f) : _Base(__f) {}
|
||||
};
|
||||
|
||||
template <class _Result, class _Tp, class _Arg>
|
||||
class mem_fun1_t :
|
||||
public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr {
|
||||
typedef typename
|
||||
_Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr _Base;
|
||||
public:
|
||||
explicit mem_fun1_t(typename _Base::__fun_type __f) : _Base(__f) {}
|
||||
};
|
||||
|
||||
template <class _Result, class _Tp, class _Arg>
|
||||
class const_mem_fun1_t :
|
||||
public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr_const {
|
||||
typedef typename
|
||||
_Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ptr_const _Base;
|
||||
public:
|
||||
explicit const_mem_fun1_t(typename _Base::__fun_type __f) : _Base(__f) {}
|
||||
};
|
||||
|
||||
template <class _Result, class _Tp, class _Arg>
|
||||
class mem_fun1_ref_t :
|
||||
public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref {
|
||||
typedef typename
|
||||
_Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref _Base;
|
||||
public:
|
||||
explicit mem_fun1_ref_t(typename _Base::__fun_type __f) : _Base(__f) {}
|
||||
};
|
||||
|
||||
template <class _Result, class _Tp, class _Arg>
|
||||
class const_mem_fun1_ref_t :
|
||||
public _Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref_const {
|
||||
typedef typename
|
||||
_Mem_fun_traits<_Result>::_STLP_TEMPLATE _Args1<_Tp,_Arg>::_Ref_const _Base;
|
||||
public:
|
||||
explicit const_mem_fun1_ref_t(typename _Base::__fun_type __f) : _Base(__f) {}
|
||||
};
|
||||
|
||||
template <class _Arg, class _Result>
|
||||
class pointer_to_unary_function :
|
||||
public _Ptr_fun1<_Result,_Arg> {
|
||||
typedef typename
|
||||
_Ptr_fun1<_Result,_Arg>::__fun_type __fun_type;
|
||||
public:
|
||||
explicit pointer_to_unary_function(__fun_type __f)
|
||||
: _Ptr_fun1<_Result,_Arg>(__f) {}
|
||||
};
|
||||
|
||||
template <class _Arg1, class _Arg2, class _Result>
|
||||
class pointer_to_binary_function :
|
||||
public _Ptr_fun2<_Result,_Arg1,_Arg2> {
|
||||
typedef typename
|
||||
_Ptr_fun2<_Result,_Arg1,_Arg2>::__fun_type __fun_type;
|
||||
public:
|
||||
explicit pointer_to_binary_function(__fun_type __f)
|
||||
: _Ptr_fun2<_Result,_Arg1,_Arg2>(__f) {}
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template <class _Ret, class _Tp>
|
||||
class mem_fun_t : public unary_function<_Tp*,_Ret> {
|
||||
typedef _Ret (_Tp::*__fun_type)(void);
|
||||
public:
|
||||
explicit mem_fun_t(__fun_type __pf) : _M_f(__pf) {}
|
||||
_Ret operator()(_Tp* __p) const { return (__p->*_M_f)(); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Ret, class _Tp>
|
||||
class const_mem_fun_t : public unary_function<const _Tp*,_Ret> {
|
||||
typedef _Ret (_Tp::*__fun_type)(void) const;
|
||||
public:
|
||||
explicit const_mem_fun_t(__fun_type __pf) : _M_f(__pf) {}
|
||||
_Ret operator()(const _Tp* __p) const { return (__p->*_M_f)(); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Ret, class _Tp>
|
||||
class mem_fun_ref_t : public unary_function<_Tp,_Ret> {
|
||||
typedef _Ret (_Tp::*__fun_type)(void);
|
||||
public:
|
||||
explicit mem_fun_ref_t(__fun_type __pf) : _M_f(__pf) {}
|
||||
_Ret operator()(_Tp& __r) const { return (__r.*_M_f)(); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Ret, class _Tp>
|
||||
class const_mem_fun_ref_t : public unary_function<_Tp,_Ret> {
|
||||
typedef _Ret (_Tp::*__fun_type)(void) const;
|
||||
public:
|
||||
explicit const_mem_fun_ref_t(__fun_type __pf) : _M_f(__pf) {}
|
||||
_Ret operator()(const _Tp& __r) const { return (__r.*_M_f)(); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Ret, class _Tp, class _Arg>
|
||||
class mem_fun1_t : public binary_function<_Tp*,_Arg,_Ret> {
|
||||
typedef _Ret (_Tp::*__fun_type)(_Arg);
|
||||
public:
|
||||
explicit mem_fun1_t(__fun_type __pf) : _M_f(__pf) {}
|
||||
_Ret operator()(_Tp* __p, _Arg __x) const { return (__p->*_M_f)(__x); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Ret, class _Tp, class _Arg>
|
||||
class const_mem_fun1_t : public binary_function<const _Tp*,_Arg,_Ret> {
|
||||
typedef _Ret (_Tp::*__fun_type)(_Arg) const;
|
||||
public:
|
||||
explicit const_mem_fun1_t(__fun_type __pf) : _M_f(__pf) {}
|
||||
_Ret operator()(const _Tp* __p, _Arg __x) const
|
||||
{ return (__p->*_M_f)(__x); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Ret, class _Tp, class _Arg>
|
||||
class mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> {
|
||||
typedef _Ret (_Tp::*__fun_type)(_Arg);
|
||||
public:
|
||||
explicit mem_fun1_ref_t(__fun_type __pf) : _M_f(__pf) {}
|
||||
_Ret operator()(_Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Ret, class _Tp, class _Arg>
|
||||
class const_mem_fun1_ref_t : public binary_function<_Tp,_Arg,_Ret> {
|
||||
typedef _Ret (_Tp::*__fun_type)(_Arg) const;
|
||||
public:
|
||||
explicit const_mem_fun1_ref_t(__fun_type __pf) : _M_f(__pf) {}
|
||||
_Ret operator()(const _Tp& __r, _Arg __x) const { return (__r.*_M_f)(__x); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Arg, class _Result>
|
||||
class pointer_to_unary_function : public unary_function<_Arg, _Result> {
|
||||
protected:
|
||||
_Result (*_M_ptr)(_Arg);
|
||||
public:
|
||||
pointer_to_unary_function() {}
|
||||
explicit pointer_to_unary_function(_Result (*__x)(_Arg)) : _M_ptr(__x) {}
|
||||
_Result operator()(_Arg __x) const { return _M_ptr(__x); }
|
||||
};
|
||||
|
||||
template <class _Arg1, class _Arg2, class _Result>
|
||||
class pointer_to_binary_function :
|
||||
public binary_function<_Arg1,_Arg2,_Result> {
|
||||
protected:
|
||||
_Result (*_M_ptr)(_Arg1, _Arg2);
|
||||
public:
|
||||
pointer_to_binary_function() {}
|
||||
explicit pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2))
|
||||
: _M_ptr(__x) {}
|
||||
_Result operator()(_Arg1 __x, _Arg2 __y) const {
|
||||
return _M_ptr(__x, __y);
|
||||
}
|
||||
};
|
||||
|
||||
# if defined (_STLP_DONT_RETURN_VOID) && !defined (_STLP_NO_CLASS_PARTIAL_SPECIALIZATION)
|
||||
//Partial specializations for the void type
|
||||
template <class _Tp>
|
||||
class mem_fun_t<void, _Tp> : public unary_function<_Tp*,void> {
|
||||
typedef void (_Tp::*__fun_type)(void);
|
||||
public:
|
||||
explicit mem_fun_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {}
|
||||
void operator()(_Tp* __p) const { (__p->*_M_f)(); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
class const_mem_fun_t<void, _Tp> : public unary_function<const _Tp*,void> {
|
||||
typedef void (_Tp::*__fun_type)(void) const;
|
||||
public:
|
||||
explicit const_mem_fun_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {}
|
||||
void operator()(const _Tp* __p) const { (__p->*_M_f)(); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
class mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> {
|
||||
typedef void (_Tp::*__fun_type)(void);
|
||||
public:
|
||||
explicit mem_fun_ref_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {}
|
||||
void operator()(_Tp& __r) const { (__r.*_M_f)(); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
class const_mem_fun_ref_t<void, _Tp> : public unary_function<_Tp,void> {
|
||||
typedef void (_Tp::*__fun_type)(void) const;
|
||||
public:
|
||||
explicit const_mem_fun_ref_t _STLP_PSPEC2(void,_Tp) (__fun_type __pf) : _M_f(__pf) {}
|
||||
void operator()(const _Tp& __r) const { (__r.*_M_f)(); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Arg>
|
||||
class mem_fun1_t<void, _Tp, _Arg> : public binary_function<_Tp*,_Arg,void> {
|
||||
typedef void (_Tp::*__fun_type)(_Arg);
|
||||
public:
|
||||
explicit mem_fun1_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {}
|
||||
void operator()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Arg>
|
||||
class const_mem_fun1_t<void, _Tp, _Arg>
|
||||
: public binary_function<const _Tp*,_Arg,void> {
|
||||
typedef void (_Tp::*__fun_type)(_Arg) const;
|
||||
public:
|
||||
explicit const_mem_fun1_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {}
|
||||
void operator()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Arg>
|
||||
class mem_fun1_ref_t<void, _Tp, _Arg>
|
||||
: public binary_function<_Tp,_Arg,void> {
|
||||
typedef void (_Tp::*__fun_type)(_Arg);
|
||||
public:
|
||||
explicit mem_fun1_ref_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {}
|
||||
void operator()(_Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Arg>
|
||||
class const_mem_fun1_ref_t<void, _Tp, _Arg>
|
||||
: public binary_function<_Tp,_Arg,void> {
|
||||
typedef void (_Tp::*__fun_type)(_Arg) const;
|
||||
public:
|
||||
explicit const_mem_fun1_ref_t _STLP_PSPEC3(void,_Tp,_Arg) (__fun_type __pf) : _M_f(__pf) {}
|
||||
void operator()(const _Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); }
|
||||
private:
|
||||
__fun_type _M_f;
|
||||
};
|
||||
|
||||
template <class _Arg>
|
||||
class pointer_to_unary_function<_Arg, void> : public unary_function<_Arg, void> {
|
||||
typedef void (*__fun_type)(_Arg);
|
||||
__fun_type _M_ptr;
|
||||
public:
|
||||
pointer_to_unary_function() {}
|
||||
explicit pointer_to_unary_function(__fun_type __x) : _M_ptr(__x) {}
|
||||
void operator()(_Arg __x) const { _M_ptr(__x); }
|
||||
};
|
||||
|
||||
template <class _Arg1, class _Arg2>
|
||||
class pointer_to_binary_function<_Arg1, _Arg2, void> : public binary_function<_Arg1,_Arg2,void> {
|
||||
typedef void (*__fun_type)(_Arg1, _Arg2);
|
||||
__fun_type _M_ptr;
|
||||
public:
|
||||
pointer_to_binary_function() {}
|
||||
explicit pointer_to_binary_function(__fun_type __x) : _M_ptr(__x) {}
|
||||
void operator()(_Arg1 __x, _Arg2 __y) const { _M_ptr(__x, __y); }
|
||||
};
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_MEMBER_POINTER_PARAM_BUG)
|
||||
// Mem_fun adaptor helper functions. There are only two:
|
||||
// mem_fun and mem_fun_ref. (mem_fun1 and mem_fun1_ref
|
||||
// are provided for backward compatibility, but they are no longer
|
||||
// part of the C++ standard.)
|
||||
|
||||
template <class _Result, class _Tp>
|
||||
inline mem_fun_t<_Result,_Tp>
|
||||
mem_fun(_Result (_Tp::*__f)()) { return mem_fun_t<_Result,_Tp>(__f); }
|
||||
|
||||
template <class _Result, class _Tp>
|
||||
inline const_mem_fun_t<_Result,_Tp>
|
||||
mem_fun(_Result (_Tp::*__f)() const) { return const_mem_fun_t<_Result,_Tp>(__f); }
|
||||
|
||||
template <class _Result, class _Tp>
|
||||
inline mem_fun_ref_t<_Result,_Tp>
|
||||
mem_fun_ref(_Result (_Tp::*__f)()) { return mem_fun_ref_t<_Result,_Tp>(__f); }
|
||||
|
||||
template <class _Result, class _Tp>
|
||||
inline const_mem_fun_ref_t<_Result,_Tp>
|
||||
mem_fun_ref(_Result (_Tp::*__f)() const) { return const_mem_fun_ref_t<_Result,_Tp>(__f); }
|
||||
|
||||
template <class _Result, class _Tp, class _Arg>
|
||||
inline mem_fun1_t<_Result,_Tp,_Arg>
|
||||
mem_fun(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_t<_Result,_Tp,_Arg>(__f); }
|
||||
|
||||
template <class _Result, class _Tp, class _Arg>
|
||||
inline const_mem_fun1_t<_Result,_Tp,_Arg>
|
||||
mem_fun(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_t<_Result,_Tp,_Arg>(__f); }
|
||||
|
||||
template <class _Result, class _Tp, class _Arg>
|
||||
inline mem_fun1_ref_t<_Result,_Tp,_Arg>
|
||||
mem_fun_ref(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); }
|
||||
|
||||
template <class _Result, class _Tp, class _Arg>
|
||||
inline const_mem_fun1_ref_t<_Result,_Tp,_Arg>
|
||||
mem_fun_ref(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); }
|
||||
|
||||
# if !(defined (_STLP_NO_EXTENSIONS) || defined (_STLP_NO_ANACHRONISMS))
|
||||
// mem_fun1 and mem_fun1_ref are no longer part of the C++ standard,
|
||||
// but they are provided for backward compatibility.
|
||||
template <class _Result, class _Tp, class _Arg>
|
||||
inline mem_fun1_t<_Result,_Tp,_Arg>
|
||||
mem_fun1(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_t<_Result,_Tp,_Arg>(__f); }
|
||||
|
||||
template <class _Result, class _Tp, class _Arg>
|
||||
inline const_mem_fun1_t<_Result,_Tp,_Arg>
|
||||
mem_fun1(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_t<_Result,_Tp,_Arg>(__f); }
|
||||
|
||||
template <class _Result, class _Tp, class _Arg>
|
||||
inline mem_fun1_ref_t<_Result,_Tp,_Arg>
|
||||
mem_fun1_ref(_Result (_Tp::*__f)(_Arg)) { return mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); }
|
||||
|
||||
template <class _Result, class _Tp, class _Arg>
|
||||
inline const_mem_fun1_ref_t<_Result,_Tp,_Arg>
|
||||
mem_fun1_ref(_Result (_Tp::*__f)(_Arg) const) { return const_mem_fun1_ref_t<_Result,_Tp,_Arg>(__f); }
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
template <class _Arg, class _Result>
|
||||
inline pointer_to_unary_function<_Arg, _Result>
|
||||
ptr_fun(_Result (*__f)(_Arg))
|
||||
{ return pointer_to_unary_function<_Arg, _Result>(__f); }
|
||||
|
||||
template <class _Arg1, class _Arg2, class _Result>
|
||||
inline pointer_to_binary_function<_Arg1,_Arg2,_Result>
|
||||
ptr_fun(_Result (*__f)(_Arg1, _Arg2))
|
||||
{ return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f); }
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
217
extern/STLport/5.2.1/stlport/stl/_function_base.h
vendored
Normal file
217
extern/STLport/5.2.1/stlport/stl/_function_base.h
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996-1998
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
|
||||
#define _STLP_INTERNAL_FUNCTION_BASE_H
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_TYPE_TRAITS_H)
|
||||
# include <stl/type_traits.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _Arg, class _Result>
|
||||
struct unary_function {
|
||||
typedef _Arg argument_type;
|
||||
typedef _Result result_type;
|
||||
#if !defined (__BORLANDC__) || (__BORLANDC__ < 0x580)
|
||||
protected:
|
||||
/* This class purpose is to be derived but it is not polymorphic so users should never try
|
||||
* to destroy an instance of it directly. The protected non-virtual destructor make this
|
||||
* fact obvious at compilation time. */
|
||||
~unary_function() {}
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _Arg1, class _Arg2, class _Result>
|
||||
struct binary_function {
|
||||
typedef _Arg1 first_argument_type;
|
||||
typedef _Arg2 second_argument_type;
|
||||
typedef _Result result_type;
|
||||
#if !defined (__BORLANDC__) || (__BORLANDC__ < 0x580)
|
||||
protected:
|
||||
/* See unary_function comment. */
|
||||
~binary_function() {}
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct equal_to : public binary_function<_Tp, _Tp, bool> {
|
||||
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; }
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct less : public binary_function<_Tp,_Tp,bool>
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
/* less is the default template parameter for many STL containers, to fully use
|
||||
* the move constructor feature we need to know that the default less is just a
|
||||
* functor.
|
||||
*/
|
||||
, public __stlport_class<less<_Tp> >
|
||||
#endif
|
||||
{
|
||||
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; }
|
||||
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(less<_Tp>& __x) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
template <class _Tp>
|
||||
struct __type_traits<less<_Tp> > {
|
||||
#if !defined (__BORLANDC__)
|
||||
typedef typename _IsSTLportClass<less<_Tp> >::_Ret _STLportLess;
|
||||
#else
|
||||
enum { _Is = _IsSTLportClass<less<_Tp> >::_Is };
|
||||
typedef typename __bool2type<_Is>::_Ret _STLportLess;
|
||||
#endif
|
||||
typedef _STLportLess has_trivial_default_constructor;
|
||||
typedef _STLportLess has_trivial_copy_constructor;
|
||||
typedef _STLportLess has_trivial_assignment_operator;
|
||||
typedef _STLportLess has_trivial_destructor;
|
||||
typedef _STLportLess is_POD_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Tp>
|
||||
less<_Tp> __less(_Tp* ) { return less<_Tp>(); }
|
||||
|
||||
template <class _Tp>
|
||||
equal_to<_Tp> __equal_to(_Tp* ) { return equal_to<_Tp>(); }
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _Tp>
|
||||
struct plus : public binary_function<_Tp, _Tp, _Tp> {
|
||||
_Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; }
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct minus : public binary_function<_Tp, _Tp, _Tp> {
|
||||
_Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x - __y; }
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Tp>
|
||||
plus<_Tp> __plus(_Tp* ) { return plus<_Tp>(); }
|
||||
|
||||
template <class _Tp>
|
||||
minus<_Tp> __minus(_Tp* ) { return minus<_Tp>(); }
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _Tp>
|
||||
struct multiplies : public binary_function<_Tp, _Tp, _Tp> {
|
||||
_Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x * __y; }
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Pair>
|
||||
struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> {
|
||||
const typename _Pair::first_type& operator()(const _Pair& __x) const {
|
||||
return __x.first;
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Pair>
|
||||
struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type> {
|
||||
const typename _Pair::second_type& operator()(const _Pair& __x) const {
|
||||
return __x.second;
|
||||
}
|
||||
};
|
||||
|
||||
// project1st and project2nd are extensions: they are not part of the standard
|
||||
template <class _Arg1, class _Arg2>
|
||||
struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1> {
|
||||
_Arg1 operator()(const _Arg1& __x, const _Arg2&) const { return __x; }
|
||||
};
|
||||
|
||||
template <class _Arg1, class _Arg2>
|
||||
struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2> {
|
||||
_Arg2 operator()(const _Arg1&, const _Arg2& __y) const { return __y; }
|
||||
};
|
||||
|
||||
#if defined (_STLP_MULTI_CONST_TEMPLATE_ARG_BUG)
|
||||
// fbp : sort of select1st just for maps
|
||||
template <class _Pair, class _Whatever>
|
||||
// JDJ (CW Pro1 doesn't like const when first_type is also const)
|
||||
struct __Select1st_hint : public unary_function<_Pair, _Whatever> {
|
||||
const _Whatever& operator () (const _Pair& __x) const { return __x.first; }
|
||||
};
|
||||
# define _STLP_SELECT1ST(__x,__y) _STLP_PRIV __Select1st_hint< __x, __y >
|
||||
#else
|
||||
# define _STLP_SELECT1ST(__x, __y) _STLP_PRIV _Select1st< __x >
|
||||
#endif
|
||||
|
||||
template <class _Tp>
|
||||
struct _Identity : public unary_function<_Tp,_Tp> {
|
||||
const _Tp& operator()(const _Tp& __x) const { return __x; }
|
||||
};
|
||||
|
||||
template <class _Result, class _Argument>
|
||||
struct _Constant_unary_fun {
|
||||
typedef _Argument argument_type;
|
||||
typedef _Result result_type;
|
||||
result_type _M_val;
|
||||
|
||||
_Constant_unary_fun(const result_type& __v) : _M_val(__v) {}
|
||||
const result_type& operator()(const _Argument&) const { return _M_val; }
|
||||
};
|
||||
|
||||
template <class _Result, class _Arg1, class _Arg2>
|
||||
struct _Constant_binary_fun {
|
||||
typedef _Arg1 first_argument_type;
|
||||
typedef _Arg2 second_argument_type;
|
||||
typedef _Result result_type;
|
||||
_Result _M_val;
|
||||
|
||||
_Constant_binary_fun(const _Result& __v) : _M_val(__v) {}
|
||||
const result_type& operator()(const _Arg1&, const _Arg2&) const {
|
||||
return _M_val;
|
||||
}
|
||||
};
|
||||
|
||||
// identity_element (not part of the C++ standard).
|
||||
template <class _Tp> inline _Tp __identity_element(plus<_Tp>) { return _Tp(0); }
|
||||
template <class _Tp> inline _Tp __identity_element(multiplies<_Tp>) { return _Tp(1); }
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_FUNCTION_BASE_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
146
extern/STLport/5.2.1/stlport/stl/_hash_fun.h
vendored
Normal file
146
extern/STLport/5.2.1/stlport/stl/_hash_fun.h
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 1996-1998
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Silicon Graphics makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Hewlett-Packard Company makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_HASH_FUN_H
|
||||
#define _STLP_HASH_FUN_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSTDDEF
|
||||
# include <stl/_cstddef.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _Key> struct hash { };
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
inline size_t __stl_hash_string(const char* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
unsigned long __h = 0;
|
||||
for ( ; *__s; ++__s)
|
||||
__h = 5*__h + *__s;
|
||||
|
||||
return size_t(__h);
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct hash<char*> {
|
||||
size_t operator()(const char* __s) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return _STLP_PRIV __stl_hash_string(__s);
|
||||
}
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct hash<const char*> {
|
||||
size_t operator()(const char* __s) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return _STLP_PRIV __stl_hash_string(__s);
|
||||
}
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL struct hash<char> {
|
||||
size_t operator()(char __x) const { return __x; }
|
||||
};
|
||||
_STLP_TEMPLATE_NULL struct hash<unsigned char> {
|
||||
size_t operator()(unsigned char __x) const { return __x; }
|
||||
};
|
||||
#if !defined (_STLP_NO_SIGNED_BUILTINS)
|
||||
_STLP_TEMPLATE_NULL struct hash<signed char> {
|
||||
size_t operator()(unsigned char __x) const { return __x; }
|
||||
};
|
||||
#endif
|
||||
_STLP_TEMPLATE_NULL struct hash<short> {
|
||||
size_t operator()(short __x) const { return __x; }
|
||||
};
|
||||
_STLP_TEMPLATE_NULL struct hash<unsigned short> {
|
||||
size_t operator()(unsigned short __x) const { return __x; }
|
||||
};
|
||||
_STLP_TEMPLATE_NULL struct hash<int> {
|
||||
size_t operator()(int __x) const { return __x; }
|
||||
};
|
||||
|
||||
#if !defined (_STLP_MSVC) || (_STLP_MSVC < 1300) || defined (_WIN64)
|
||||
_STLP_TEMPLATE_NULL struct hash<unsigned int> {
|
||||
size_t operator()(unsigned int __x) const { return __x; }
|
||||
};
|
||||
#else
|
||||
/* MSVC .Net since 2002 has a 64 bits portability warning feature. typedef
|
||||
* like size_t are tagged as potential 64 bits variables making them different from
|
||||
* unsigned int. To avoid the warning when a hash container is instanciated with
|
||||
* the size_t key we prefer to grant the size_t specialization rather than the
|
||||
* unsigned int one.
|
||||
*/
|
||||
_STLP_TEMPLATE_NULL struct hash<size_t> {
|
||||
size_t operator()(size_t __x) const { return __x; }
|
||||
};
|
||||
#endif
|
||||
|
||||
_STLP_TEMPLATE_NULL struct hash<long> {
|
||||
size_t operator()(long __x) const { return __x; }
|
||||
};
|
||||
_STLP_TEMPLATE_NULL struct hash<unsigned long> {
|
||||
size_t operator()(unsigned long __x) const { return __x; }
|
||||
};
|
||||
|
||||
#if defined (_STLP_LONG_LONG)
|
||||
_STLP_TEMPLATE_NULL struct hash<_STLP_LONG_LONG> {
|
||||
size_t operator()(_STLP_LONG_LONG x) const { return (size_t)x; }
|
||||
};
|
||||
_STLP_TEMPLATE_NULL struct hash<unsigned _STLP_LONG_LONG> {
|
||||
size_t operator()(unsigned _STLP_LONG_LONG x) const { return (size_t)x; }
|
||||
};
|
||||
#endif
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct hash<void *>
|
||||
{
|
||||
union __vp {
|
||||
size_t s;
|
||||
void *p;
|
||||
};
|
||||
|
||||
size_t operator()(void *__x) const
|
||||
{
|
||||
__vp vp;
|
||||
vp.p = __x;
|
||||
return vp.s;
|
||||
}
|
||||
};
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_HASH_FUN_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
500
extern/STLport/5.2.1/stlport/stl/_hash_map.h
vendored
Normal file
500
extern/STLport/5.2.1/stlport/stl/_hash_map.h
vendored
Normal file
@@ -0,0 +1,500 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_HASH_MAP_H
|
||||
#define _STLP_INTERNAL_HASH_MAP_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_HASHTABLE_H
|
||||
# include <stl/_hashtable.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
//Specific iterator traits creation
|
||||
_STLP_CREATE_HASH_ITERATOR_TRAITS(HashMapTraitsT, traits)
|
||||
|
||||
template <class _Key, class _Tp, _STLP_DFL_TMPL_PARAM(_HashFcn,hash<_Key>),
|
||||
_STLP_DFL_TMPL_PARAM(_EqualKey,equal_to<_Key>),
|
||||
_STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) >
|
||||
class hash_map
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
||||
: public __stlport_class<hash_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> >
|
||||
#endif
|
||||
{
|
||||
private:
|
||||
typedef hash_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self;
|
||||
public:
|
||||
typedef _Key key_type;
|
||||
typedef _Tp data_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<_STLP_CONST key_type, data_type> value_type;
|
||||
private:
|
||||
//Specific iterator traits creation
|
||||
typedef _STLP_PRIV _HashMapTraitsT<value_type> _HashMapTraits;
|
||||
|
||||
public:
|
||||
typedef hashtable<value_type, key_type, _HashFcn, _HashMapTraits,
|
||||
_STLP_SELECT1ST(value_type, _Key), _EqualKey, _Alloc > _Ht;
|
||||
|
||||
typedef typename _Ht::hasher hasher;
|
||||
typedef typename _Ht::key_equal key_equal;
|
||||
|
||||
typedef typename _Ht::size_type size_type;
|
||||
typedef typename _Ht::difference_type difference_type;
|
||||
typedef typename _Ht::pointer pointer;
|
||||
typedef typename _Ht::const_pointer const_pointer;
|
||||
typedef typename _Ht::reference reference;
|
||||
typedef typename _Ht::const_reference const_reference;
|
||||
|
||||
typedef typename _Ht::iterator iterator;
|
||||
typedef typename _Ht::const_iterator const_iterator;
|
||||
|
||||
typedef typename _Ht::allocator_type allocator_type;
|
||||
|
||||
hasher hash_funct() const { return _M_ht.hash_funct(); }
|
||||
key_equal key_eq() const { return _M_ht.key_eq(); }
|
||||
allocator_type get_allocator() const { return _M_ht.get_allocator(); }
|
||||
|
||||
private:
|
||||
_Ht _M_ht;
|
||||
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
||||
public:
|
||||
hash_map() : _M_ht(0, hasher(), key_equal(), allocator_type()) {}
|
||||
explicit hash_map(size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
|
||||
hash_map(size_type __n, const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
|
||||
hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a) {}
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
hash_map(__move_source<_Self> src)
|
||||
: _M_ht(__move_source<_Ht>(src.get()._M_ht)) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
template <class _InputIterator>
|
||||
hash_map(_InputIterator __f, _InputIterator __l)
|
||||
: _M_ht(0, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
|
||||
template <class _InputIterator>
|
||||
hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql)
|
||||
: _M_ht(__n, __hf, __eql, allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
# endif
|
||||
template <class _InputIterator>
|
||||
hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
#else
|
||||
hash_map(const value_type* __f, const value_type* __l)
|
||||
: _M_ht(0, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_map(const value_type* __f, const value_type* __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_map(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_map(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
hash_map(const_iterator __f, const_iterator __l)
|
||||
: _M_ht(0, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_map(const_iterator __f, const_iterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_map(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_map(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
#endif /*_STLP_MEMBER_TEMPLATES */
|
||||
|
||||
public:
|
||||
size_type size() const { return _M_ht.size(); }
|
||||
size_type max_size() const { return _M_ht.max_size(); }
|
||||
bool empty() const { return _M_ht.empty(); }
|
||||
void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); }
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(_Self& __x) { swap(__x); }
|
||||
#endif
|
||||
iterator begin() { return _M_ht.begin(); }
|
||||
iterator end() { return _M_ht.end(); }
|
||||
const_iterator begin() const { return _M_ht.begin(); }
|
||||
const_iterator end() const { return _M_ht.end(); }
|
||||
|
||||
public:
|
||||
pair<iterator,bool> insert(const value_type& __obj)
|
||||
{ return _M_ht.insert_unique(__obj); }
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __f, _InputIterator __l)
|
||||
{ _M_ht.insert_unique(__f,__l); }
|
||||
#else
|
||||
void insert(const value_type* __f, const value_type* __l)
|
||||
{ _M_ht.insert_unique(__f,__l); }
|
||||
void insert(const_iterator __f, const_iterator __l)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
#endif /*_STLP_MEMBER_TEMPLATES */
|
||||
pair<iterator,bool> insert_noresize(const value_type& __obj)
|
||||
{ return _M_ht.insert_unique_noresize(__obj); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator find(const _KT& __key) { return _M_ht.find(__key); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator find(const _KT& __key) const { return _M_ht.find(__key); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
_Tp& operator[](const _KT& __key) {
|
||||
iterator __it = _M_ht.find(__key);
|
||||
return (__it == _M_ht.end() ?
|
||||
_M_ht._M_insert(value_type(__key, _STLP_DEFAULT_CONSTRUCTED(_Tp))).second :
|
||||
(*__it).second );
|
||||
}
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type count(const _KT& __key) const { return _M_ht.count(__key); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<iterator, iterator> equal_range(const _KT& __key)
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<const_iterator, const_iterator> equal_range(const _KT& __key) const
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type erase(const _KT& __key) {return _M_ht.erase(__key); }
|
||||
void erase(iterator __it) { _M_ht.erase(__it); }
|
||||
void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
|
||||
void clear() { _M_ht.clear(); }
|
||||
|
||||
void resize(size_type __hint) { _M_ht.resize(__hint); }
|
||||
size_type bucket_count() const { return _M_ht.bucket_count(); }
|
||||
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
|
||||
size_type elems_in_bucket(size_type __n) const
|
||||
{ return _M_ht.elems_in_bucket(__n); }
|
||||
};
|
||||
|
||||
//Specific iterator traits creation
|
||||
_STLP_CREATE_HASH_ITERATOR_TRAITS(HashMultimapTraitsT, traits)
|
||||
|
||||
template <class _Key, class _Tp, _STLP_DFL_TMPL_PARAM(_HashFcn,hash<_Key>),
|
||||
_STLP_DFL_TMPL_PARAM(_EqualKey,equal_to<_Key>),
|
||||
_STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) >
|
||||
class hash_multimap
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
||||
: public __stlport_class<hash_multimap<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> >
|
||||
#endif
|
||||
{
|
||||
private:
|
||||
typedef hash_multimap<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self;
|
||||
public:
|
||||
typedef _Key key_type;
|
||||
typedef _Tp data_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<_STLP_CONST key_type, data_type> value_type;
|
||||
private:
|
||||
//Specific iterator traits creation
|
||||
typedef _STLP_PRIV _HashMultimapTraitsT<value_type> _HashMultimapTraits;
|
||||
|
||||
public:
|
||||
typedef hashtable<value_type, key_type, _HashFcn, _HashMultimapTraits,
|
||||
_STLP_SELECT1ST(value_type, _Key), _EqualKey, _Alloc > _Ht;
|
||||
|
||||
typedef typename _Ht::hasher hasher;
|
||||
typedef typename _Ht::key_equal key_equal;
|
||||
|
||||
typedef typename _Ht::size_type size_type;
|
||||
typedef typename _Ht::difference_type difference_type;
|
||||
typedef typename _Ht::pointer pointer;
|
||||
typedef typename _Ht::const_pointer const_pointer;
|
||||
typedef typename _Ht::reference reference;
|
||||
typedef typename _Ht::const_reference const_reference;
|
||||
|
||||
typedef typename _Ht::iterator iterator;
|
||||
typedef typename _Ht::const_iterator const_iterator;
|
||||
|
||||
typedef typename _Ht::allocator_type allocator_type;
|
||||
|
||||
hasher hash_funct() const { return _M_ht.hash_funct(); }
|
||||
key_equal key_eq() const { return _M_ht.key_eq(); }
|
||||
allocator_type get_allocator() const { return _M_ht.get_allocator(); }
|
||||
|
||||
private:
|
||||
_Ht _M_ht;
|
||||
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
||||
public:
|
||||
hash_multimap() : _M_ht(0, hasher(), key_equal(), allocator_type()) {}
|
||||
explicit hash_multimap(size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
|
||||
hash_multimap(size_type __n, const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
|
||||
hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a) {}
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
hash_multimap(__move_source<_Self> src)
|
||||
: _M_ht(__move_source<_Ht>(src.get()._M_ht)) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
template <class _InputIterator>
|
||||
hash_multimap(_InputIterator __f, _InputIterator __l)
|
||||
: _M_ht(0, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
|
||||
template <class _InputIterator>
|
||||
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql)
|
||||
: _M_ht(__n, __hf, __eql, allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
# endif
|
||||
template <class _InputIterator>
|
||||
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
|
||||
#else
|
||||
hash_multimap(const value_type* __f, const value_type* __l)
|
||||
: _M_ht(0, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multimap(const value_type* __f, const value_type* __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multimap(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multimap(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
|
||||
hash_multimap(const_iterator __f, const_iterator __l)
|
||||
: _M_ht(0, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multimap(const_iterator __f, const_iterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
#endif /*_STLP_MEMBER_TEMPLATES */
|
||||
|
||||
public:
|
||||
size_type size() const { return _M_ht.size(); }
|
||||
size_type max_size() const { return _M_ht.max_size(); }
|
||||
bool empty() const { return _M_ht.empty(); }
|
||||
void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); }
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(_Self& __x) { swap(__x); }
|
||||
#endif
|
||||
|
||||
iterator begin() { return _M_ht.begin(); }
|
||||
iterator end() { return _M_ht.end(); }
|
||||
const_iterator begin() const { return _M_ht.begin(); }
|
||||
const_iterator end() const { return _M_ht.end(); }
|
||||
|
||||
public:
|
||||
iterator insert(const value_type& __obj)
|
||||
{ return _M_ht.insert_equal(__obj); }
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __f, _InputIterator __l)
|
||||
{ _M_ht.insert_equal(__f,__l); }
|
||||
#else
|
||||
void insert(const value_type* __f, const value_type* __l) {
|
||||
_M_ht.insert_equal(__f,__l);
|
||||
}
|
||||
void insert(const_iterator __f, const_iterator __l)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
#endif /*_STLP_MEMBER_TEMPLATES */
|
||||
iterator insert_noresize(const value_type& __obj)
|
||||
{ return _M_ht.insert_equal_noresize(__obj); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator find(const _KT& __key) { return _M_ht.find(__key); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator find(const _KT& __key) const { return _M_ht.find(__key); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type count(const _KT& __key) const { return _M_ht.count(__key); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<iterator, iterator>
|
||||
equal_range(const _KT& __key) { return _M_ht.equal_range(__key); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<const_iterator, const_iterator>
|
||||
equal_range(const _KT& __key) const { return _M_ht.equal_range(__key); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type erase(const _KT& __key) {return _M_ht.erase(__key); }
|
||||
void erase(iterator __it) { _M_ht.erase(__it); }
|
||||
void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
|
||||
void clear() { _M_ht.clear(); }
|
||||
|
||||
public:
|
||||
void resize(size_type __hint) { _M_ht.resize(__hint); }
|
||||
size_type bucket_count() const { return _M_ht.bucket_count(); }
|
||||
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
|
||||
size_type elems_in_bucket(size_type __n) const
|
||||
{ return _M_ht.elems_in_bucket(__n); }
|
||||
};
|
||||
|
||||
#define _STLP_TEMPLATE_HEADER template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
|
||||
#define _STLP_TEMPLATE_CONTAINER hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>
|
||||
#include <stl/_relops_hash_cont.h>
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#define _STLP_TEMPLATE_CONTAINER hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>
|
||||
#include <stl/_relops_hash_cont.h>
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#undef _STLP_TEMPLATE_HEADER
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
# if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
|
||||
struct __move_traits<hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > :
|
||||
_STLP_PRIV __move_traits_help<typename hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>::_Ht>
|
||||
{};
|
||||
|
||||
template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
|
||||
struct __move_traits<hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > :
|
||||
_STLP_PRIV __move_traits_help<typename hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc>::_Ht>
|
||||
{};
|
||||
# endif
|
||||
|
||||
// Specialization of insert_iterator so that it will work for hash_map
|
||||
// and hash_multimap.
|
||||
template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
|
||||
class insert_iterator<hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
|
||||
protected:
|
||||
typedef hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
|
||||
_Container* container;
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
typedef output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
|
||||
insert_iterator(_Container& __x) : container(&__x) {}
|
||||
insert_iterator(_Container& __x, typename _Container::iterator)
|
||||
: container(&__x) {}
|
||||
insert_iterator<_Container>&
|
||||
operator=(const typename _Container::value_type& __val) {
|
||||
container->insert(__val);
|
||||
return *this;
|
||||
}
|
||||
insert_iterator<_Container>& operator*() { return *this; }
|
||||
insert_iterator<_Container>& operator++() { return *this; }
|
||||
insert_iterator<_Container>& operator++(int) { return *this; }
|
||||
};
|
||||
|
||||
template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
|
||||
class insert_iterator<hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
|
||||
protected:
|
||||
typedef hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
|
||||
_Container* container;
|
||||
typename _Container::iterator iter;
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
typedef output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
|
||||
insert_iterator(_Container& __x) : container(&__x) {}
|
||||
insert_iterator(_Container& __x, typename _Container::iterator)
|
||||
: container(&__x) {}
|
||||
insert_iterator<_Container>&
|
||||
operator=(const typename _Container::value_type& __val) {
|
||||
container->insert(__val);
|
||||
return *this;
|
||||
}
|
||||
insert_iterator<_Container>& operator*() { return *this; }
|
||||
insert_iterator<_Container>& operator++() { return *this; }
|
||||
insert_iterator<_Container>& operator++(int) { return *this; }
|
||||
};
|
||||
#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_HASH_MAP_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
495
extern/STLport/5.2.1/stlport/stl/_hash_set.h
vendored
Normal file
495
extern/STLport/5.2.1/stlport/stl/_hash_set.h
vendored
Normal file
@@ -0,0 +1,495 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_HASH_SET_H
|
||||
#define _STLP_INTERNAL_HASH_SET_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_HASHTABLE_H
|
||||
# include <stl/_hashtable.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
//Specific iterator traits creation
|
||||
_STLP_CREATE_HASH_ITERATOR_TRAITS(HashSetTraitsT, Const_traits)
|
||||
|
||||
template <class _Value, _STLP_DFL_TMPL_PARAM(_HashFcn,hash<_Value>),
|
||||
_STLP_DFL_TMPL_PARAM(_EqualKey, equal_to<_Value>),
|
||||
_STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Value>) >
|
||||
class hash_set
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
||||
: public __stlport_class<hash_set<_Value, _HashFcn, _EqualKey, _Alloc> >
|
||||
#endif
|
||||
{
|
||||
typedef hash_set<_Value, _HashFcn, _EqualKey, _Alloc> _Self;
|
||||
//Specific iterator traits creation
|
||||
typedef _STLP_PRIV _HashSetTraitsT<_Value> _HashSetTraits;
|
||||
public:
|
||||
typedef hashtable<_Value, _Value, _HashFcn,
|
||||
_HashSetTraits, _STLP_PRIV _Identity<_Value>, _EqualKey, _Alloc> _Ht;
|
||||
public:
|
||||
typedef typename _Ht::key_type key_type;
|
||||
typedef typename _Ht::value_type value_type;
|
||||
typedef typename _Ht::hasher hasher;
|
||||
typedef typename _Ht::key_equal key_equal;
|
||||
|
||||
typedef typename _Ht::size_type size_type;
|
||||
typedef typename _Ht::difference_type difference_type;
|
||||
typedef typename _Ht::pointer pointer;
|
||||
typedef typename _Ht::const_pointer const_pointer;
|
||||
typedef typename _Ht::reference reference;
|
||||
typedef typename _Ht::const_reference const_reference;
|
||||
|
||||
typedef typename _Ht::iterator iterator;
|
||||
typedef typename _Ht::const_iterator const_iterator;
|
||||
|
||||
typedef typename _Ht::allocator_type allocator_type;
|
||||
|
||||
hasher hash_funct() const { return _M_ht.hash_funct(); }
|
||||
key_equal key_eq() const { return _M_ht.key_eq(); }
|
||||
allocator_type get_allocator() const { return _M_ht.get_allocator(); }
|
||||
|
||||
private:
|
||||
_Ht _M_ht;
|
||||
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
||||
|
||||
public:
|
||||
hash_set()
|
||||
: _M_ht(0, hasher(), key_equal(), allocator_type()) {}
|
||||
explicit hash_set(size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
|
||||
hash_set(size_type __n, const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
#else
|
||||
hash_set(size_type __n, const hasher& __hf, const key_equal& __eql)
|
||||
: _M_ht(__n, __hf, __eql, allocator_type()) {}
|
||||
hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a)
|
||||
#endif
|
||||
: _M_ht(__n, __hf, __eql, __a) {}
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
hash_set(__move_source<_Self> src)
|
||||
: _M_ht(__move_source<_Ht>(src.get()._M_ht)) {}
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
hash_set(_InputIterator __f, _InputIterator __l)
|
||||
: _M_ht(0, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_set(_InputIterator __f, _InputIterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
|
||||
template <class _InputIterator>
|
||||
hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql)
|
||||
: _M_ht(__n, __hf, __eql, allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
# endif
|
||||
#else
|
||||
hash_set(const value_type* __f, const value_type* __l)
|
||||
: _M_ht(0, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_set(const value_type* __f, const value_type* __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_set(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_set(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
hash_set(const_iterator __f, const_iterator __l)
|
||||
: _M_ht(0, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_set(const_iterator __f, const_iterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_set(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
hash_set(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
#endif /*_STLP_MEMBER_TEMPLATES */
|
||||
|
||||
public:
|
||||
size_type size() const { return _M_ht.size(); }
|
||||
size_type max_size() const { return _M_ht.max_size(); }
|
||||
bool empty() const { return _M_ht.empty(); }
|
||||
void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); }
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(_Self& __x) { swap(__x); }
|
||||
#endif
|
||||
|
||||
iterator begin() { return _M_ht.begin(); }
|
||||
iterator end() { return _M_ht.end(); }
|
||||
const_iterator begin() const { return _M_ht.begin(); }
|
||||
const_iterator end() const { return _M_ht.end(); }
|
||||
|
||||
public:
|
||||
pair<iterator, bool> insert(const value_type& __obj)
|
||||
{ return _M_ht.insert_unique(__obj); }
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __f, _InputIterator __l)
|
||||
#else
|
||||
void insert(const_iterator __f, const_iterator __l)
|
||||
{_M_ht.insert_unique(__f, __l); }
|
||||
void insert(const value_type* __f, const value_type* __l)
|
||||
#endif
|
||||
{ _M_ht.insert_unique(__f,__l); }
|
||||
|
||||
pair<iterator, bool> insert_noresize(const value_type& __obj)
|
||||
{ return _M_ht.insert_unique_noresize(__obj); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator find(const _KT& __key) { return _M_ht.find(__key); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator find(const _KT& __key) const { return _M_ht.find(__key); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type count(const _KT& __key) const { return _M_ht.count(__key); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<iterator, iterator> equal_range(const _KT& __key)
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<const_iterator, const_iterator> equal_range(const _KT& __key) const
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type erase(const _KT& __key) {return _M_ht.erase(__key); }
|
||||
void erase(iterator __it) { _M_ht.erase(__it); }
|
||||
void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
|
||||
void clear() { _M_ht.clear(); }
|
||||
|
||||
public:
|
||||
void resize(size_type __hint) { _M_ht.resize(__hint); }
|
||||
size_type bucket_count() const { return _M_ht.bucket_count(); }
|
||||
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
|
||||
size_type elems_in_bucket(size_type __n) const
|
||||
{ return _M_ht.elems_in_bucket(__n); }
|
||||
};
|
||||
|
||||
//Specific iterator traits creation
|
||||
_STLP_CREATE_HASH_ITERATOR_TRAITS(HashMultisetTraitsT, Const_traits)
|
||||
|
||||
template <class _Value, _STLP_DFL_TMPL_PARAM(_HashFcn,hash<_Value>),
|
||||
_STLP_DFL_TMPL_PARAM(_EqualKey, equal_to<_Value>),
|
||||
_STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Value>) >
|
||||
class hash_multiset
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
||||
: public __stlport_class<hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> >
|
||||
#endif
|
||||
{
|
||||
typedef hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Self;
|
||||
//Specific iterator traits creation
|
||||
typedef _STLP_PRIV _HashMultisetTraitsT<_Value> _HashMultisetTraits;
|
||||
public:
|
||||
typedef hashtable<_Value, _Value, _HashFcn,
|
||||
_HashMultisetTraits, _STLP_PRIV _Identity<_Value>, _EqualKey, _Alloc> _Ht;
|
||||
|
||||
typedef typename _Ht::key_type key_type;
|
||||
typedef typename _Ht::value_type value_type;
|
||||
typedef typename _Ht::hasher hasher;
|
||||
typedef typename _Ht::key_equal key_equal;
|
||||
|
||||
typedef typename _Ht::size_type size_type;
|
||||
typedef typename _Ht::difference_type difference_type;
|
||||
typedef typename _Ht::pointer pointer;
|
||||
typedef typename _Ht::const_pointer const_pointer;
|
||||
typedef typename _Ht::reference reference;
|
||||
typedef typename _Ht::const_reference const_reference;
|
||||
|
||||
typedef typename _Ht::iterator iterator;
|
||||
typedef typename _Ht::const_iterator const_iterator;
|
||||
|
||||
typedef typename _Ht::allocator_type allocator_type;
|
||||
|
||||
hasher hash_funct() const { return _M_ht.hash_funct(); }
|
||||
key_equal key_eq() const { return _M_ht.key_eq(); }
|
||||
allocator_type get_allocator() const { return _M_ht.get_allocator(); }
|
||||
|
||||
private:
|
||||
_Ht _M_ht;
|
||||
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
||||
|
||||
public:
|
||||
hash_multiset()
|
||||
: _M_ht(0, hasher(), key_equal(), allocator_type()) {}
|
||||
explicit hash_multiset(size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
|
||||
hash_multiset(size_type __n, const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
|
||||
hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql)
|
||||
: _M_ht(__n, __hf, __eql, allocator_type()) {}
|
||||
hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a)
|
||||
: _M_ht(__n, __hf, __eql, __a) {}
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
hash_multiset(__move_source<_Self> src)
|
||||
: _M_ht(__move_source<_Ht>(src.get()._M_ht)) {}
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
hash_multiset(_InputIterator __f, _InputIterator __l)
|
||||
: _M_ht(0, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
template <class _InputIterator>
|
||||
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
|
||||
template <class _InputIterator>
|
||||
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
|
||||
template <class _InputIterator>
|
||||
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql)
|
||||
: _M_ht(__n, __hf, __eql, allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
# endif
|
||||
#else
|
||||
hash_multiset(const value_type* __f, const value_type* __l)
|
||||
: _M_ht(0, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multiset(const value_type* __f, const value_type* __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multiset(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multiset(const value_type* __f, const value_type* __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
|
||||
hash_multiset(const_iterator __f, const_iterator __l)
|
||||
: _M_ht(0, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multiset(const_iterator __f, const_iterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multiset(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
hash_multiset(const_iterator __f, const_iterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
#endif /*_STLP_MEMBER_TEMPLATES */
|
||||
|
||||
public:
|
||||
size_type size() const { return _M_ht.size(); }
|
||||
size_type max_size() const { return _M_ht.max_size(); }
|
||||
bool empty() const { return _M_ht.empty(); }
|
||||
void swap(_Self& hs) { _M_ht.swap(hs._M_ht); }
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(_Self& __x) { swap(__x); }
|
||||
#endif
|
||||
|
||||
iterator begin() { return _M_ht.begin(); }
|
||||
iterator end() { return _M_ht.end(); }
|
||||
const_iterator begin() const { return _M_ht.begin(); }
|
||||
const_iterator end() const { return _M_ht.end(); }
|
||||
|
||||
public:
|
||||
iterator insert(const value_type& __obj) { return _M_ht.insert_equal(__obj); }
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __f, _InputIterator __l)
|
||||
{ _M_ht.insert_equal(__f,__l); }
|
||||
#else
|
||||
void insert(const value_type* __f, const value_type* __l)
|
||||
{ _M_ht.insert_equal(__f,__l); }
|
||||
void insert(const_iterator __f, const_iterator __l)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
#endif /*_STLP_MEMBER_TEMPLATES */
|
||||
iterator insert_noresize(const value_type& __obj)
|
||||
{ return _M_ht.insert_equal_noresize(__obj); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator find(const _KT& __key) { return _M_ht.find(__key); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator find(const _KT& __key) const { return _M_ht.find(__key); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type count(const _KT& __key) const { return _M_ht.count(__key); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<iterator, iterator> equal_range(const _KT& __key)
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<const_iterator, const_iterator> equal_range(const _KT& __key) const
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type erase(const _KT& __key) {return _M_ht.erase(__key); }
|
||||
void erase(iterator __it) { _M_ht.erase(__it); }
|
||||
void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
|
||||
void clear() { _M_ht.clear(); }
|
||||
|
||||
public:
|
||||
void resize(size_type __hint) { _M_ht.resize(__hint); }
|
||||
size_type bucket_count() const { return _M_ht.bucket_count(); }
|
||||
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
|
||||
size_type elems_in_bucket(size_type __n) const
|
||||
{ return _M_ht.elems_in_bucket(__n); }
|
||||
};
|
||||
|
||||
#define _STLP_TEMPLATE_HEADER template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
#define _STLP_TEMPLATE_CONTAINER hash_set<_Value,_HashFcn,_EqualKey,_Alloc>
|
||||
|
||||
#include <stl/_relops_hash_cont.h>
|
||||
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#define _STLP_TEMPLATE_CONTAINER hash_multiset<_Value,_HashFcn,_EqualKey,_Alloc>
|
||||
#include <stl/_relops_hash_cont.h>
|
||||
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#undef _STLP_TEMPLATE_HEADER
|
||||
|
||||
// Specialization of insert_iterator so that it will work for hash_set
|
||||
// and hash_multiset.
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
# if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
struct __move_traits<hash_set<_Value, _HashFcn, _EqualKey, _Alloc> > :
|
||||
_STLP_PRIV __move_traits_aux<typename hash_set<_Value, _HashFcn, _EqualKey, _Alloc>::_Ht>
|
||||
{};
|
||||
|
||||
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
struct __move_traits<hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> > :
|
||||
_STLP_PRIV __move_traits_aux<typename hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>::_Ht>
|
||||
{};
|
||||
# endif
|
||||
|
||||
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
class insert_iterator<hash_set<_Value, _HashFcn, _EqualKey, _Alloc> > {
|
||||
protected:
|
||||
typedef hash_set<_Value, _HashFcn, _EqualKey, _Alloc> _Container;
|
||||
_Container* container;
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
typedef output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
|
||||
insert_iterator(_Container& __x) : container(&__x) {}
|
||||
insert_iterator(_Container& __x, typename _Container::iterator)
|
||||
: container(&__x) {}
|
||||
insert_iterator<_Container>&
|
||||
operator=(const typename _Container::value_type& __val) {
|
||||
container->insert(__val);
|
||||
return *this;
|
||||
}
|
||||
insert_iterator<_Container>& operator*() { return *this; }
|
||||
insert_iterator<_Container>& operator++() { return *this; }
|
||||
insert_iterator<_Container>& operator++(int) { return *this; }
|
||||
};
|
||||
|
||||
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
class insert_iterator<hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> > {
|
||||
protected:
|
||||
typedef hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Container;
|
||||
_Container* container;
|
||||
typename _Container::iterator iter;
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
typedef output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
|
||||
insert_iterator(_Container& __x) : container(&__x) {}
|
||||
insert_iterator(_Container& __x, typename _Container::iterator)
|
||||
: container(&__x) {}
|
||||
insert_iterator<_Container>&
|
||||
operator=(const typename _Container::value_type& __val) {
|
||||
container->insert(__val);
|
||||
return *this;
|
||||
}
|
||||
insert_iterator<_Container>& operator*() { return *this; }
|
||||
insert_iterator<_Container>& operator++() { return *this; }
|
||||
insert_iterator<_Container>& operator++(int) { return *this; }
|
||||
};
|
||||
#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_HASH_SET_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
553
extern/STLport/5.2.1/stlport/stl/_hashtable.c
vendored
Normal file
553
extern/STLport/5.2.1/stlport/stl/_hashtable.c
vendored
Normal file
@@ -0,0 +1,553 @@
|
||||
/*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_HASHTABLE_C
|
||||
#define _STLP_HASHTABLE_C
|
||||
|
||||
#ifndef _STLP_INTERNAL_HASHTABLE_H
|
||||
# include <stl/_hashtable.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION)
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
# define __PRIME_LIST_BODY { \
|
||||
7ul, 23ul, \
|
||||
53ul, 97ul, 193ul, 389ul, 769ul, \
|
||||
1543ul, 3079ul, 6151ul, 12289ul, 24593ul, \
|
||||
49157ul, 98317ul, 196613ul, 393241ul, 786433ul, \
|
||||
1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul, \
|
||||
50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul,\
|
||||
1610612741ul, 3221225473ul, 4294967291ul \
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
const size_t* _STLP_CALL
|
||||
_Stl_prime<_Dummy>::_S_primes(size_t &__size) {
|
||||
static const size_t _list[] = __PRIME_LIST_BODY;
|
||||
# ifndef __MWERKS__
|
||||
__size = sizeof(_list) / sizeof(_list[0]);
|
||||
# else
|
||||
__size = 30;
|
||||
# endif
|
||||
return _list;
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
size_t _STLP_CALL
|
||||
_Stl_prime<_Dummy>::_S_max_nb_buckets() {
|
||||
size_t __size;
|
||||
const size_t* __first = _S_primes(__size);
|
||||
return *(__first + __size - 1);
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
size_t _STLP_CALL
|
||||
_Stl_prime<_Dummy>::_S_next_size(size_t __n) {
|
||||
size_t __size;
|
||||
const size_t* __first = _S_primes(__size);
|
||||
const size_t* __last = __first + __size;
|
||||
const size_t* pos = __lower_bound(__first, __last, __n,
|
||||
__less((size_t*)0), __less((size_t*)0), (ptrdiff_t*)0);
|
||||
return (pos == __last ? *(__last - 1) : *pos);
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
_Stl_prime<_Dummy>::_S_prev_sizes(size_t __n, size_t const*&__begin, size_t const*&__pos) {
|
||||
size_t __size;
|
||||
__begin = _S_primes(__size);
|
||||
const size_t* __last = __begin + __size;
|
||||
__pos = __lower_bound(__begin, __last, __n,
|
||||
__less((size_t*)0), __less((size_t*)0), (ptrdiff_t*)0);
|
||||
|
||||
if (__pos== __last)
|
||||
--__pos;
|
||||
else if (*__pos == __n) {
|
||||
if (__pos != __begin)
|
||||
--__pos;
|
||||
}
|
||||
}
|
||||
|
||||
# undef __PRIME_LIST_BODY
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_DEBUG)
|
||||
# define hashtable _STLP_NON_DBG_NAME(hashtable)
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
#endif
|
||||
|
||||
// fbp: these defines are for outline methods definitions.
|
||||
// needed to definitions to be portable. Should not be used in method bodies.
|
||||
|
||||
#if defined ( _STLP_NESTED_TYPE_PARAM_BUG )
|
||||
# define __size_type__ size_t
|
||||
# define size_type size_t
|
||||
# define value_type _Val
|
||||
# define key_type _Key
|
||||
# define __reference__ _Val&
|
||||
|
||||
# define __iterator__ _Ht_iterator<_Val, _STLP_HEADER_TYPENAME _Traits::_NonConstTraits, \
|
||||
_Key, _HF, _ExK, _EqK, _All>
|
||||
# define __const_iterator__ _Ht_iterator<_Val, _STLP_HEADER_TYPENAME _Traits::_ConstTraits, \
|
||||
_Key, _HF, _ExK, _EqK, _All>
|
||||
#else
|
||||
# define __size_type__ _STLP_TYPENAME_ON_RETURN_TYPE hashtable<_Val, _Key, _HF, _Traits, _ExK, _EqK, _All>::size_type
|
||||
# define __reference__ _STLP_TYPENAME_ON_RETURN_TYPE hashtable<_Val, _Key, _HF, _Traits, _ExK, _EqK, _All>::reference
|
||||
# define __iterator__ _STLP_TYPENAME_ON_RETURN_TYPE hashtable<_Val, _Key, _HF, _Traits, _ExK, _EqK, _All>::iterator
|
||||
# define __const_iterator__ _STLP_TYPENAME_ON_RETURN_TYPE hashtable<_Val, _Key, _HF, _Traits, _ExK, _EqK, _All>::const_iterator
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This method is too difficult to implement for hashtable that do not
|
||||
* require a sorted operation on the stored type.
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
bool hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>::_M_equal(
|
||||
const hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>& __ht1,
|
||||
const hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>& __ht2) {
|
||||
return __ht1._M_buckets == __ht2._M_buckets &&
|
||||
__ht1._M_elems == __ht2._M_elems;
|
||||
}
|
||||
*/
|
||||
|
||||
/* Returns the iterator before the first iterator of the bucket __n and set
|
||||
* __n to the first previous bucket having the same first iterator as bucket
|
||||
* __n.
|
||||
*/
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
__iterator__
|
||||
hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
::_M_before_begin(size_type &__n) const {
|
||||
return _S_before_begin(_M_elems, _M_buckets, __n);
|
||||
}
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
__iterator__
|
||||
hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
::_S_before_begin(const _ElemsCont& __elems, const _BucketVector& __buckets,
|
||||
size_type &__n) {
|
||||
_ElemsCont &__mutable_elems = __CONST_CAST(_ElemsCont&, __elems);
|
||||
typename _BucketVector::const_iterator __bpos(__buckets.begin() + __n);
|
||||
|
||||
_ElemsIte __pos(*__bpos);
|
||||
if (__pos == __mutable_elems.begin()) {
|
||||
__n = 0;
|
||||
return __mutable_elems.before_begin();
|
||||
}
|
||||
|
||||
typename _BucketVector::const_iterator __bcur(__bpos);
|
||||
_BucketType *__pos_node = __pos._M_node;
|
||||
for (--__bcur; __pos_node == *__bcur; --__bcur);
|
||||
|
||||
__n = __bcur - __buckets.begin() + 1;
|
||||
_ElemsIte __cur(*__bcur);
|
||||
_ElemsIte __prev = __cur++;
|
||||
for (; __cur != __pos; ++__prev, ++__cur);
|
||||
return __prev;
|
||||
}
|
||||
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
__iterator__
|
||||
hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
::_M_insert_noresize(size_type __n, const value_type& __obj) {
|
||||
//We always insert this element as 1st in the bucket to not break
|
||||
//the elements order as equal elements must be kept next to each other.
|
||||
size_type __prev = __n;
|
||||
_ElemsIte __pos = _M_before_begin(__prev)._M_ite;
|
||||
|
||||
fill(_M_buckets.begin() + __prev, _M_buckets.begin() + __n + 1,
|
||||
_M_elems.insert_after(__pos, __obj)._M_node);
|
||||
++_M_num_elements;
|
||||
return iterator(_ElemsIte(_M_buckets[__n]));
|
||||
}
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
pair<__iterator__, bool>
|
||||
hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
::insert_unique_noresize(const value_type& __obj) {
|
||||
const size_type __n = _M_bkt_num(__obj);
|
||||
_ElemsIte __cur(_M_buckets[__n]);
|
||||
_ElemsIte __last(_M_buckets[__n + 1]);
|
||||
|
||||
if (__cur != __last) {
|
||||
for (; __cur != __last; ++__cur) {
|
||||
if (_M_equals(_M_get_key(*__cur), _M_get_key(__obj))) {
|
||||
//We check that equivalent keys have equals hash code as otherwise, on resize,
|
||||
//equivalent value might not be in the same bucket
|
||||
_STLP_ASSERT(_M_hash(_M_get_key(*__cur)) == _M_hash(_M_get_key(__obj)))
|
||||
return pair<iterator, bool>(iterator(__cur), false);
|
||||
}
|
||||
}
|
||||
/* Here we do not rely on the _M_insert_noresize method as we know
|
||||
* that we cannot break element orders, elements are unique, and
|
||||
* insertion after the first bucket element is faster than what is
|
||||
* done in _M_insert_noresize.
|
||||
*/
|
||||
__cur = _M_elems.insert_after(_ElemsIte(_M_buckets[__n]), __obj);
|
||||
++_M_num_elements;
|
||||
return pair<iterator, bool>(iterator(__cur), true);
|
||||
}
|
||||
|
||||
return pair<iterator, bool>(_M_insert_noresize(__n, __obj), true);
|
||||
}
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
__iterator__
|
||||
hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
::insert_equal_noresize(const value_type& __obj) {
|
||||
const size_type __n = _M_bkt_num(__obj);
|
||||
{
|
||||
_ElemsIte __cur(_M_buckets[__n]);
|
||||
_ElemsIte __last(_M_buckets[__n + 1]);
|
||||
|
||||
for (; __cur != __last; ++__cur) {
|
||||
if (_M_equals(_M_get_key(*__cur), _M_get_key(__obj))) {
|
||||
//We check that equivalent keys have equals hash code as otherwise, on resize,
|
||||
//equivalent value might not be in the same bucket
|
||||
_STLP_ASSERT(_M_hash(_M_get_key(*__cur)) == _M_hash(_M_get_key(__obj)))
|
||||
++_M_num_elements;
|
||||
return _M_elems.insert_after(__cur, __obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _M_insert_noresize(__n, __obj);
|
||||
}
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
__reference__
|
||||
hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
::_M_insert(const value_type& __obj) {
|
||||
_M_enlarge(_M_num_elements + 1);
|
||||
return *insert_unique_noresize(__obj).first;
|
||||
}
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
__size_type__
|
||||
hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
::erase(const key_type& __key) {
|
||||
const size_type __n = _M_bkt_num_key(__key);
|
||||
|
||||
_ElemsIte __cur(_M_buckets[__n]);
|
||||
_ElemsIte __last(_M_buckets[__n + 1]);
|
||||
if (__cur == __last)
|
||||
return 0;
|
||||
|
||||
size_type __erased = 0;
|
||||
if (_M_equals(_M_get_key(*__cur), __key)) {
|
||||
//We look for the pos before __cur:
|
||||
size_type __prev_b = __n;
|
||||
_ElemsIte __prev = _M_before_begin(__prev_b)._M_ite;
|
||||
do {
|
||||
__cur = _M_elems.erase_after(__prev);
|
||||
++__erased;
|
||||
} while ((__cur != __last) && _M_equals(_M_get_key(*__cur), __key));
|
||||
fill(_M_buckets.begin() + __prev_b, _M_buckets.begin() + __n + 1, __cur._M_node);
|
||||
}
|
||||
else {
|
||||
_ElemsIte __prev = __cur++;
|
||||
for (; __cur != __last; ++__prev, ++__cur) {
|
||||
if (_M_equals(_M_get_key(*__cur), __key)) {
|
||||
do {
|
||||
__cur = _M_elems.erase_after(__prev);
|
||||
++__erased;
|
||||
} while ((__cur != __last) && _M_equals(_M_get_key(*__cur), __key));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_M_num_elements -= __erased;
|
||||
_M_reduce();
|
||||
return __erased;
|
||||
}
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
::erase(const_iterator __it) {
|
||||
const size_type __n = _M_bkt_num(*__it);
|
||||
_ElemsIte __cur(_M_buckets[__n]);
|
||||
|
||||
size_type __erased = 0;
|
||||
if (__cur == __it._M_ite) {
|
||||
size_type __prev_b = __n;
|
||||
_ElemsIte __prev = _M_before_begin(__prev_b)._M_ite;
|
||||
fill(_M_buckets.begin() + __prev_b, _M_buckets.begin() + __n + 1,
|
||||
_M_elems.erase_after(__prev)._M_node);
|
||||
++__erased;
|
||||
}
|
||||
else {
|
||||
_ElemsIte __prev = __cur++;
|
||||
_ElemsIte __last(_M_buckets[__n + 1]);
|
||||
for (; __cur != __last; ++__prev, ++__cur) {
|
||||
if (__cur == __it._M_ite) {
|
||||
_M_elems.erase_after(__prev);
|
||||
++__erased;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_M_num_elements -= __erased;
|
||||
_M_reduce();
|
||||
}
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
::erase(const_iterator __first, const_iterator __last) {
|
||||
if (__first == __last)
|
||||
return;
|
||||
size_type __f_bucket = _M_bkt_num(*__first);
|
||||
size_type __l_bucket = __last != end() ? _M_bkt_num(*__last) : (_M_buckets.size() - 1);
|
||||
|
||||
_ElemsIte __cur(_M_buckets[__f_bucket]);
|
||||
_ElemsIte __prev;
|
||||
if (__cur == __first._M_ite) {
|
||||
__prev = _M_before_begin(__f_bucket)._M_ite;
|
||||
}
|
||||
else {
|
||||
_ElemsIte __last(_M_buckets[++__f_bucket]);
|
||||
__prev = __cur++;
|
||||
for (; (__cur != __last) && (__cur != __first._M_ite); ++__prev, ++__cur);
|
||||
}
|
||||
size_type __erased = 0;
|
||||
//We do not use the slist::erase_after method taking a range to count the
|
||||
//number of erased elements:
|
||||
while (__cur != __last._M_ite) {
|
||||
__cur = _M_elems.erase_after(__prev);
|
||||
++__erased;
|
||||
}
|
||||
fill(_M_buckets.begin() + __f_bucket, _M_buckets.begin() + __l_bucket + 1, __cur._M_node);
|
||||
_M_num_elements -= __erased;
|
||||
_M_reduce();
|
||||
}
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
::rehash(size_type __num_buckets_hint) {
|
||||
if (bucket_count() >= __num_buckets_hint) {
|
||||
// We are trying to reduce number of buckets, we have to validate it:
|
||||
size_type __limit_num_buckets = (size_type)((float)size() / max_load_factor());
|
||||
if (__num_buckets_hint < __limit_num_buckets) {
|
||||
// Targetted number of buckets __num_buckets_hint would break
|
||||
// load_factor() <= max_load_factor() rule.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_M_rehash(__num_buckets_hint);
|
||||
}
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
::_M_enlarge(size_type __to_size) {
|
||||
size_type __num_buckets = bucket_count();
|
||||
size_type __num_buckets_hint = (size_type)((float)__to_size / max_load_factor());
|
||||
if (__num_buckets_hint <= __num_buckets) {
|
||||
return;
|
||||
}
|
||||
__num_buckets = _STLP_PRIV _Stl_prime_type::_S_next_size(__num_buckets_hint);
|
||||
|
||||
_M_rehash(__num_buckets);
|
||||
}
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
::_M_reduce() {
|
||||
size_type __num_buckets = bucket_count();
|
||||
// We only try to reduce the hashtable if the theorical load factor
|
||||
// is lower than a fraction of the max load factor:
|
||||
// 4 factor is coming from the fact that prime number list is almost a
|
||||
// geometrical suite with reason 2, as we try to jump 2 levels is means
|
||||
// a 4 factor.
|
||||
if ((float)size() / (float)__num_buckets > max_load_factor() / 4.0f)
|
||||
return;
|
||||
|
||||
const size_type *__first;
|
||||
const size_type *__prev;
|
||||
_STLP_PRIV _Stl_prime_type::_S_prev_sizes(__num_buckets, __first, __prev);
|
||||
|
||||
/* We are only going to reduce number of buckets if moving to yet the previous number
|
||||
* of buckets in the prime numbers would respect the load rule. Otherwise algorithm
|
||||
* successively removing and adding an element would each time perform an expensive
|
||||
* rehash operation. */
|
||||
const size_type *__prev_prev = __prev;
|
||||
if (__prev_prev != __first) {
|
||||
--__prev_prev;
|
||||
if ((float)size() / (float)*__prev_prev > max_load_factor())
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (*__prev >= __num_buckets)
|
||||
return;
|
||||
}
|
||||
|
||||
// Can we reduce further:
|
||||
while (__prev_prev != __first) {
|
||||
--__prev_prev;
|
||||
if ((float)size() / (float)*__prev_prev > max_load_factor())
|
||||
// We cannot reduce further.
|
||||
break;
|
||||
--__prev;
|
||||
}
|
||||
|
||||
_M_rehash(*__prev);
|
||||
}
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
::_M_resize() {
|
||||
if (load_factor() > max_load_factor()) {
|
||||
// We have to enlarge
|
||||
_M_enlarge(size());
|
||||
}
|
||||
else {
|
||||
// We can try to reduce size:
|
||||
_M_reduce();
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
::_M_rehash(size_type __num_buckets) {
|
||||
#if defined (_STLP_DEBUG)
|
||||
_M_check();
|
||||
#endif
|
||||
_ElemsCont __tmp_elems(_M_elems.get_allocator());
|
||||
_BucketVector __tmp(__num_buckets + 1, __STATIC_CAST(_BucketType*, 0), _M_buckets.get_allocator());
|
||||
_ElemsIte __cur, __last(_M_elems.end());
|
||||
while (!_M_elems.empty()) {
|
||||
__cur = _M_elems.begin();
|
||||
size_type __new_bucket = _M_bkt_num(*__cur, __num_buckets);
|
||||
_ElemsIte __ite(__cur), __before_ite(__cur);
|
||||
for (++__ite;
|
||||
__ite != __last && _M_equals(_M_get_key(*__cur), _M_get_key(*__ite));
|
||||
++__ite, ++__before_ite);
|
||||
size_type __prev_bucket = __new_bucket;
|
||||
_ElemsIte __prev = _S_before_begin(__tmp_elems, __tmp, __prev_bucket)._M_ite;
|
||||
__tmp_elems.splice_after(__prev, _M_elems, _M_elems.before_begin(), __before_ite);
|
||||
fill(__tmp.begin() + __prev_bucket, __tmp.begin() + __new_bucket + 1, __cur._M_node);
|
||||
}
|
||||
_M_elems.swap(__tmp_elems);
|
||||
_M_buckets.swap(__tmp);
|
||||
}
|
||||
|
||||
#if defined (_STLP_DEBUG)
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>::_M_check() const {
|
||||
//We check that hash code of stored keys haven't change and also that equivalent
|
||||
//relation hasn't been modified
|
||||
size_t __num_buckets = bucket_count();
|
||||
for (size_t __b = 0; __b < __num_buckets; ++__b) {
|
||||
_ElemsIte __cur(_M_buckets[__b]), __last(_M_buckets[__b + 1]);
|
||||
_ElemsIte __fst(__cur), __snd(__cur);
|
||||
for (; __cur != __last; ++__cur) {
|
||||
_STLP_ASSERT( _M_bkt_num(*__cur, __num_buckets) == __b )
|
||||
_STLP_ASSERT( !_M_equals(_M_get_key(*__fst), _M_get_key(*__cur)) || _M_equals(_M_get_key(*__snd), _M_get_key(*__cur)) )
|
||||
if (__fst != __snd)
|
||||
++__fst;
|
||||
if (__snd != __cur)
|
||||
++__snd;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>::clear() {
|
||||
_M_elems.clear();
|
||||
_M_buckets.assign(_M_buckets.size(), __STATIC_CAST(_BucketType*, 0));
|
||||
_M_num_elements = 0;
|
||||
}
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
::_M_copy_from(const hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>& __ht) {
|
||||
_M_elems.clear();
|
||||
_M_elems.insert(_M_elems.end(), __ht._M_elems.begin(), __ht._M_elems.end());
|
||||
_M_buckets.resize(__ht._M_buckets.size());
|
||||
_ElemsConstIte __src(__ht._M_elems.begin()), __src_end(__ht._M_elems.end());
|
||||
_ElemsIte __dst(_M_elems.begin());
|
||||
typename _BucketVector::const_iterator __src_b(__ht._M_buckets.begin()),
|
||||
__src_end_b(__ht._M_buckets.end());
|
||||
typename _BucketVector::iterator __dst_b(_M_buckets.begin()), __dst_end_b(_M_buckets.end());
|
||||
for (; __src != __src_end; ++__src, ++__dst) {
|
||||
for (; __src_b != __src_end_b; ++__src_b, ++__dst_b) {
|
||||
if (*__src_b == __src._M_node) {
|
||||
*__dst_b = __dst._M_node;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
fill(__dst_b, __dst_end_b, __STATIC_CAST(_BucketType*, 0));
|
||||
_M_num_elements = __ht._M_num_elements;
|
||||
_M_max_load_factor = __ht._M_max_load_factor;
|
||||
}
|
||||
|
||||
#undef __iterator__
|
||||
#undef const_iterator
|
||||
#undef __size_type__
|
||||
#undef __reference__
|
||||
#undef size_type
|
||||
#undef value_type
|
||||
#undef key_type
|
||||
#undef __stl_num_primes
|
||||
|
||||
#if defined (_STLP_DEBUG)
|
||||
# undef hashtable
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_HASHTABLE_C */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
658
extern/STLport/5.2.1/stlport/stl/_hashtable.h
vendored
Normal file
658
extern/STLport/5.2.1/stlport/stl/_hashtable.h
vendored
Normal file
@@ -0,0 +1,658 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_HASHTABLE_H
|
||||
#define _STLP_INTERNAL_HASHTABLE_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_VECTOR_H
|
||||
# include <stl/_vector.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_SLIST_H
|
||||
# include <stl/_slist.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_H
|
||||
# include <stl/_iterator.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
|
||||
# include <stl/_function_base.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALGOBASE_H
|
||||
# include <stl/_algobase.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_HASH_FUN_H
|
||||
# include <stl/_hash_fun.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Hashtable class, used to implement the hashed associative containers
|
||||
* hash_set, hash_map, hash_multiset, hash_multimap,
|
||||
* unordered_set, unordered_map, unordered_multiset, unordered_multimap.
|
||||
*/
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
//Export of the classes used to represent buckets in the hashtable implementation.
|
||||
# if !defined (_STLP_USE_PTR_SPECIALIZATIONS)
|
||||
//If pointer specialization is enabled vector<_Slist_node_base*> will use the void*
|
||||
//storage type for which internal classes have already been exported.
|
||||
_STLP_EXPORT_TEMPLATE_CLASS allocator<_STLP_PRIV _Slist_node_base*>;
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<_Slist_node_base**, _Slist_node_base*,
|
||||
allocator<_Slist_node_base*> >;
|
||||
_STLP_EXPORT_TEMPLATE_CLASS _Vector_base<_Slist_node_base*,
|
||||
allocator<_Slist_node_base*> >;
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_DEBUG)
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
# define _STLP_NON_DBG_VECTOR _STLP_NON_DBG_NAME(vector)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS __construct_checker<_STLP_NON_DBG_VECTOR<_Slist_node_base*, allocator<_Slist_node_base*> > >;
|
||||
_STLP_EXPORT_TEMPLATE_CLASS _STLP_NON_DBG_VECTOR<_Slist_node_base*, allocator<_Slist_node_base*> >;
|
||||
# undef _STLP_NON_DBG_VECTOR
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
# endif
|
||||
|
||||
_STLP_EXPORT_TEMPLATE_CLASS vector<_STLP_PRIV _Slist_node_base*,
|
||||
allocator<_STLP_PRIV _Slist_node_base*> >;
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_DEBUG)
|
||||
# define hashtable _STLP_NON_DBG_NAME(hashtable)
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
#endif
|
||||
|
||||
// some compilers require the names of template parameters to be the same
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
class hashtable;
|
||||
|
||||
#if !defined (_STLP_DEBUG)
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
#endif
|
||||
|
||||
template <class _BaseIte, class _Traits>
|
||||
struct _Ht_iterator {
|
||||
typedef typename _Traits::_ConstTraits _ConstTraits;
|
||||
typedef typename _Traits::_NonConstTraits _NonConstTraits;
|
||||
|
||||
typedef _Ht_iterator<_BaseIte,_Traits> _Self;
|
||||
|
||||
typedef typename _Traits::value_type value_type;
|
||||
typedef typename _Traits::pointer pointer;
|
||||
typedef typename _Traits::reference reference;
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef size_t size_type;
|
||||
|
||||
typedef _Ht_iterator<_BaseIte, _NonConstTraits> iterator;
|
||||
typedef _Ht_iterator<_BaseIte, _ConstTraits> const_iterator;
|
||||
|
||||
_Ht_iterator() {}
|
||||
//copy constructor for iterator and constructor from iterator for const_iterator
|
||||
_Ht_iterator(const iterator& __it) : _M_ite(__it._M_ite) {}
|
||||
_Ht_iterator(_BaseIte __it) : _M_ite(__it) {}
|
||||
|
||||
reference operator*() const {
|
||||
return *_M_ite;
|
||||
}
|
||||
_STLP_DEFINE_ARROW_OPERATOR
|
||||
|
||||
_Self& operator++() {
|
||||
++_M_ite;
|
||||
return *this;
|
||||
}
|
||||
_Self operator++(int) {
|
||||
_Self __tmp = *this;
|
||||
++*this;
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
bool operator == (const_iterator __rhs) const {
|
||||
return _M_ite == __rhs._M_ite;
|
||||
}
|
||||
bool operator != (const_iterator __rhs) const {
|
||||
return _M_ite != __rhs._M_ite;
|
||||
}
|
||||
|
||||
_BaseIte _M_ite;
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
template <class _BaseIte, class _Traits>
|
||||
struct __type_traits<_STLP_PRIV _Ht_iterator<_BaseIte, _Traits> > {
|
||||
typedef __false_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
typedef __true_type has_trivial_assignment_operator;
|
||||
typedef __true_type has_trivial_destructor;
|
||||
typedef __false_type is_POD_type;
|
||||
};
|
||||
#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
|
||||
|
||||
#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
|
||||
template <class _BaseIte, class _Traits>
|
||||
inline
|
||||
# if defined (_STLP_NESTED_TYPE_PARAM_BUG)
|
||||
_STLP_TYPENAME_ON_RETURN_TYPE _Traits::value_type *
|
||||
# else
|
||||
_STLP_TYPENAME_ON_RETURN_TYPE _STLP_PRIV _Ht_iterator<_BaseIte,_Traits>::value_type *
|
||||
# endif
|
||||
value_type(const _STLP_PRIV _Ht_iterator<_BaseIte,_Traits>&) {
|
||||
typedef _STLP_TYPENAME _STLP_PRIV _Ht_iterator<_BaseIte,_Traits>::value_type _Val;
|
||||
return (_Val*) 0;
|
||||
}
|
||||
template <class _BaseIte, class _Traits>
|
||||
inline forward_iterator_tag iterator_category(const _STLP_PRIV _Ht_iterator<_BaseIte,_Traits>&)
|
||||
{ return forward_iterator_tag(); }
|
||||
template <class _BaseIte, class _Traits>
|
||||
inline ptrdiff_t* distance_type(const _STLP_PRIV _Ht_iterator<_BaseIte,_Traits>&)
|
||||
{ return (ptrdiff_t*) 0; }
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Dummy>
|
||||
class _Stl_prime {
|
||||
// Returns begining of primes list and size by reference.
|
||||
static const size_t* _S_primes(size_t&);
|
||||
public:
|
||||
//Returns the maximum number of buckets handled by the hashtable implementation
|
||||
static size_t _STLP_CALL _S_max_nb_buckets();
|
||||
|
||||
//Returns the bucket size next to a required size
|
||||
static size_t _STLP_CALL _S_next_size(size_t);
|
||||
|
||||
// Returns the bucket range containing sorted list of prime numbers <= __hint.
|
||||
static void _STLP_CALL _S_prev_sizes(size_t __hint, const size_t *&__begin, const size_t *&__end);
|
||||
};
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS _Stl_prime<bool>;
|
||||
#endif
|
||||
|
||||
typedef _Stl_prime<bool> _Stl_prime_type;
|
||||
|
||||
#if !defined (_STLP_DEBUG)
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Hashtables handle allocators a bit differently than other containers
|
||||
* do. If we're using standard-conforming allocators, then a hashtable
|
||||
* unconditionally has a member variable to hold its allocator, even if
|
||||
* it so happens that all instances of the allocator type are identical.
|
||||
* This is because, for hashtables, this extra storage is negligible.
|
||||
* Additionally, a base class wouldn't serve any other purposes; it
|
||||
* wouldn't, for example, simplify the exception-handling code.
|
||||
*/
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
class hashtable {
|
||||
typedef hashtable<_Val, _Key, _HF, _Traits, _ExK, _EqK, _All> _Self;
|
||||
typedef typename _Traits::_NonConstTraits _NonConstTraits;
|
||||
typedef typename _Traits::_ConstTraits _ConstTraits;
|
||||
typedef typename _Traits::_NonConstLocalTraits _NonConstLocalTraits;
|
||||
typedef typename _Traits::_ConstLocalTraits _ConstLocalTraits;
|
||||
|
||||
public:
|
||||
typedef _Key key_type;
|
||||
typedef _Val value_type;
|
||||
typedef _HF hasher;
|
||||
typedef _EqK key_equal;
|
||||
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef typename _NonConstTraits::pointer pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef typename _NonConstTraits::reference reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef forward_iterator_tag _Iterator_category;
|
||||
|
||||
hasher hash_funct() const { return _M_hash; }
|
||||
key_equal key_eq() const { return _M_equals; }
|
||||
|
||||
private:
|
||||
_STLP_FORCE_ALLOCATORS(_Val, _All)
|
||||
#if defined (_STLP_DEBUG)
|
||||
typedef _STLP_PRIV _STLP_NON_DBG_NAME(slist)<value_type, _All> _ElemsCont;
|
||||
#else
|
||||
typedef slist<value_type, _All> _ElemsCont;
|
||||
#endif
|
||||
typedef typename _ElemsCont::iterator _ElemsIte;
|
||||
typedef typename _ElemsCont::const_iterator _ElemsConstIte;
|
||||
typedef _STLP_PRIV _Slist_node_base _BucketType;
|
||||
typedef typename _Alloc_traits<_BucketType*, _All>::allocator_type _BucketAllocType;
|
||||
/*
|
||||
* We are going to use vector of _Slist_node_base pointers for 2 reasons:
|
||||
* - limit code bloat, all hashtable instanciation use the same buckets representation.
|
||||
* - avoid _STLP_DEBUG performance trouble: with a vector of iterator on slist the resize
|
||||
* method would be too slow because the slist::splice_after method become linear on
|
||||
* the number of iterators in the buckets rather than constant in time as the iterator
|
||||
* has to be move from a slist to the other.
|
||||
*/
|
||||
#if defined (_STLP_DEBUG)
|
||||
typedef _STLP_PRIV _STLP_NON_DBG_NAME(vector)<_BucketType*, _BucketAllocType> _BucketVector;
|
||||
#else
|
||||
typedef vector<_BucketType*, _BucketAllocType> _BucketVector;
|
||||
#endif
|
||||
|
||||
hasher _M_hash;
|
||||
key_equal _M_equals;
|
||||
_ElemsCont _M_elems;
|
||||
_BucketVector _M_buckets;
|
||||
size_type _M_num_elements;
|
||||
float _M_max_load_factor;
|
||||
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
||||
|
||||
static const key_type& _M_get_key(const value_type& __val) {
|
||||
_ExK k;
|
||||
return k(__val);
|
||||
}
|
||||
public:
|
||||
typedef _STLP_PRIV _Ht_iterator<_ElemsIte, _NonConstTraits> iterator;
|
||||
typedef _STLP_PRIV _Ht_iterator<_ElemsIte, _ConstTraits> const_iterator;
|
||||
//TODO: Avoids this debug check and make the local_iterator different from
|
||||
//iterator in debug mode too.
|
||||
#if !defined (_STLP_DEBUG)
|
||||
typedef _STLP_PRIV _Ht_iterator<_ElemsIte, _NonConstLocalTraits> local_iterator;
|
||||
typedef _STLP_PRIV _Ht_iterator<_ElemsIte, _ConstLocalTraits> const_local_iterator;
|
||||
#else
|
||||
typedef iterator local_iterator;
|
||||
typedef const_iterator const_local_iterator;
|
||||
#endif
|
||||
|
||||
typedef _All allocator_type;
|
||||
allocator_type get_allocator() const { return _M_elems.get_allocator(); }
|
||||
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
hashtable(size_type __n,
|
||||
const _HF& __hf,
|
||||
const _EqK& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
#else
|
||||
hashtable(size_type __n,
|
||||
const _HF& __hf,
|
||||
const _EqK& __eql)
|
||||
: _M_hash(__hf),
|
||||
_M_equals(__eql),
|
||||
_M_elems(allocator_type()),
|
||||
_M_buckets(_STLP_CONVERT_ALLOCATOR(__a, _BucketType*)),
|
||||
_M_num_elements(0),
|
||||
_M_max_load_factor(1.0f)
|
||||
{ _M_initialize_buckets(__n); }
|
||||
|
||||
hashtable(size_type __n,
|
||||
const _HF& __hf,
|
||||
const _EqK& __eql,
|
||||
const allocator_type& __a)
|
||||
#endif
|
||||
: _M_hash(__hf),
|
||||
_M_equals(__eql),
|
||||
_M_elems(__a),
|
||||
_M_buckets(_STLP_CONVERT_ALLOCATOR(__a, _BucketType*)),
|
||||
_M_num_elements(0),
|
||||
_M_max_load_factor(1.0f)
|
||||
{ _M_initialize_buckets(__n); }
|
||||
|
||||
hashtable(const _Self& __ht)
|
||||
: _M_hash(__ht._M_hash),
|
||||
_M_equals(__ht._M_equals),
|
||||
_M_elems(__ht.get_allocator()),
|
||||
_M_buckets(_STLP_CONVERT_ALLOCATOR(__ht.get_allocator(), _BucketType*)),
|
||||
_M_num_elements(0),
|
||||
_M_max_load_factor(1.0f)
|
||||
{ _M_copy_from(__ht); }
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
hashtable(__move_source<_Self> src)
|
||||
: _M_hash(_STLP_PRIV _AsMoveSource(src.get()._M_hash)),
|
||||
_M_equals(_STLP_PRIV _AsMoveSource(src.get()._M_equals)),
|
||||
_M_elems(__move_source<_ElemsCont>(src.get()._M_elems)),
|
||||
_M_buckets(__move_source<_BucketVector>(src.get()._M_buckets)),
|
||||
_M_num_elements(src.get()._M_num_elements),
|
||||
_M_max_load_factor(src.get()._M_max_load_factor) {}
|
||||
#endif
|
||||
|
||||
_Self& operator= (const _Self& __ht) {
|
||||
if (&__ht != this) {
|
||||
clear();
|
||||
_M_hash = __ht._M_hash;
|
||||
_M_equals = __ht._M_equals;
|
||||
_M_copy_from(__ht);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
~hashtable() { clear(); }
|
||||
|
||||
size_type size() const { return _M_num_elements; }
|
||||
size_type max_size() const { return size_type(-1); }
|
||||
bool empty() const { return size() == 0; }
|
||||
|
||||
void swap(_Self& __ht) {
|
||||
_STLP_STD::swap(_M_hash, __ht._M_hash);
|
||||
_STLP_STD::swap(_M_equals, __ht._M_equals);
|
||||
_M_elems.swap(__ht._M_elems);
|
||||
_M_buckets.swap(__ht._M_buckets);
|
||||
_STLP_STD::swap(_M_num_elements, __ht._M_num_elements);
|
||||
_STLP_STD::swap(_M_max_load_factor, __ht._M_max_load_factor);
|
||||
}
|
||||
|
||||
iterator begin() { return _M_elems.begin(); }
|
||||
iterator end() { return _M_elems.end(); }
|
||||
local_iterator begin(size_type __n) { return _ElemsIte(_M_buckets[__n]); }
|
||||
local_iterator end(size_type __n) { return _ElemsIte(_M_buckets[__n + 1]); }
|
||||
|
||||
const_iterator begin() const { return __CONST_CAST(_ElemsCont&, _M_elems).begin(); }
|
||||
const_iterator end() const { return __CONST_CAST(_ElemsCont&, _M_elems).end(); }
|
||||
const_local_iterator begin(size_type __n) const { return _ElemsIte(_M_buckets[__n]); }
|
||||
const_local_iterator end(size_type __n) const { return _ElemsIte(_M_buckets[__n + 1]); }
|
||||
|
||||
//static bool _STLP_CALL _M_equal (const _Self&, const _Self&);
|
||||
|
||||
public:
|
||||
//The number of buckets is size() - 1 because the last bucket always contains
|
||||
//_M_elems.end() to make algo easier to implement.
|
||||
size_type bucket_count() const { return _M_buckets.size() - 1; }
|
||||
size_type max_bucket_count() const { return _STLP_PRIV _Stl_prime_type::_S_max_nb_buckets(); }
|
||||
size_type elems_in_bucket(size_type __bucket) const
|
||||
{ return _STLP_STD::distance(_ElemsIte(_M_buckets[__bucket]), _ElemsIte(_M_buckets[__bucket + 1])); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type bucket(const _KT& __k) const { return _M_bkt_num_key(__k); }
|
||||
|
||||
// hash policy
|
||||
float load_factor() const { return (float)size() / (float)bucket_count(); }
|
||||
float max_load_factor() const { return _M_max_load_factor; }
|
||||
void max_load_factor(float __z) {
|
||||
_M_max_load_factor = __z;
|
||||
_M_resize();
|
||||
}
|
||||
|
||||
pair<iterator, bool> insert_unique(const value_type& __obj) {
|
||||
_M_enlarge(_M_num_elements + 1);
|
||||
return insert_unique_noresize(__obj);
|
||||
}
|
||||
|
||||
iterator insert_equal(const value_type& __obj) {
|
||||
_M_enlarge(_M_num_elements + 1);
|
||||
return insert_equal_noresize(__obj);
|
||||
}
|
||||
|
||||
protected:
|
||||
iterator _M_insert_noresize(size_type __n, const value_type& __obj);
|
||||
public:
|
||||
pair<iterator, bool> insert_unique_noresize(const value_type& __obj);
|
||||
iterator insert_equal_noresize(const value_type& __obj);
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void insert_unique(_InputIterator __f, _InputIterator __l)
|
||||
{ insert_unique(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIterator)); }
|
||||
|
||||
template <class _InputIterator>
|
||||
void insert_equal(_InputIterator __f, _InputIterator __l)
|
||||
{ insert_equal(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIterator)); }
|
||||
|
||||
template <class _InputIterator>
|
||||
void insert_unique(_InputIterator __f, _InputIterator __l,
|
||||
const input_iterator_tag &) {
|
||||
for ( ; __f != __l; ++__f)
|
||||
insert_unique(*__f);
|
||||
}
|
||||
|
||||
template <class _InputIterator>
|
||||
void insert_equal(_InputIterator __f, _InputIterator __l,
|
||||
const input_iterator_tag &) {
|
||||
for ( ; __f != __l; ++__f)
|
||||
insert_equal(*__f);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
void insert_unique(_ForwardIterator __f, _ForwardIterator __l,
|
||||
const forward_iterator_tag &) {
|
||||
size_type __n = _STLP_STD::distance(__f, __l);
|
||||
_M_enlarge(_M_num_elements + __n);
|
||||
for ( ; __n > 0; --__n, ++__f)
|
||||
insert_unique_noresize(*__f);
|
||||
}
|
||||
|
||||
template <class _ForwardIterator>
|
||||
void insert_equal(_ForwardIterator __f, _ForwardIterator __l,
|
||||
const forward_iterator_tag &) {
|
||||
size_type __n = _STLP_STD::distance(__f, __l);
|
||||
_M_enlarge(_M_num_elements + __n);
|
||||
for ( ; __n > 0; --__n, ++__f)
|
||||
insert_equal_noresize(*__f);
|
||||
}
|
||||
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
void insert_unique(const value_type* __f, const value_type* __l) {
|
||||
size_type __n = __l - __f;
|
||||
_M_enlarge(_M_num_elements + __n);
|
||||
for ( ; __n > 0; --__n, ++__f)
|
||||
insert_unique_noresize(*__f);
|
||||
}
|
||||
|
||||
void insert_equal(const value_type* __f, const value_type* __l) {
|
||||
size_type __n = __l - __f;
|
||||
_M_enlarge(_M_num_elements + __n);
|
||||
for ( ; __n > 0; --__n, ++__f)
|
||||
insert_equal_noresize(*__f);
|
||||
}
|
||||
|
||||
void insert_unique(const_iterator __f, const_iterator __l) {
|
||||
size_type __n = _STLP_STD::distance(__f, __l);
|
||||
_M_enlarge(_M_num_elements + __n);
|
||||
for ( ; __n > 0; --__n, ++__f)
|
||||
insert_unique_noresize(*__f);
|
||||
}
|
||||
|
||||
void insert_equal(const_iterator __f, const_iterator __l) {
|
||||
size_type __n = _STLP_STD::distance(__f, __l);
|
||||
_M_enlarge(_M_num_elements + __n);
|
||||
for ( ; __n > 0; --__n, ++__f)
|
||||
insert_equal_noresize(*__f);
|
||||
}
|
||||
#endif /*_STLP_MEMBER_TEMPLATES */
|
||||
|
||||
//reference find_or_insert(const value_type& __obj);
|
||||
|
||||
private:
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
_ElemsIte _M_find(const _KT& __key) const {
|
||||
size_type __n = _M_bkt_num_key(__key);
|
||||
_ElemsIte __first(_M_buckets[__n]);
|
||||
_ElemsIte __last(_M_buckets[__n + 1]);
|
||||
for ( ; (__first != __last) && !_M_equals(_M_get_key(*__first), __key); ++__first);
|
||||
if (__first != __last)
|
||||
return __first;
|
||||
else
|
||||
return __CONST_CAST(_ElemsCont&, _M_elems).end();
|
||||
}
|
||||
|
||||
public:
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator find(const _KT& __key) { return _M_find(__key); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator find(const _KT& __key) const { return _M_find(__key); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type count(const _KT& __key) const {
|
||||
const size_type __n = _M_bkt_num_key(__key);
|
||||
|
||||
_ElemsIte __cur(_M_buckets[__n]);
|
||||
_ElemsIte __last(_M_buckets[__n + 1]);
|
||||
for (; __cur != __last; ++__cur) {
|
||||
if (_M_equals(_M_get_key(*__cur), __key)) {
|
||||
size_type __result = 1;
|
||||
for (++__cur;
|
||||
__cur != __last && _M_equals(_M_get_key(*__cur), __key);
|
||||
++__result, ++__cur);
|
||||
return __result;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<iterator, iterator> equal_range(const _KT& __key) {
|
||||
typedef pair<iterator, iterator> _Pii;
|
||||
const size_type __n = _M_bkt_num_key(__key);
|
||||
|
||||
for (_ElemsIte __first(_M_buckets[__n]), __last(_M_buckets[__n + 1]);
|
||||
__first != __last; ++__first) {
|
||||
if (_M_equals(_M_get_key(*__first), __key)) {
|
||||
_ElemsIte __cur(__first);
|
||||
for (++__cur; (__cur != __last) && _M_equals(_M_get_key(*__cur), __key); ++__cur);
|
||||
return _Pii(__first, __cur);
|
||||
}
|
||||
}
|
||||
return _Pii(end(), end());
|
||||
}
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<const_iterator, const_iterator> equal_range(const _KT& __key) const {
|
||||
typedef pair<const_iterator, const_iterator> _Pii;
|
||||
const size_type __n = _M_bkt_num_key(__key);
|
||||
|
||||
for (_ElemsIte __first(_M_buckets[__n]), __last(_M_buckets[__n + 1]);
|
||||
__first != __last; ++__first) {
|
||||
if (_M_equals(_M_get_key(*__first), __key)) {
|
||||
_ElemsIte __cur(__first);
|
||||
for (++__cur; (__cur != __last) && _M_equals(_M_get_key(*__cur), __key); ++__cur);
|
||||
return _Pii(__first, __cur);
|
||||
}
|
||||
}
|
||||
return _Pii(end(), end());
|
||||
}
|
||||
|
||||
size_type erase(const key_type& __key);
|
||||
void erase(const_iterator __it);
|
||||
void erase(const_iterator __first, const_iterator __last);
|
||||
|
||||
private:
|
||||
void _M_enlarge(size_type __n);
|
||||
void _M_reduce();
|
||||
void _M_resize();
|
||||
void _M_rehash(size_type __num_buckets);
|
||||
#if defined (_STLP_DEBUG)
|
||||
void _M_check() const;
|
||||
#endif
|
||||
|
||||
public:
|
||||
void rehash(size_type __num_buckets_hint);
|
||||
void resize(size_type __num_buckets_hint)
|
||||
{ rehash(__num_buckets_hint); }
|
||||
void clear();
|
||||
|
||||
// this is for hash_map::operator[]
|
||||
reference _M_insert(const value_type& __obj);
|
||||
|
||||
private:
|
||||
//__n is set to the first bucket that has to be modified if any
|
||||
//erase/insert operation is done after the returned iterator.
|
||||
iterator _M_before_begin(size_type &__n) const;
|
||||
|
||||
static iterator _S_before_begin(const _ElemsCont& __elems, const _BucketVector& __buckets,
|
||||
size_type &__n);
|
||||
|
||||
void _M_initialize_buckets(size_type __n) {
|
||||
const size_type __n_buckets = _STLP_PRIV _Stl_prime_type::_S_next_size(__n) + 1;
|
||||
_M_buckets.reserve(__n_buckets);
|
||||
_M_buckets.assign(__n_buckets, __STATIC_CAST(_BucketType*, 0));
|
||||
}
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type _M_bkt_num_key(const _KT& __key) const
|
||||
{ return _M_bkt_num_key(__key, bucket_count()); }
|
||||
|
||||
size_type _M_bkt_num(const value_type& __obj) const
|
||||
{ return _M_bkt_num_key(_M_get_key(__obj)); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type _M_bkt_num_key(const _KT& __key, size_type __n) const
|
||||
{ return _M_hash(__key) % __n; }
|
||||
|
||||
size_type _M_bkt_num(const value_type& __obj, size_t __n) const
|
||||
{ return _M_bkt_num_key(_M_get_key(__obj), __n); }
|
||||
|
||||
void _M_copy_from(const _Self& __ht);
|
||||
};
|
||||
|
||||
#if defined (_STLP_DEBUG)
|
||||
# undef hashtable
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_hashtable.c>
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_DEBUG)
|
||||
# include <stl/debug/_hashtable.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#define _STLP_TEMPLATE_HEADER template <class _Val, class _Key, class _HF, class _Traits, class _ExK, class _EqK, class _All>
|
||||
#define _STLP_TEMPLATE_CONTAINER hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
|
||||
#include <stl/_relops_hash_cont.h>
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#undef _STLP_TEMPLATE_HEADER
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
template <class _Val, class _Key, class _HF, class _Traits, class _ExK, class _EqK, class _All>
|
||||
struct __move_traits<hashtable<_Val, _Key, _HF, _Traits, _ExK, _EqK, _All> > {
|
||||
//Hashtables are movable:
|
||||
typedef __true_type implemented;
|
||||
|
||||
//Completeness depends on many template parameters, for the moment we consider it not complete:
|
||||
typedef __false_type complete;
|
||||
};
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_HASHTABLE_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
246
extern/STLport/5.2.1/stlport/stl/_heap.c
vendored
Normal file
246
extern/STLport/5.2.1/stlport/stl/_heap.c
vendored
Normal file
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_HEAP_C
|
||||
#define _STLP_HEAP_C
|
||||
|
||||
#ifndef _STLP_INTERNAL_HEAP_H
|
||||
# include <stl/_heap.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
|
||||
# include <stl/_iterator_base.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance, class _Tp>
|
||||
_STLP_INLINE_LOOP
|
||||
void
|
||||
__push_heap(_RandomAccessIterator __first,
|
||||
_Distance __holeIndex, _Distance __topIndex, _Tp __val)
|
||||
{
|
||||
_Distance __parent = (__holeIndex - 1) / 2;
|
||||
while (__holeIndex > __topIndex && *(__first + __parent) < __val) {
|
||||
*(__first + __holeIndex) = *(__first + __parent);
|
||||
__holeIndex = __parent;
|
||||
__parent = (__holeIndex - 1) / 2;
|
||||
}
|
||||
*(__first + __holeIndex) = __val;
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance, class _Tp>
|
||||
inline void
|
||||
__push_heap_aux(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Distance*, _Tp*)
|
||||
{
|
||||
__push_heap(__first, _Distance((__last - __first) - 1), _Distance(0),
|
||||
_Tp(*(__last - 1)));
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
void
|
||||
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
__push_heap_aux(__first, __last,
|
||||
_STLP_DISTANCE_TYPE(__first, _RandomAccessIterator), _STLP_VALUE_TYPE(__first, _RandomAccessIterator));
|
||||
}
|
||||
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance, class _Tp,
|
||||
class _Compare>
|
||||
_STLP_INLINE_LOOP
|
||||
void
|
||||
__push_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
_Distance __topIndex, _Tp __val, _Compare __comp)
|
||||
{
|
||||
_Distance __parent = (__holeIndex - 1) / 2;
|
||||
while (__holeIndex > __topIndex && __comp(*(__first + __parent), __val)) {
|
||||
_STLP_VERBOSE_ASSERT(!__comp(__val, *(__first + __parent)), _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
|
||||
*(__first + __holeIndex) = *(__first + __parent);
|
||||
__holeIndex = __parent;
|
||||
__parent = (__holeIndex - 1) / 2;
|
||||
}
|
||||
*(__first + __holeIndex) = __val;
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare,
|
||||
class _Distance, class _Tp>
|
||||
inline void
|
||||
__push_heap_aux(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Compare __comp,
|
||||
_Distance*, _Tp*)
|
||||
{
|
||||
__push_heap(__first, _Distance((__last - __first) - 1), _Distance(0),
|
||||
_Tp(*(__last - 1)), __comp);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
void
|
||||
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_Compare __comp)
|
||||
{
|
||||
__push_heap_aux(__first, __last, __comp,
|
||||
_STLP_DISTANCE_TYPE(__first, _RandomAccessIterator), _STLP_VALUE_TYPE(__first, _RandomAccessIterator));
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance, class _Tp>
|
||||
void
|
||||
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
_Distance __len, _Tp __val) {
|
||||
_Distance __topIndex = __holeIndex;
|
||||
_Distance __secondChild = 2 * __holeIndex + 2;
|
||||
while (__secondChild < __len) {
|
||||
if (*(__first + __secondChild) < *(__first + (__secondChild - 1)))
|
||||
__secondChild--;
|
||||
*(__first + __holeIndex) = *(__first + __secondChild);
|
||||
__holeIndex = __secondChild;
|
||||
__secondChild = 2 * (__secondChild + 1);
|
||||
}
|
||||
if (__secondChild == __len) {
|
||||
*(__first + __holeIndex) = *(__first + (__secondChild - 1));
|
||||
__holeIndex = __secondChild - 1;
|
||||
}
|
||||
__push_heap(__first, __holeIndex, __topIndex, __val);
|
||||
}
|
||||
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp>
|
||||
inline void
|
||||
__pop_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last, _Tp*) {
|
||||
__pop_heap(__first, __last - 1, __last - 1,
|
||||
_Tp(*(__last - 1)), _STLP_DISTANCE_TYPE(__first, _RandomAccessIterator));
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
void pop_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last) {
|
||||
__pop_heap_aux(__first, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIterator));
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance,
|
||||
class _Tp, class _Compare>
|
||||
void
|
||||
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
_Distance __len, _Tp __val, _Compare __comp)
|
||||
{
|
||||
_Distance __topIndex = __holeIndex;
|
||||
_Distance __secondChild = 2 * __holeIndex + 2;
|
||||
while (__secondChild < __len) {
|
||||
if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1)))) {
|
||||
_STLP_VERBOSE_ASSERT(!__comp(*(__first + (__secondChild - 1)), *(__first + __secondChild)),
|
||||
_StlMsg_INVALID_STRICT_WEAK_PREDICATE)
|
||||
__secondChild--;
|
||||
}
|
||||
*(__first + __holeIndex) = *(__first + __secondChild);
|
||||
__holeIndex = __secondChild;
|
||||
__secondChild = 2 * (__secondChild + 1);
|
||||
}
|
||||
if (__secondChild == __len) {
|
||||
*(__first + __holeIndex) = *(__first + (__secondChild - 1));
|
||||
__holeIndex = __secondChild - 1;
|
||||
}
|
||||
__push_heap(__first, __holeIndex, __topIndex, __val, __comp);
|
||||
}
|
||||
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp, class _Compare>
|
||||
inline void
|
||||
__pop_heap_aux(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Tp*, _Compare __comp)
|
||||
{
|
||||
__pop_heap(__first, __last - 1, __last - 1, _Tp(*(__last - 1)), __comp,
|
||||
_STLP_DISTANCE_TYPE(__first, _RandomAccessIterator));
|
||||
}
|
||||
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
void
|
||||
pop_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
__pop_heap_aux(__first, __last, _STLP_VALUE_TYPE(__first, _RandomAccessIterator), __comp);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp, class _Distance>
|
||||
_STLP_INLINE_LOOP
|
||||
void
|
||||
__make_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Tp*, _Distance*)
|
||||
{
|
||||
if (__last - __first < 2) return;
|
||||
_Distance __len = __last - __first;
|
||||
_Distance __parent = (__len - 2)/2;
|
||||
|
||||
for (;;) {
|
||||
__adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)));
|
||||
if (__parent == 0) return;
|
||||
__parent--;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
void
|
||||
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
__make_heap(__first, __last,
|
||||
_STLP_VALUE_TYPE(__first, _RandomAccessIterator), _STLP_DISTANCE_TYPE(__first, _RandomAccessIterator));
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare,
|
||||
class _Tp, class _Distance>
|
||||
_STLP_INLINE_LOOP
|
||||
void
|
||||
__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_Compare __comp, _Tp*, _Distance*)
|
||||
{
|
||||
if (__last - __first < 2) return;
|
||||
_Distance __len = __last - __first;
|
||||
_Distance __parent = (__len - 2)/2;
|
||||
|
||||
for (;;) {
|
||||
__adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)),
|
||||
__comp);
|
||||
if (__parent == 0) return;
|
||||
__parent--;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
void
|
||||
make_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
__make_heap(__first, __last, __comp,
|
||||
_STLP_VALUE_TYPE(__first, _RandomAccessIterator), _STLP_DISTANCE_TYPE(__first, _RandomAccessIterator));
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_HEAP_C */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
125
extern/STLport/5.2.1/stlport/stl/_heap.h
vendored
Normal file
125
extern/STLport/5.2.1/stlport/stl/_heap.h
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Hewlett-Packard Company makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Silicon Graphics makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_HEAP_H
|
||||
#define _STLP_INTERNAL_HEAP_H
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap.
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
void
|
||||
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last);
|
||||
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
void
|
||||
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_Compare __comp);
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance, class _Tp>
|
||||
void
|
||||
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
_Distance __len, _Tp __val);
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp, class _Distance>
|
||||
inline void
|
||||
__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_RandomAccessIterator __result, _Tp __val, _Distance*)
|
||||
{
|
||||
*__result = *__first;
|
||||
__adjust_heap(__first, _Distance(0), _Distance(__last - __first), __val);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
void pop_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last);
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance,
|
||||
class _Tp, class _Compare>
|
||||
void
|
||||
__adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
|
||||
_Distance __len, _Tp __val, _Compare __comp);
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp, class _Compare,
|
||||
class _Distance>
|
||||
inline void
|
||||
__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_RandomAccessIterator __result, _Tp __val, _Compare __comp,
|
||||
_Distance*)
|
||||
{
|
||||
*__result = *__first;
|
||||
__adjust_heap(__first, _Distance(0), _Distance(__last - __first),
|
||||
__val, __comp);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
void
|
||||
pop_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Compare __comp);
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
void
|
||||
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last);
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
void
|
||||
make_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Compare __comp);
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
_STLP_INLINE_LOOP
|
||||
void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
while (__last - __first > 1)
|
||||
pop_heap(__first, __last--);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Compare>
|
||||
_STLP_INLINE_LOOP
|
||||
void
|
||||
sort_heap(_RandomAccessIterator __first,
|
||||
_RandomAccessIterator __last, _Compare __comp)
|
||||
{
|
||||
while (__last - __first > 1)
|
||||
pop_heap(__first, __last--, __comp);
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# if !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_heap.c>
|
||||
# endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_HEAP_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
165
extern/STLport/5.2.1/stlport/stl/_iomanip.h
vendored
Normal file
165
extern/STLport/5.2.1/stlport/stl/_iomanip.h
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_IOMANIP
|
||||
#define _STLP_INTERNAL_IOMANIP
|
||||
|
||||
#ifndef _STLP_INTERNAL_ISTREAM
|
||||
# include <stl/_istream.h> // Includes <ostream> and <ios>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Machinery for defining manipulators.
|
||||
|
||||
// Class that calls one of ios_base's single-argument member functions.
|
||||
template <class _Arg>
|
||||
struct _Ios_Manip_1 {
|
||||
typedef _Arg (ios_base::*__f_ptr_type)(_Arg);
|
||||
|
||||
_Ios_Manip_1(__f_ptr_type __f, const _Arg& __arg)
|
||||
: _M_f(__f), _M_arg(__arg) {}
|
||||
|
||||
void operator()(ios_base& __ios) const
|
||||
{ (__ios.*_M_f)(_M_arg); }
|
||||
|
||||
__f_ptr_type _M_f;
|
||||
_Arg _M_arg;
|
||||
};
|
||||
|
||||
// Class that calls one of ios_base's two-argument member functions.
|
||||
struct _Ios_Setf_Manip {
|
||||
ios_base::fmtflags _M_flag;
|
||||
ios_base::fmtflags _M_mask;
|
||||
bool _M_two_args;
|
||||
|
||||
_Ios_Setf_Manip(ios_base::fmtflags __f)
|
||||
: _M_flag(__f), _M_mask(0), _M_two_args(false) {}
|
||||
|
||||
_Ios_Setf_Manip(ios_base::fmtflags __f, ios_base::fmtflags __m)
|
||||
: _M_flag(__f), _M_mask(__m), _M_two_args(true) {}
|
||||
|
||||
void operator()(ios_base& __ios) const {
|
||||
if (_M_two_args)
|
||||
__ios.setf(_M_flag, _M_mask);
|
||||
else
|
||||
__ios.setf(_M_flag);
|
||||
}
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _CharT, class _Traits, class _Arg>
|
||||
inline basic_istream<_CharT, _Traits>& _STLP_CALL
|
||||
operator>>(basic_istream<_CharT, _Traits>& __istr,
|
||||
const _STLP_PRIV _Ios_Manip_1<_Arg>& __f) {
|
||||
__f(__istr);
|
||||
return __istr;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Arg>
|
||||
inline basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os,
|
||||
const _STLP_PRIV _Ios_Manip_1<_Arg>& __f) {
|
||||
__f(__os);
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline basic_istream<_CharT, _Traits>& _STLP_CALL
|
||||
operator>>(basic_istream<_CharT, _Traits>& __istr,
|
||||
const _STLP_PRIV _Ios_Setf_Manip& __f) {
|
||||
__f(__istr);
|
||||
return __istr;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os,
|
||||
const _STLP_PRIV _Ios_Setf_Manip& __f) {
|
||||
__f(__os);
|
||||
return __os;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// The ios_base manipulators.
|
||||
inline _STLP_PRIV _Ios_Setf_Manip _STLP_CALL resetiosflags(ios_base::fmtflags __mask)
|
||||
{ return _STLP_PRIV _Ios_Setf_Manip(0, __mask); }
|
||||
|
||||
inline _STLP_PRIV _Ios_Setf_Manip _STLP_CALL setiosflags(ios_base::fmtflags __flag)
|
||||
{ return _STLP_PRIV _Ios_Setf_Manip(__flag); }
|
||||
|
||||
inline _STLP_PRIV _Ios_Setf_Manip _STLP_CALL setbase(int __n) {
|
||||
ios_base::fmtflags __base = __n == 8 ? ios_base::oct :
|
||||
__n == 10 ? ios_base::dec :
|
||||
__n == 16 ? ios_base::hex :
|
||||
ios_base::fmtflags(0);
|
||||
return _STLP_PRIV _Ios_Setf_Manip(__base, ios_base::basefield);
|
||||
}
|
||||
|
||||
inline _STLP_PRIV _Ios_Manip_1<streamsize> _STLP_CALL
|
||||
setprecision(int __n) {
|
||||
_STLP_PRIV _Ios_Manip_1<streamsize>::__f_ptr_type __f = &ios_base::precision;
|
||||
return _STLP_PRIV _Ios_Manip_1<streamsize>(__f, __n);
|
||||
}
|
||||
|
||||
inline _STLP_PRIV _Ios_Manip_1<streamsize> _STLP_CALL
|
||||
setw(int __n) {
|
||||
_STLP_PRIV _Ios_Manip_1<streamsize>::__f_ptr_type __f = &ios_base::width;
|
||||
return _STLP_PRIV _Ios_Manip_1<streamsize>(__f, __n);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// setfill, a manipulator that operates on basic_ios<> instead of ios_base.
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _CharT>
|
||||
struct _Setfill_Manip {
|
||||
_Setfill_Manip(_CharT __c) : _M_c(__c) {}
|
||||
_CharT _M_c;
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _CharT, class _CharT2, class _Traits>
|
||||
inline basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os,
|
||||
const _STLP_PRIV _Setfill_Manip<_CharT2>& __m) {
|
||||
__os.fill(__m._M_c);
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _CharT, class _CharT2, class _Traits>
|
||||
inline basic_istream<_CharT, _Traits>& _STLP_CALL
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is,
|
||||
const _STLP_PRIV _Setfill_Manip<_CharT2>& __m) {
|
||||
__is.fill(__m._M_c);
|
||||
return __is;
|
||||
}
|
||||
|
||||
template <class _CharT>
|
||||
inline _STLP_PRIV _Setfill_Manip<_CharT> _STLP_CALL setfill(_CharT __c)
|
||||
{ return _STLP_PRIV _Setfill_Manip<_CharT>(__c); }
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_IOMANIP */
|
||||
127
extern/STLport/5.2.1/stlport/stl/_ios.c
vendored
Normal file
127
extern/STLport/5.2.1/stlport/stl/_ios.c
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_IOS_C
|
||||
#define _STLP_IOS_C
|
||||
|
||||
#ifndef _STLP_INTERNAL_IOS_H
|
||||
# include <stl/_ios.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_STREAMBUF
|
||||
# include <stl/_streambuf.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_NUMPUNCT_H
|
||||
# include <stl/_numpunct.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
// basic_ios<>'s non-inline member functions
|
||||
|
||||
// Public constructor, taking a streambuf.
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ios<_CharT, _Traits>
|
||||
::basic_ios(basic_streambuf<_CharT, _Traits>* __streambuf)
|
||||
: ios_base(), _M_cached_ctype(0),
|
||||
_M_fill(_STLP_NULL_CHAR_INIT(_CharT)), _M_streambuf(0), _M_tied_ostream(0) {
|
||||
basic_ios<_CharT, _Traits>::init(__streambuf);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_streambuf<_CharT, _Traits>*
|
||||
basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<_CharT, _Traits>* __buf) {
|
||||
basic_streambuf<_CharT, _Traits>* __tmp = _M_streambuf;
|
||||
_M_streambuf = __buf;
|
||||
this->clear();
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ios<_CharT, _Traits>&
|
||||
basic_ios<_CharT, _Traits>::copyfmt(const basic_ios<_CharT, _Traits>& __x) {
|
||||
_M_invoke_callbacks(erase_event);
|
||||
_M_copy_state(__x); // Inherited from ios_base.
|
||||
_M_cached_ctype = __x._M_cached_ctype;
|
||||
_M_fill = __x._M_fill;
|
||||
_M_tied_ostream = __x._M_tied_ostream;
|
||||
_M_invoke_callbacks(copyfmt_event);
|
||||
this->_M_set_exception_mask(__x.exceptions());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
locale basic_ios<_CharT, _Traits>::imbue(const locale& __loc) {
|
||||
locale __tmp = ios_base::imbue(__loc);
|
||||
_STLP_TRY {
|
||||
if (_M_streambuf)
|
||||
_M_streambuf->pubimbue(__loc);
|
||||
|
||||
// no throwing here
|
||||
_M_cached_ctype = &use_facet<ctype<char_type> >(__loc);
|
||||
}
|
||||
_STLP_CATCH_ALL {
|
||||
__tmp = ios_base::imbue(__tmp);
|
||||
_M_handle_exception(ios_base::failbit);
|
||||
}
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
// Protected constructor and initialization functions. The default
|
||||
// constructor creates an uninitialized basic_ios, and init() initializes
|
||||
// all of the members to the values in Table 89 of the C++ standard.
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ios<_CharT, _Traits>::basic_ios()
|
||||
: ios_base(),
|
||||
_M_fill(_STLP_NULL_CHAR_INIT(_CharT)), _M_streambuf(0), _M_tied_ostream(0)
|
||||
{}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
void
|
||||
basic_ios<_CharT, _Traits>::init(basic_streambuf<_CharT, _Traits>* __sb)
|
||||
{
|
||||
this->rdbuf(__sb);
|
||||
this->imbue(locale());
|
||||
this->tie(0);
|
||||
this->_M_set_exception_mask(ios_base::goodbit);
|
||||
this->_M_clear_nothrow(__sb != 0 ? ios_base::goodbit : ios_base::badbit);
|
||||
ios_base::flags(ios_base::skipws | ios_base::dec);
|
||||
ios_base::width(0);
|
||||
ios_base::precision(6);
|
||||
this->fill(widen(' '));
|
||||
// We don't need to worry about any of the three arrays: they are
|
||||
// initialized correctly in ios_base's constructor.
|
||||
}
|
||||
|
||||
// This is never called except from within a catch clause.
|
||||
template <class _CharT, class _Traits>
|
||||
void basic_ios<_CharT, _Traits>::_M_handle_exception(ios_base::iostate __flag)
|
||||
{
|
||||
this->_M_setstate_nothrow(__flag);
|
||||
if (this->_M_get_exception_mask() & __flag)
|
||||
_STLP_RETHROW;
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_IOS_C */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
187
extern/STLport/5.2.1/stlport/stl/_ios.h
vendored
Normal file
187
extern/STLport/5.2.1/stlport/stl/_ios.h
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_INTERNAL_IOS_H
|
||||
#define _STLP_INTERNAL_IOS_H
|
||||
|
||||
|
||||
#ifndef _STLP_IOS_BASE_H
|
||||
# include <stl/_ios_base.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_CTYPE_H
|
||||
# include <stl/_ctype.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_NUMPUNCT_H
|
||||
# include <stl/_numpunct.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// Class basic_ios, a subclass of ios_base. The only important difference
|
||||
// between the two is that basic_ios is a class template, parameterized
|
||||
// by the character type. ios_base exists to factor out all of the
|
||||
// common properties that don't depend on the character type.
|
||||
|
||||
// The second template parameter, _Traits, defaults to char_traits<_CharT>.
|
||||
// The default is declared in header <iosfwd>, and it isn't declared here
|
||||
// because C++ language rules do not allow it to be declared twice.
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
class basic_ios : public ios_base {
|
||||
friend class ios_base;
|
||||
public: // Synonyms for types.
|
||||
typedef _CharT char_type;
|
||||
typedef typename _Traits::int_type int_type;
|
||||
typedef typename _Traits::pos_type pos_type;
|
||||
typedef typename _Traits::off_type off_type;
|
||||
typedef _Traits traits_type;
|
||||
|
||||
public: // Constructor, destructor.
|
||||
explicit basic_ios(basic_streambuf<_CharT, _Traits>* __streambuf);
|
||||
virtual ~basic_ios() {}
|
||||
|
||||
public: // Members from clause 27.4.4.2
|
||||
basic_ostream<_CharT, _Traits>* tie() const {
|
||||
return _M_tied_ostream;
|
||||
}
|
||||
basic_ostream<_CharT, _Traits>*
|
||||
tie(basic_ostream<char_type, traits_type>* __new_tied_ostream) {
|
||||
basic_ostream<char_type, traits_type>* __tmp = _M_tied_ostream;
|
||||
_M_tied_ostream = __new_tied_ostream;
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
basic_streambuf<_CharT, _Traits>* rdbuf() const
|
||||
{ return _M_streambuf; }
|
||||
|
||||
basic_streambuf<_CharT, _Traits>*
|
||||
rdbuf(basic_streambuf<char_type, traits_type>*);
|
||||
|
||||
// Copies __x's state to *this.
|
||||
basic_ios<_CharT, _Traits>& copyfmt(const basic_ios<_CharT, _Traits>& __x);
|
||||
|
||||
char_type fill() const { return _M_fill; }
|
||||
char_type fill(char_type __fill) {
|
||||
char_type __tmp(_M_fill);
|
||||
_M_fill = __fill;
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
public: // Members from 27.4.4.3. These four functions
|
||||
// can almost be defined in ios_base.
|
||||
|
||||
void clear(iostate __state = goodbit) {
|
||||
_M_clear_nothrow(this->rdbuf() ? __state : iostate(__state|ios_base::badbit));
|
||||
_M_check_exception_mask();
|
||||
}
|
||||
void setstate(iostate __state) { this->clear(rdstate() | __state); }
|
||||
|
||||
iostate exceptions() const { return this->_M_get_exception_mask(); }
|
||||
void exceptions(iostate __mask) {
|
||||
this->_M_set_exception_mask(__mask);
|
||||
this->clear(this->rdstate());
|
||||
}
|
||||
|
||||
public: // Locale-related member functions.
|
||||
locale imbue(const locale&);
|
||||
|
||||
inline char narrow(_CharT, char) const ;
|
||||
inline _CharT widen(char) const;
|
||||
|
||||
// Helper function that makes testing for EOF more convenient.
|
||||
static bool _STLP_CALL _S_eof(int_type __c) {
|
||||
const int_type __eof = _Traits::eof();
|
||||
return _Traits::eq_int_type(__c, __eof);
|
||||
}
|
||||
|
||||
protected:
|
||||
// Cached copy of the curent locale's ctype facet. Set by init() and imbue().
|
||||
const ctype<char_type>* _M_cached_ctype;
|
||||
|
||||
public:
|
||||
// Equivalent to &use_facet< Facet >(getloc()), but faster.
|
||||
const ctype<char_type>* _M_ctype_facet() const { return _M_cached_ctype; }
|
||||
|
||||
protected:
|
||||
basic_ios();
|
||||
|
||||
void init(basic_streambuf<_CharT, _Traits>* __streambuf);
|
||||
|
||||
public:
|
||||
|
||||
// Helper function used in istream and ostream. It is called only from
|
||||
// a catch clause.
|
||||
void _M_handle_exception(ios_base::iostate __flag);
|
||||
|
||||
private: // Data members
|
||||
char_type _M_fill; // The fill character, used for padding.
|
||||
|
||||
basic_streambuf<_CharT, _Traits>* _M_streambuf;
|
||||
basic_ostream<_CharT, _Traits>* _M_tied_ostream;
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline char
|
||||
basic_ios<_CharT, _Traits>::narrow(_CharT __c, char __default) const
|
||||
{ return _M_ctype_facet()->narrow(__c, __default); }
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _CharT
|
||||
basic_ios<_CharT, _Traits>::widen(char __c) const
|
||||
{ return _M_ctype_facet()->widen(__c); }
|
||||
|
||||
# if !defined (_STLP_NO_METHOD_SPECIALIZATION)
|
||||
_STLP_TEMPLATE_NULL
|
||||
inline char
|
||||
basic_ios<char, char_traits<char> >::narrow(char __c, char) const
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
inline char
|
||||
basic_ios<char, char_traits<char> >::widen(char __c) const
|
||||
{
|
||||
return __c;
|
||||
}
|
||||
# endif /* _STLP_NO_METHOD_SPECIALIZATION */
|
||||
|
||||
# if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_ios<char, char_traits<char> >;
|
||||
# if ! defined (_STLP_NO_WCHAR_T)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_ios<wchar_t, char_traits<wchar_t> >;
|
||||
# endif
|
||||
# endif /* _STLP_USE_TEMPLATE_EXPORT */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_ios.c>
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_IOS */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
345
extern/STLport/5.2.1/stlport/stl/_ios_base.h
vendored
Normal file
345
extern/STLport/5.2.1/stlport/stl/_ios_base.h
vendored
Normal file
@@ -0,0 +1,345 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_IOS_BASE_H
|
||||
#define _STLP_IOS_BASE_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_STDEXCEPT_BASE
|
||||
# include <stl/_stdexcept_base.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_PAIR_H
|
||||
# include <stl/_pair.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_LOCALE_H
|
||||
# include <stl/_locale.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_STRING_H
|
||||
# include <stl/_string.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// Class ios_base. This is the base class of the ios hierarchy, which
|
||||
// includes basic_istream and basic_ostream. Classes in the ios
|
||||
// hierarchy are actually quite simple: they are just glorified
|
||||
// wrapper classes. They delegate buffering and physical character
|
||||
// manipulation to the streambuf classes, and they delegate most
|
||||
// formatting tasks to a locale.
|
||||
|
||||
class _STLP_CLASS_DECLSPEC ios_base {
|
||||
public:
|
||||
|
||||
class _STLP_CLASS_DECLSPEC failure : public __Named_exception {
|
||||
public:
|
||||
explicit failure(const string&);
|
||||
virtual ~failure() _STLP_NOTHROW_INHERENTLY;
|
||||
};
|
||||
|
||||
typedef int fmtflags;
|
||||
typedef int iostate;
|
||||
typedef int openmode;
|
||||
typedef int seekdir;
|
||||
|
||||
# ifndef _STLP_NO_ANACHRONISMS
|
||||
typedef fmtflags fmt_flags;
|
||||
# endif
|
||||
|
||||
// Formatting flags.
|
||||
_STLP_STATIC_CONSTANT(int, left = 0x0001);
|
||||
_STLP_STATIC_CONSTANT(int, right = 0x0002);
|
||||
_STLP_STATIC_CONSTANT(int, internal = 0x0004);
|
||||
_STLP_STATIC_CONSTANT(int, dec = 0x0008);
|
||||
_STLP_STATIC_CONSTANT(int, hex = 0x0010);
|
||||
_STLP_STATIC_CONSTANT(int, oct = 0x0020);
|
||||
_STLP_STATIC_CONSTANT(int, fixed = 0x0040);
|
||||
_STLP_STATIC_CONSTANT(int, scientific = 0x0080);
|
||||
_STLP_STATIC_CONSTANT(int, boolalpha = 0x0100);
|
||||
_STLP_STATIC_CONSTANT(int, showbase = 0x0200);
|
||||
_STLP_STATIC_CONSTANT(int, showpoint = 0x0400);
|
||||
_STLP_STATIC_CONSTANT(int, showpos = 0x0800);
|
||||
_STLP_STATIC_CONSTANT(int, skipws = 0x1000);
|
||||
_STLP_STATIC_CONSTANT(int, unitbuf = 0x2000);
|
||||
_STLP_STATIC_CONSTANT(int, uppercase = 0x4000);
|
||||
_STLP_STATIC_CONSTANT(int, adjustfield = left | right | internal);
|
||||
_STLP_STATIC_CONSTANT(int, basefield = dec | hex | oct);
|
||||
_STLP_STATIC_CONSTANT(int, floatfield = scientific | fixed);
|
||||
|
||||
// State flags.
|
||||
_STLP_STATIC_CONSTANT(int, goodbit = 0x00);
|
||||
_STLP_STATIC_CONSTANT(int, badbit = 0x01);
|
||||
_STLP_STATIC_CONSTANT(int, eofbit = 0x02);
|
||||
_STLP_STATIC_CONSTANT(int, failbit = 0x04);
|
||||
|
||||
// Openmode flags.
|
||||
_STLP_STATIC_CONSTANT(int, __default_mode = 0x0); /* implementation detail */
|
||||
_STLP_STATIC_CONSTANT(int, app = 0x01);
|
||||
_STLP_STATIC_CONSTANT(int, ate = 0x02);
|
||||
_STLP_STATIC_CONSTANT(int, binary = 0x04);
|
||||
_STLP_STATIC_CONSTANT(int, in = 0x08);
|
||||
_STLP_STATIC_CONSTANT(int, out = 0x10);
|
||||
_STLP_STATIC_CONSTANT(int, trunc = 0x20);
|
||||
|
||||
// Seekdir flags
|
||||
_STLP_STATIC_CONSTANT(int, beg = 0x01);
|
||||
_STLP_STATIC_CONSTANT(int, cur = 0x02);
|
||||
_STLP_STATIC_CONSTANT(int, end = 0x04);
|
||||
|
||||
public: // Flag-manipulation functions.
|
||||
fmtflags flags() const { return _M_fmtflags; }
|
||||
fmtflags flags(fmtflags __flags) {
|
||||
fmtflags __tmp = _M_fmtflags;
|
||||
_M_fmtflags = __flags;
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
fmtflags setf(fmtflags __flag) {
|
||||
fmtflags __tmp = _M_fmtflags;
|
||||
_M_fmtflags |= __flag;
|
||||
return __tmp;
|
||||
}
|
||||
fmtflags setf(fmtflags __flag, fmtflags __mask) {
|
||||
fmtflags __tmp = _M_fmtflags;
|
||||
_M_fmtflags &= ~__mask;
|
||||
_M_fmtflags |= __flag & __mask;
|
||||
return __tmp;
|
||||
}
|
||||
void unsetf(fmtflags __mask) { _M_fmtflags &= ~__mask; }
|
||||
|
||||
streamsize precision() const { return _M_precision; }
|
||||
streamsize precision(streamsize __newprecision) {
|
||||
streamsize __tmp = _M_precision;
|
||||
_M_precision = __newprecision;
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
streamsize width() const { return _M_width; }
|
||||
streamsize width(streamsize __newwidth) {
|
||||
streamsize __tmp = _M_width;
|
||||
_M_width = __newwidth;
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
public: // Locales
|
||||
locale imbue(const locale&);
|
||||
locale getloc() const { return _M_locale; }
|
||||
|
||||
public: // Auxiliary storage.
|
||||
static int _STLP_CALL xalloc();
|
||||
long& iword(int __index);
|
||||
void*& pword(int __index);
|
||||
|
||||
public: // Destructor.
|
||||
virtual ~ios_base();
|
||||
|
||||
public: // Callbacks.
|
||||
enum event { erase_event, imbue_event, copyfmt_event };
|
||||
typedef void (*event_callback)(event, ios_base&, int __index);
|
||||
void register_callback(event_callback __fn, int __index);
|
||||
|
||||
public: // This member function affects only
|
||||
// the eight predefined ios objects:
|
||||
// cin, cout, etc.
|
||||
static bool _STLP_CALL sync_with_stdio(bool __sync = true);
|
||||
|
||||
public: // The C++ standard requires only that these
|
||||
// member functions be defined in basic_ios.
|
||||
// We define them in the non-template
|
||||
// base class to avoid code duplication.
|
||||
operator void*() const { return !fail() ? (void*) __CONST_CAST(ios_base*,this) : (void*) 0; }
|
||||
bool operator!() const { return fail(); }
|
||||
|
||||
iostate rdstate() const { return _M_iostate; }
|
||||
|
||||
bool good() const { return _M_iostate == 0; }
|
||||
bool eof() const { return (_M_iostate & eofbit) != 0; }
|
||||
bool fail() const { return (_M_iostate & (failbit | badbit)) != 0; }
|
||||
bool bad() const { return (_M_iostate & badbit) != 0; }
|
||||
|
||||
protected: // The functional protected interface.
|
||||
|
||||
// Copies the state of __x to *this. This member function makes it
|
||||
// possible to implement basic_ios::copyfmt without having to expose
|
||||
// ios_base's private data members. Does not copy _M_exception_mask
|
||||
// or _M_iostate.
|
||||
void _M_copy_state(const ios_base& __x);
|
||||
|
||||
void _M_setstate_nothrow(iostate __state) { _M_iostate |= __state; }
|
||||
void _M_clear_nothrow(iostate __state) { _M_iostate = __state; }
|
||||
iostate _M_get_exception_mask() const { return _M_exception_mask; }
|
||||
void _M_set_exception_mask(iostate __mask) { _M_exception_mask = __mask; }
|
||||
void _M_check_exception_mask() {
|
||||
if (_M_iostate & _M_exception_mask)
|
||||
_M_throw_failure();
|
||||
}
|
||||
|
||||
void _M_invoke_callbacks(event);
|
||||
void _STLP_FUNCTION_THROWS _M_throw_failure();
|
||||
|
||||
ios_base(); // Default constructor.
|
||||
|
||||
protected: // Initialization of the I/O system
|
||||
static void _STLP_CALL _S_initialize();
|
||||
static void _STLP_CALL _S_uninitialize();
|
||||
static bool _S_is_synced;
|
||||
|
||||
private: // Invalidate the copy constructor and
|
||||
// assignment operator.
|
||||
ios_base(const ios_base&);
|
||||
void operator=(const ios_base&);
|
||||
|
||||
private: // Data members.
|
||||
|
||||
fmtflags _M_fmtflags; // Flags
|
||||
iostate _M_iostate;
|
||||
openmode _M_openmode;
|
||||
seekdir _M_seekdir;
|
||||
iostate _M_exception_mask;
|
||||
|
||||
streamsize _M_precision;
|
||||
streamsize _M_width;
|
||||
|
||||
locale _M_locale;
|
||||
|
||||
pair<event_callback, int>* _M_callbacks;
|
||||
size_t _M_num_callbacks; // Size of the callback array.
|
||||
size_t _M_callback_index; // Index of the next available callback;
|
||||
// initially zero.
|
||||
|
||||
long* _M_iwords; // Auxiliary storage. The count is zero
|
||||
size_t _M_num_iwords; // if and only if the pointer is null.
|
||||
|
||||
void** _M_pwords;
|
||||
size_t _M_num_pwords;
|
||||
|
||||
public:
|
||||
// ----------------------------------------------------------------------
|
||||
// Nested initializer class. This is an implementation detail, but it's
|
||||
// prescribed by the standard. The static initializer object (on
|
||||
// implementations where such a thing is required) is declared in
|
||||
// <iostream>
|
||||
class _STLP_CLASS_DECLSPEC Init
|
||||
{
|
||||
public:
|
||||
Init();
|
||||
~Init();
|
||||
private:
|
||||
static long _S_count;
|
||||
friend class ios_base;
|
||||
};
|
||||
|
||||
friend class Init;
|
||||
|
||||
public:
|
||||
# ifndef _STLP_NO_ANACHRONISMS
|
||||
// 31.6 Old iostreams members [depr.ios.members]
|
||||
typedef iostate io_state;
|
||||
typedef openmode open_mode;
|
||||
typedef seekdir seek_dir;
|
||||
typedef _STLP_STD::streamoff streamoff;
|
||||
typedef _STLP_STD::streampos streampos;
|
||||
# endif
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// ios_base manipulator functions, from section 27.4.5 of the C++ standard.
|
||||
// All of them are trivial one-line wrapper functions.
|
||||
|
||||
// fmtflag manipulators, section 27.4.5.1
|
||||
inline ios_base& _STLP_CALL boolalpha(ios_base& __s)
|
||||
{ __s.setf(ios_base::boolalpha); return __s;}
|
||||
|
||||
inline ios_base& _STLP_CALL noboolalpha(ios_base& __s)
|
||||
{ __s.unsetf(ios_base::boolalpha); return __s;}
|
||||
|
||||
inline ios_base& _STLP_CALL showbase(ios_base& __s)
|
||||
{ __s.setf(ios_base::showbase); return __s;}
|
||||
|
||||
inline ios_base& _STLP_CALL noshowbase(ios_base& __s)
|
||||
{ __s.unsetf(ios_base::showbase); return __s;}
|
||||
|
||||
inline ios_base& _STLP_CALL showpoint(ios_base& __s)
|
||||
{ __s.setf(ios_base::showpoint); return __s;}
|
||||
|
||||
inline ios_base& _STLP_CALL noshowpoint(ios_base& __s)
|
||||
{ __s.unsetf(ios_base::showpoint); return __s;}
|
||||
|
||||
inline ios_base& _STLP_CALL showpos(ios_base& __s)
|
||||
{ __s.setf(ios_base::showpos); return __s;}
|
||||
|
||||
inline ios_base& _STLP_CALL noshowpos(ios_base& __s)
|
||||
{ __s.unsetf(ios_base::showpos); return __s;}
|
||||
|
||||
inline ios_base& _STLP_CALL skipws(ios_base& __s)
|
||||
{ __s.setf(ios_base::skipws); return __s;}
|
||||
|
||||
inline ios_base& _STLP_CALL noskipws(ios_base& __s)
|
||||
{ __s.unsetf(ios_base::skipws); return __s;}
|
||||
|
||||
inline ios_base& _STLP_CALL uppercase(ios_base& __s)
|
||||
{ __s.setf(ios_base::uppercase); return __s;}
|
||||
|
||||
inline ios_base& _STLP_CALL nouppercase(ios_base& __s)
|
||||
{ __s.unsetf(ios_base::uppercase); return __s;}
|
||||
|
||||
inline ios_base& _STLP_CALL unitbuf(ios_base& __s)
|
||||
{ __s.setf(ios_base::unitbuf); return __s;}
|
||||
|
||||
inline ios_base& _STLP_CALL nounitbuf(ios_base& __s)
|
||||
{ __s.unsetf(ios_base::unitbuf); return __s;}
|
||||
|
||||
|
||||
// adjustfield manipulators, section 27.4.5.2
|
||||
inline ios_base& _STLP_CALL internal(ios_base& __s)
|
||||
{ __s.setf(ios_base::internal, ios_base::adjustfield); return __s; }
|
||||
|
||||
inline ios_base& _STLP_CALL left(ios_base& __s)
|
||||
{ __s.setf(ios_base::left, ios_base::adjustfield); return __s; }
|
||||
|
||||
inline ios_base& _STLP_CALL right(ios_base& __s)
|
||||
{ __s.setf(ios_base::right, ios_base::adjustfield); return __s; }
|
||||
|
||||
// basefield manipulators, section 27.4.5.3
|
||||
inline ios_base& _STLP_CALL dec(ios_base& __s)
|
||||
{ __s.setf(ios_base::dec, ios_base::basefield); return __s; }
|
||||
|
||||
inline ios_base& _STLP_CALL hex(ios_base& __s)
|
||||
{ __s.setf(ios_base::hex, ios_base::basefield); return __s; }
|
||||
|
||||
inline ios_base& _STLP_CALL oct(ios_base& __s)
|
||||
{ __s.setf(ios_base::oct, ios_base::basefield); return __s; }
|
||||
|
||||
|
||||
// floatfield manipulators, section 27.4.5.3
|
||||
inline ios_base& _STLP_CALL fixed(ios_base& __s)
|
||||
{ __s.setf(ios_base::fixed, ios_base::floatfield); return __s; }
|
||||
|
||||
inline ios_base& _STLP_CALL scientific(ios_base& __s)
|
||||
{ __s.setf(ios_base::scientific, ios_base::floatfield); return __s; }
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_IOS_BASE */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
12
extern/STLport/5.2.1/stlport/stl/_ioserr.h
vendored
Normal file
12
extern/STLport/5.2.1/stlport/stl/_ioserr.h
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* This file is included in every header that needs the STLport library to be
|
||||
* built; the header files mostly are the iostreams-headers. The file checks for
|
||||
* _STLP_USE_NO_IOSTREAMS or _STLP_NO_IOSTREAMS being not defined, so that the
|
||||
* iostreams part of STLport cannot be used when the symbols were defined
|
||||
* accidentally.
|
||||
*/
|
||||
#if defined (_STLP_NO_IOSTREAMS)
|
||||
# error STLport iostreams header cannot be used; you chose not to use iostreams in the STLport configuration file (stlport/stl/config/user_config.h).
|
||||
#elif defined (_STLP_USE_NO_IOSTREAMS )
|
||||
# error STLport iostreams header cannot be used; your compiler do not support it.
|
||||
#endif
|
||||
159
extern/STLport/5.2.1/stlport/stl/_iosfwd.h
vendored
Normal file
159
extern/STLport/5.2.1/stlport/stl/_iosfwd.h
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
#ifndef _STLP_INTERNAL_IOSFWD
|
||||
#define _STLP_INTERNAL_IOSFWD
|
||||
|
||||
#if defined (__sgi) && !defined (__GNUC__) && !defined (_STANDARD_C_PLUS_PLUS)
|
||||
# error This header file requires the -LANG:std option
|
||||
#endif
|
||||
|
||||
// This file provides forward declarations of the most important I/O
|
||||
// classes. Note that almost all of those classes are class templates,
|
||||
// with default template arguments. According to the C++ standard,
|
||||
// if a class template is declared more than once in the same scope
|
||||
// then only one of those declarations may have default arguments.
|
||||
|
||||
// <iosfwd> contains the same declarations as other headers, and including
|
||||
// both <iosfwd> and (say) <iostream> is permitted. This means that only
|
||||
// one header may contain those default template arguments.
|
||||
|
||||
// In this implementation, the declarations in <iosfwd> contain default
|
||||
// template arguments. All of the other I/O headers include <iosfwd>.
|
||||
|
||||
#ifndef _STLP_CHAR_TRAITS_H
|
||||
# include <stl/char_traits.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
class ios_base;
|
||||
|
||||
template <class _CharT, _STLP_DFL_TMPL_PARAM(_Traits , char_traits<_CharT>) >
|
||||
class basic_ios;
|
||||
|
||||
template <class _CharT, _STLP_DFL_TMPL_PARAM(_Traits , char_traits<_CharT>) >
|
||||
class basic_streambuf;
|
||||
|
||||
template <class _CharT, _STLP_DFL_TMPL_PARAM(_Traits , char_traits<_CharT>) >
|
||||
class basic_istream;
|
||||
|
||||
template <class _CharT, _STLP_DFL_TMPL_PARAM(_Traits , char_traits<_CharT>) >
|
||||
class basic_ostream;
|
||||
|
||||
template <class _CharT, _STLP_DFL_TMPL_PARAM(_Traits , char_traits<_CharT>) >
|
||||
class basic_iostream;
|
||||
|
||||
template <class _CharT, _STLP_DFL_TMPL_PARAM( _Traits , char_traits<_CharT>),
|
||||
_STLP_DFL_TMPL_PARAM(_Allocator , allocator<_CharT>) >
|
||||
class basic_stringbuf;
|
||||
|
||||
template <class _CharT, _STLP_DFL_TMPL_PARAM(_Traits , char_traits<_CharT>),
|
||||
_STLP_DFL_TMPL_PARAM(_Allocator , allocator<_CharT>) >
|
||||
class basic_istringstream;
|
||||
|
||||
template <class _CharT, _STLP_DFL_TMPL_PARAM(_Traits , char_traits<_CharT>),
|
||||
_STLP_DFL_TMPL_PARAM(_Allocator , allocator<_CharT>) >
|
||||
class basic_ostringstream;
|
||||
|
||||
template <class _CharT, _STLP_DFL_TMPL_PARAM(_Traits , char_traits<_CharT>),
|
||||
_STLP_DFL_TMPL_PARAM(_Allocator , allocator<_CharT>) >
|
||||
class basic_stringstream;
|
||||
|
||||
template <class _CharT, _STLP_DFL_TMPL_PARAM(_Traits , char_traits<_CharT>) >
|
||||
class basic_filebuf;
|
||||
|
||||
template <class _CharT, _STLP_DFL_TMPL_PARAM(_Traits , char_traits<_CharT>) >
|
||||
class basic_ifstream;
|
||||
|
||||
template <class _CharT, _STLP_DFL_TMPL_PARAM(_Traits , char_traits<_CharT>) >
|
||||
class basic_ofstream;
|
||||
|
||||
template <class _CharT, _STLP_DFL_TMPL_PARAM(_Traits , char_traits<_CharT>) >
|
||||
class basic_fstream;
|
||||
|
||||
template <class _CharT, _STLP_DFL_TMPL_PARAM(_Traits , char_traits<_CharT>) >
|
||||
class istreambuf_iterator;
|
||||
|
||||
template <class _CharT, _STLP_DFL_TMPL_PARAM(_Traits , char_traits<_CharT>) >
|
||||
class ostreambuf_iterator;
|
||||
|
||||
typedef basic_ios<char, char_traits<char> > ios;
|
||||
|
||||
#if !defined (_STLP_NO_WCHAR_T)
|
||||
typedef basic_ios<wchar_t, char_traits<wchar_t> > wios;
|
||||
#endif
|
||||
|
||||
// Forward declaration of class locale, and of the most important facets.
|
||||
class locale;
|
||||
template <class _Facet>
|
||||
#if defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS)
|
||||
struct _Use_facet {
|
||||
const locale& __loc;
|
||||
_Use_facet(const locale& __p_loc) : __loc(__p_loc) {}
|
||||
inline const _Facet& operator *() const;
|
||||
};
|
||||
# define use_facet *_Use_facet
|
||||
#else
|
||||
inline const _Facet& use_facet(const locale&);
|
||||
#endif
|
||||
|
||||
template <class _CharT> class ctype;
|
||||
template <class _CharT> class ctype_byname;
|
||||
template <class _CharT> class collate;
|
||||
template <class _CharT> class collate_byname;
|
||||
|
||||
_STLP_TEMPLATE_NULL class ctype<char>;
|
||||
_STLP_TEMPLATE_NULL class ctype_byname<char>;
|
||||
_STLP_TEMPLATE_NULL class collate<char>;
|
||||
_STLP_TEMPLATE_NULL class collate_byname<char>;
|
||||
|
||||
#if !defined (_STLP_NO_WCHAR_T)
|
||||
_STLP_TEMPLATE_NULL class ctype<wchar_t>;
|
||||
_STLP_TEMPLATE_NULL class ctype_byname<wchar_t>;
|
||||
_STLP_TEMPLATE_NULL class collate<wchar_t>;
|
||||
_STLP_TEMPLATE_NULL class collate_byname<wchar_t>;
|
||||
#endif
|
||||
|
||||
#if !(defined (__SUNPRO_CC) && __SUNPRO_CC < 0x500 )
|
||||
// Typedefs for ordinary (narrow-character) streams.
|
||||
//_STLP_TEMPLATE_NULL class basic_streambuf<char, char_traits<char> >;
|
||||
#endif
|
||||
|
||||
typedef basic_istream<char, char_traits<char> > istream;
|
||||
typedef basic_ostream<char, char_traits<char> > ostream;
|
||||
typedef basic_iostream<char, char_traits<char> > iostream;
|
||||
typedef basic_streambuf<char,char_traits<char> > streambuf;
|
||||
|
||||
typedef basic_stringbuf<char, char_traits<char>, allocator<char> > stringbuf;
|
||||
typedef basic_istringstream<char, char_traits<char>, allocator<char> > istringstream;
|
||||
typedef basic_ostringstream<char, char_traits<char>, allocator<char> > ostringstream;
|
||||
typedef basic_stringstream<char, char_traits<char>, allocator<char> > stringstream;
|
||||
|
||||
typedef basic_filebuf<char, char_traits<char> > filebuf;
|
||||
typedef basic_ifstream<char, char_traits<char> > ifstream;
|
||||
typedef basic_ofstream<char, char_traits<char> > ofstream;
|
||||
typedef basic_fstream<char, char_traits<char> > fstream;
|
||||
|
||||
#if !defined (_STLP_NO_WCHAR_T)
|
||||
// Typedefs for wide-character streams.
|
||||
typedef basic_streambuf<wchar_t, char_traits<wchar_t> > wstreambuf;
|
||||
typedef basic_istream<wchar_t, char_traits<wchar_t> > wistream;
|
||||
typedef basic_ostream<wchar_t, char_traits<wchar_t> > wostream;
|
||||
typedef basic_iostream<wchar_t, char_traits<wchar_t> > wiostream;
|
||||
|
||||
typedef basic_stringbuf<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstringbuf;
|
||||
typedef basic_istringstream<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wistringstream;
|
||||
typedef basic_ostringstream<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wostringstream;
|
||||
typedef basic_stringstream<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstringstream;
|
||||
|
||||
typedef basic_filebuf<wchar_t, char_traits<wchar_t> > wfilebuf;
|
||||
typedef basic_ifstream<wchar_t, char_traits<wchar_t> > wifstream;
|
||||
typedef basic_ofstream<wchar_t, char_traits<wchar_t> > wofstream;
|
||||
typedef basic_fstream<wchar_t, char_traits<wchar_t> > wfstream;
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
140
extern/STLport/5.2.1/stlport/stl/_iostream_string.h
vendored
Normal file
140
extern/STLport/5.2.1/stlport/stl/_iostream_string.h
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 2004
|
||||
* Francois Dumont
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is an internal string for the STLport own iostream implementation.
|
||||
* The only diference rely on the allocator used to instanciate the basic_string.
|
||||
* Its goals is to improve performance limitating the number of dynamic allocation
|
||||
* that could occur when requesting a big float ouput for instance. This allocator
|
||||
* is not standard conformant as it has an internal state (the static buffer)
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _STLP_INTERNAL_IOSTREAM_STRING_H
|
||||
#define _STLP_INTERNAL_IOSTREAM_STRING_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALLOC_H
|
||||
# include <stl/_alloc.h>
|
||||
#endif /* _STLP_INTERNAL_ALLOC_H */
|
||||
|
||||
#ifndef _STLP_INTERNAL_STRING_H
|
||||
# include <stl/_string.h>
|
||||
#endif /* _STLP_INTERNAL_STRING_H */
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _CharT>
|
||||
class __iostring_allocator : public allocator<_CharT> {
|
||||
public:
|
||||
enum { _STR_SIZE = 256 };
|
||||
|
||||
private:
|
||||
enum { _BUF_SIZE = _STR_SIZE + 1 };
|
||||
typedef allocator<_CharT> _Base;
|
||||
_CharT _M_static_buf[_BUF_SIZE];
|
||||
|
||||
public:
|
||||
typedef typename _Base::size_type size_type;
|
||||
typedef typename _Base::pointer pointer;
|
||||
#if defined (_STLP_MEMBER_TEMPLATE_CLASSES)
|
||||
template <class _Tp1> struct rebind {
|
||||
# if !defined (_STLP_MSVC) || (_STLP_MSVC >= 1300)
|
||||
typedef __iostring_allocator<_Tp1> other;
|
||||
# else
|
||||
typedef _STLP_PRIV __iostring_allocator<_Tp1> other;
|
||||
# endif
|
||||
};
|
||||
#endif
|
||||
|
||||
_CharT* allocate(size_type __n, const void* __ptr = 0) {
|
||||
if (__n > _BUF_SIZE) {
|
||||
return _Base::allocate(__n, __ptr);
|
||||
}
|
||||
return _M_static_buf;
|
||||
}
|
||||
void deallocate(pointer __p, size_type __n) {
|
||||
if (__p != _M_static_buf) _Base::deallocate(__p, __n);
|
||||
}
|
||||
};
|
||||
|
||||
#if defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) || !defined (_STLP_MEMBER_TEMPLATES)
|
||||
/*
|
||||
* As the __iostring_allocator allocator will only be used in the basic_string implementation
|
||||
* we known that it is never going to be bound to another type that the one used to instantiate
|
||||
* the basic_string. This is why the associated __stl_alloc_rebind has only one template
|
||||
* parameter.
|
||||
*/
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _Tp>
|
||||
inline _STLP_PRIV __iostring_allocator<_Tp>& _STLP_CALL
|
||||
__stl_alloc_rebind(_STLP_PRIV __iostring_allocator<_Tp>& __a, const _Tp*)
|
||||
{ return __a; }
|
||||
template <class _Tp>
|
||||
inline _STLP_PRIV __iostring_allocator<_Tp> _STLP_CALL
|
||||
__stl_alloc_create(const _STLP_PRIV __iostring_allocator<_Tp>&, const _Tp*)
|
||||
{ return _STLP_PRIV __iostring_allocator<_Tp>(); }
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
#endif /* _STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE */
|
||||
|
||||
#if !defined (_STLP_DEBUG)
|
||||
template <class _CharT>
|
||||
struct __basic_iostring : public basic_string<_CharT, char_traits<_CharT>, __iostring_allocator<_CharT> > {
|
||||
/*
|
||||
* A consequence of the non standard conformant allocator is that a string using it
|
||||
* must always be presized to the allocator static buffer size because the basic_string implementation
|
||||
* do not manage an allocator returning always the same memory adress as long as the
|
||||
* requested memory block size is under a certain value.
|
||||
*/
|
||||
typedef __basic_iostring<_CharT> _Self;
|
||||
typedef basic_string<_CharT, char_traits<_CharT>, __iostring_allocator<_CharT> > _Base;
|
||||
typedef typename _Base::_Reserve_t _Reserve_t;
|
||||
|
||||
__basic_iostring() : _Base(_Reserve_t(), __iostring_allocator<_CharT>::_STR_SIZE)
|
||||
{}
|
||||
|
||||
_Self& operator=(const _CharT* __s) {
|
||||
_Base::operator=(__s);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
typedef __basic_iostring<char> __iostring;
|
||||
|
||||
# if !defined (_STLP_NO_WCHAR_T)
|
||||
typedef __basic_iostring<wchar_t> __iowstring;
|
||||
# endif
|
||||
|
||||
# define _STLP_BASIC_IOSTRING(_CharT) _STLP_PRIV __basic_iostring<_CharT>
|
||||
|
||||
#else
|
||||
|
||||
typedef string __iostring;
|
||||
# if !defined (_STLP_NO_WCHAR_T)
|
||||
typedef wstring __iowstring;
|
||||
# endif
|
||||
|
||||
# define _STLP_BASIC_IOSTRING(_CharT) basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >
|
||||
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_IOSTREAM_STRING_H */
|
||||
1429
extern/STLport/5.2.1/stlport/stl/_istream.c
vendored
Normal file
1429
extern/STLport/5.2.1/stlport/stl/_istream.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
359
extern/STLport/5.2.1/stlport/stl/_istream.h
vendored
Normal file
359
extern/STLport/5.2.1/stlport/stl/_istream.h
vendored
Normal file
@@ -0,0 +1,359 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_INTERNAL_ISTREAM
|
||||
#define _STLP_INTERNAL_ISTREAM
|
||||
|
||||
// this block is included by _ostream.h, we include it here to lower #include level
|
||||
#if defined (_STLP_HAS_WCHAR_T) && !defined (_STLP_INTERNAL_CWCHAR)
|
||||
# include <stl/_cwchar.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_IOS_H
|
||||
# include <stl/_ios.h> // For basic_ios<>. Includes <iosfwd>.
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_OSTREAM_H
|
||||
# include <stl/_ostream.h> // Needed as a base class of basic_iostream.
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
|
||||
# include <stl/_istreambuf_iterator.h>
|
||||
#endif
|
||||
|
||||
#include <stl/_ctraits_fns.h> // Helper functions that allow char traits
|
||||
// to be used as function objects.
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
template <class _CharT, class _Traits>
|
||||
class _Isentry;
|
||||
#endif
|
||||
|
||||
struct _No_Skip_WS {}; // Dummy class used by sentry.
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
bool _M_init_skip(basic_istream<_CharT, _Traits>& __istr);
|
||||
template <class _CharT, class _Traits>
|
||||
bool _M_init_noskip(basic_istream<_CharT, _Traits>& __istr);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class basic_istream, a class that performs formatted input through
|
||||
// a stream buffer.
|
||||
|
||||
// The second template parameter, _Traits, defaults to char_traits<_CharT>.
|
||||
// The default is declared in header <iosfwd>, and it isn't declared here
|
||||
// because C++ language rules do not allow it to be declared twice.
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
class basic_istream : virtual public basic_ios<_CharT, _Traits> {
|
||||
typedef basic_istream<_CharT, _Traits> _Self;
|
||||
|
||||
#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1300 && _STLP_MSVC <= 1310)
|
||||
//explicitely defined as private to avoid warnings:
|
||||
basic_istream(_Self const&);
|
||||
_Self& operator = (_Self const&);
|
||||
#endif
|
||||
|
||||
public:
|
||||
// Types
|
||||
typedef _CharT char_type;
|
||||
typedef typename _Traits::int_type int_type;
|
||||
typedef typename _Traits::pos_type pos_type;
|
||||
typedef typename _Traits::off_type off_type;
|
||||
typedef _Traits traits_type;
|
||||
typedef basic_ios<_CharT, _Traits> _Basic_ios;
|
||||
|
||||
typedef basic_ios<_CharT, _Traits>& (_STLP_CALL *__ios_fn)(basic_ios<_CharT, _Traits>&);
|
||||
typedef ios_base& (_STLP_CALL *__ios_base_fn)(ios_base&);
|
||||
typedef _Self& (_STLP_CALL *__istream_fn)(_Self&);
|
||||
|
||||
public: // Constructor and destructor.
|
||||
explicit basic_istream(basic_streambuf<_CharT, _Traits>* __buf) :
|
||||
basic_ios<_CharT, _Traits>(), _M_gcount(0) {
|
||||
this->init(__buf);
|
||||
}
|
||||
~basic_istream() {};
|
||||
|
||||
public: // Nested sentry class.
|
||||
|
||||
public: // Hooks for manipulators. The arguments are
|
||||
// function pointers.
|
||||
_Self& operator>> (__istream_fn __f) { return __f(*this); }
|
||||
_Self& operator>> (__ios_fn __f) { __f(*this); return *this; }
|
||||
_Self& operator>> (__ios_base_fn __f) { __f(*this); return *this; }
|
||||
|
||||
public: // Formatted input of numbers.
|
||||
_Self& operator>> (short& __val);
|
||||
_Self& operator>> (int& __val);
|
||||
_Self& operator>> (unsigned short& __val);
|
||||
_Self& operator>> (unsigned int& __val);
|
||||
_Self& operator>> (long& __val);
|
||||
_Self& operator>> (unsigned long& __val);
|
||||
#ifdef _STLP_LONG_LONG
|
||||
_Self& operator>> (_STLP_LONG_LONG& __val);
|
||||
_Self& operator>> (unsigned _STLP_LONG_LONG& __val);
|
||||
#endif
|
||||
_Self& operator>> (float& __val);
|
||||
_Self& operator>> (double& __val);
|
||||
# ifndef _STLP_NO_LONG_DOUBLE
|
||||
_Self& operator>> (long double& __val);
|
||||
# endif
|
||||
# ifndef _STLP_NO_BOOL
|
||||
_Self& operator>> (bool& __val);
|
||||
# endif
|
||||
_Self& operator>> (void*& __val);
|
||||
|
||||
public: // Copying characters into a streambuf.
|
||||
_Self& operator>>(basic_streambuf<_CharT, _Traits>*);
|
||||
|
||||
public: // Unformatted input.
|
||||
streamsize gcount() const { return _M_gcount; }
|
||||
int_type peek();
|
||||
|
||||
public: // get() for single characters
|
||||
int_type get();
|
||||
_Self& get(char_type& __c);
|
||||
|
||||
public: // get() for character arrays.
|
||||
_Self& get(char_type* __s, streamsize __n, char_type __delim);
|
||||
_Self& get(char_type* __s, streamsize __n)
|
||||
{ return get(__s, __n, this->widen('\n')); }
|
||||
|
||||
public: // get() for streambufs
|
||||
_Self& get(basic_streambuf<_CharT, _Traits>& __buf,
|
||||
char_type __delim);
|
||||
_Self& get(basic_streambuf<_CharT, _Traits>& __buf)
|
||||
{ return get(__buf, this->widen('\n')); }
|
||||
|
||||
public: // getline()
|
||||
_Self& getline(char_type* __s, streamsize __n, char_type delim);
|
||||
_Self& getline(char_type* __s, streamsize __n)
|
||||
{ return getline(__s, __n, this->widen('\n')); }
|
||||
|
||||
public: // read(), readsome(), ignore()
|
||||
_Self& ignore();
|
||||
_Self& ignore(streamsize __n);
|
||||
_Self& ignore(streamsize __n, int_type __delim);
|
||||
|
||||
_Self& read(char_type* __s, streamsize __n);
|
||||
streamsize readsome(char_type* __s, streamsize __n);
|
||||
|
||||
public: // putback
|
||||
_Self& putback(char_type __c);
|
||||
_Self& unget();
|
||||
|
||||
public: // Positioning and buffer control.
|
||||
int sync();
|
||||
|
||||
pos_type tellg();
|
||||
_Self& seekg(pos_type __pos);
|
||||
_Self& seekg(off_type, ios_base::seekdir);
|
||||
|
||||
public: // Helper functions for non-member extractors.
|
||||
void _M_formatted_get(_CharT& __c);
|
||||
void _M_formatted_get(_CharT* __s);
|
||||
void _M_skip_whitespace(bool __set_failbit);
|
||||
|
||||
private: // Number of characters extracted by the
|
||||
streamsize _M_gcount; // most recent unformatted input function.
|
||||
|
||||
public:
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
// If we are using DLL specs, we have not to use inner classes
|
||||
// end class declaration here
|
||||
typedef _Isentry<_CharT, _Traits> sentry;
|
||||
};
|
||||
# define sentry _Isentry
|
||||
template <class _CharT, class _Traits>
|
||||
class _Isentry {
|
||||
typedef _Isentry<_CharT, _Traits> _Self;
|
||||
# else
|
||||
class sentry {
|
||||
typedef sentry _Self;
|
||||
#endif
|
||||
|
||||
private:
|
||||
const bool _M_ok;
|
||||
// basic_streambuf<_CharT, _Traits>* _M_buf;
|
||||
|
||||
public:
|
||||
typedef _Traits traits_type;
|
||||
|
||||
explicit sentry(basic_istream<_CharT, _Traits>& __istr,
|
||||
bool __noskipws = false) :
|
||||
_M_ok((__noskipws || !(__istr.flags() & ios_base::skipws)) ? _M_init_noskip(__istr) : _M_init_skip(__istr) )
|
||||
/* , _M_buf(__istr.rdbuf()) */
|
||||
{}
|
||||
|
||||
// Calling this constructor is the same as calling the previous one with
|
||||
// __noskipws = true, except that it doesn't require a runtime test.
|
||||
sentry(basic_istream<_CharT, _Traits>& __istr, _No_Skip_WS) : /* _M_buf(__istr.rdbuf()), */
|
||||
_M_ok(_M_init_noskip(__istr)) {}
|
||||
|
||||
~sentry() {}
|
||||
|
||||
operator bool() const { return _M_ok; }
|
||||
|
||||
private: // Disable assignment and copy constructor.
|
||||
//Implementation is here only to avoid warning with some compilers.
|
||||
sentry(const _Self&) : _M_ok(false) {}
|
||||
_Self& operator=(const _Self&) { return *this; }
|
||||
};
|
||||
|
||||
# if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
# undef sentry
|
||||
# else
|
||||
// close basic_istream class definition here
|
||||
};
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS _Isentry<char, char_traits<char> >;
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_istream<char, char_traits<char> >;
|
||||
# if ! defined (_STLP_NO_WCHAR_T)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS _Isentry<wchar_t, char_traits<wchar_t> >;
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_istream<wchar_t, char_traits<wchar_t> >;
|
||||
# endif
|
||||
# endif /* _STLP_USE_TEMPLATE_EXPORT */
|
||||
|
||||
// Non-member character and string extractor functions.
|
||||
template <class _CharT, class _Traits>
|
||||
inline basic_istream<_CharT, _Traits>& _STLP_CALL
|
||||
operator>>(basic_istream<_CharT, _Traits>& __in_str, _CharT& __c) {
|
||||
__in_str._M_formatted_get(__c);
|
||||
return __in_str;
|
||||
}
|
||||
|
||||
template <class _Traits>
|
||||
inline basic_istream<char, _Traits>& _STLP_CALL
|
||||
operator>>(basic_istream<char, _Traits>& __in_str, unsigned char& __c) {
|
||||
__in_str._M_formatted_get(__REINTERPRET_CAST(char&,__c));
|
||||
return __in_str;
|
||||
}
|
||||
|
||||
template <class _Traits>
|
||||
inline basic_istream<char, _Traits>& _STLP_CALL
|
||||
operator>>(basic_istream<char, _Traits>& __in_str, signed char& __c) {
|
||||
__in_str._M_formatted_get(__REINTERPRET_CAST(char&,__c));
|
||||
return __in_str;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline basic_istream<_CharT, _Traits>& _STLP_CALL
|
||||
operator>>(basic_istream<_CharT, _Traits>& __in_str, _CharT* __s) {
|
||||
__in_str._M_formatted_get(__s);
|
||||
return __in_str;
|
||||
}
|
||||
|
||||
template <class _Traits>
|
||||
inline basic_istream<char, _Traits>& _STLP_CALL
|
||||
operator>>(basic_istream<char, _Traits>& __in_str, unsigned char* __s) {
|
||||
__in_str._M_formatted_get(__REINTERPRET_CAST(char*,__s));
|
||||
return __in_str;
|
||||
}
|
||||
|
||||
template <class _Traits>
|
||||
inline basic_istream<char, _Traits>& _STLP_CALL
|
||||
operator>>(basic_istream<char, _Traits>& __in_str, signed char* __s) {
|
||||
__in_str._M_formatted_get(__REINTERPRET_CAST(char*,__s));
|
||||
return __in_str;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// istream manipulator.
|
||||
template <class _CharT, class _Traits>
|
||||
basic_istream<_CharT, _Traits>& _STLP_CALL
|
||||
ws(basic_istream<_CharT, _Traits>& __istr) {
|
||||
if (!__istr.eof()) {
|
||||
typedef typename basic_istream<_CharT, _Traits>::sentry _Sentry;
|
||||
_Sentry __sentry(__istr, _No_Skip_WS()); // Don't skip whitespace.
|
||||
if (__sentry)
|
||||
__istr._M_skip_whitespace(false);
|
||||
}
|
||||
return __istr;
|
||||
}
|
||||
|
||||
// Helper functions for istream<>::sentry constructor.
|
||||
template <class _CharT, class _Traits>
|
||||
inline bool _M_init_skip(basic_istream<_CharT, _Traits>& __istr) {
|
||||
if (__istr.good()) {
|
||||
if (__istr.tie())
|
||||
__istr.tie()->flush();
|
||||
|
||||
__istr._M_skip_whitespace(true);
|
||||
}
|
||||
|
||||
if (!__istr.good()) {
|
||||
__istr.setstate(ios_base::failbit);
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline bool _M_init_noskip(basic_istream<_CharT, _Traits>& __istr) {
|
||||
if (__istr.good()) {
|
||||
if (__istr.tie())
|
||||
__istr.tie()->flush();
|
||||
|
||||
if (!__istr.rdbuf())
|
||||
__istr.setstate(ios_base::badbit);
|
||||
}
|
||||
else
|
||||
__istr.setstate(ios_base::failbit);
|
||||
return __istr.good();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class iostream.
|
||||
template <class _CharT, class _Traits>
|
||||
class basic_iostream
|
||||
: public basic_istream<_CharT, _Traits>,
|
||||
public basic_ostream<_CharT, _Traits>
|
||||
{
|
||||
public:
|
||||
typedef basic_ios<_CharT, _Traits> _Basic_ios;
|
||||
|
||||
explicit basic_iostream(basic_streambuf<_CharT, _Traits>* __buf);
|
||||
virtual ~basic_iostream();
|
||||
};
|
||||
|
||||
# if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_iostream<char, char_traits<char> >;
|
||||
|
||||
# if ! defined (_STLP_NO_WCHAR_T)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_iostream<wchar_t, char_traits<wchar_t> >;
|
||||
# endif
|
||||
# endif /* _STLP_USE_TEMPLATE_EXPORT */
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_streambuf<_CharT, _Traits>* _STLP_CALL _M_get_istreambuf(basic_istream<_CharT, _Traits>& __istr)
|
||||
{ return __istr.rdbuf(); }
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_istream.c>
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_ISTREAM */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
161
extern/STLport/5.2.1/stlport/stl/_istreambuf_iterator.h
vendored
Normal file
161
extern/STLport/5.2.1/stlport/stl/_istreambuf_iterator.h
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
// WARNING: This is an internal header file, included by other C++
|
||||
// standard library headers. You should not attempt to use this header
|
||||
// file directly.
|
||||
|
||||
|
||||
#ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
|
||||
#define _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
|
||||
# include <stl/_iterator_base.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_STREAMBUF
|
||||
# include <stl/_streambuf.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
// defined in _istream.h
|
||||
template <class _CharT, class _Traits>
|
||||
extern basic_streambuf<_CharT, _Traits>* _STLP_CALL _M_get_istreambuf(basic_istream<_CharT, _Traits>& ) ;
|
||||
|
||||
// We do not read any characters until operator* is called. operator* calls sgetc
|
||||
// unless the iterator is unchanged from the last call in which case a cached value is
|
||||
// used. Calls to operator++ use sbumpc.
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
class istreambuf_iterator :
|
||||
public iterator<input_iterator_tag, _CharT, typename _Traits::off_type, _CharT*, _CharT&>
|
||||
{
|
||||
public:
|
||||
typedef _CharT char_type;
|
||||
typedef _Traits traits_type;
|
||||
typedef typename _Traits::int_type int_type;
|
||||
typedef basic_streambuf<_CharT, _Traits> streambuf_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:
|
||||
istreambuf_iterator(streambuf_type* __p = 0) { this->_M_init(__p); }
|
||||
// istreambuf_iterator(basic_istream<_CharT, _Traits>& __is) { this->_M_init(_M_get_istreambuf(__is)); }
|
||||
inline istreambuf_iterator(basic_istream<_CharT, _Traits>& __is);
|
||||
|
||||
char_type operator*() const { this->_M_getc(); return _M_c; }
|
||||
istreambuf_iterator<_CharT, _Traits>& operator++() {
|
||||
_M_buf->sbumpc();
|
||||
_M_have_c = false;
|
||||
return *this;
|
||||
}
|
||||
istreambuf_iterator<_CharT, _Traits> operator++(int);
|
||||
|
||||
bool equal(const istreambuf_iterator<_CharT, _Traits>& __i) const {
|
||||
if (this->_M_buf)
|
||||
this->_M_getc();
|
||||
if (__i._M_buf)
|
||||
__i._M_getc();
|
||||
return this->_M_eof == __i._M_eof;
|
||||
}
|
||||
|
||||
private:
|
||||
void _M_init(streambuf_type* __p) {
|
||||
_M_buf = __p;
|
||||
_M_eof = (__p == 0);
|
||||
_M_have_c = false;
|
||||
}
|
||||
|
||||
void _M_getc() const {
|
||||
if (_M_have_c)
|
||||
return;
|
||||
int_type __c = _M_buf->sgetc();
|
||||
_STLP_MUTABLE(_Self, _M_c) = traits_type::to_char_type(__c);
|
||||
_STLP_MUTABLE(_Self, _M_eof) = traits_type::eq_int_type(__c, traits_type::eof());
|
||||
_STLP_MUTABLE(_Self, _M_have_c) = true;
|
||||
}
|
||||
|
||||
private:
|
||||
streambuf_type* _M_buf;
|
||||
mutable _CharT _M_c;
|
||||
mutable bool _M_eof;
|
||||
mutable bool _M_have_c;
|
||||
};
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
inline istreambuf_iterator<_CharT, _Traits>::istreambuf_iterator(basic_istream<_CharT, _Traits>& __is)
|
||||
{ this->_M_init(_M_get_istreambuf(__is)); }
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
inline bool _STLP_CALL operator==(const istreambuf_iterator<_CharT, _Traits>& __x,
|
||||
const istreambuf_iterator<_CharT, _Traits>& __y) {
|
||||
return __x.equal(__y);
|
||||
}
|
||||
|
||||
#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
inline bool _STLP_CALL operator!=(const istreambuf_iterator<_CharT, _Traits>& __x,
|
||||
const istreambuf_iterator<_CharT, _Traits>& __y) {
|
||||
return !__x.equal(__y);
|
||||
}
|
||||
|
||||
#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
|
||||
|
||||
# if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS istreambuf_iterator<char, char_traits<char> >;
|
||||
# if defined (INSTANTIATE_WIDE_STREAMS)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS istreambuf_iterator<wchar_t, char_traits<wchar_t> >;
|
||||
# endif
|
||||
# endif /* _STLP_USE_TEMPLATE_EXPORT */
|
||||
|
||||
# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
|
||||
template <class _CharT, class _Traits>
|
||||
inline input_iterator_tag _STLP_CALL iterator_category(const istreambuf_iterator<_CharT, _Traits>&) { return input_iterator_tag(); }
|
||||
template <class _CharT, class _Traits>
|
||||
inline streamoff* _STLP_CALL
|
||||
distance_type(const istreambuf_iterator<_CharT, _Traits>&) { return (streamoff*)0; }
|
||||
template <class _CharT, class _Traits>
|
||||
inline _CharT* _STLP_CALL value_type(const istreambuf_iterator<_CharT, _Traits>&) { return (_CharT*)0; }
|
||||
# endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
istreambuf_iterator<_CharT, _Traits>
|
||||
istreambuf_iterator<_CharT, _Traits>::operator++(int) {
|
||||
_M_getc(); // __tmp should avoid any future actions under
|
||||
// underlined buffer---during call of operator *()
|
||||
// (due to buffer for *this and __tmp are the same).
|
||||
istreambuf_iterator<_CharT, _Traits> __tmp = *this;
|
||||
_M_buf->sbumpc();
|
||||
_M_have_c = false;
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
265
extern/STLport/5.2.1/stlport/stl/_iterator.h
vendored
Normal file
265
extern/STLport/5.2.1/stlport/stl/_iterator.h
vendored
Normal file
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996-1998
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_H
|
||||
#define _STLP_INTERNAL_ITERATOR_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
|
||||
# include <stl/_iterator_base.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
// This is the new version of reverse_iterator, as defined in the
|
||||
// draft C++ standard. It relies on the iterator_traits template,
|
||||
// which in turn relies on partial specialization. The class
|
||||
// reverse_bidirectional_iterator is no longer part of the draft
|
||||
// standard, but it is retained for backward compatibility.
|
||||
|
||||
template <class _Iterator>
|
||||
class reverse_iterator :
|
||||
public iterator<typename iterator_traits<_Iterator>::iterator_category,
|
||||
typename iterator_traits<_Iterator>::value_type,
|
||||
typename iterator_traits<_Iterator>::difference_type,
|
||||
typename iterator_traits<_Iterator>::pointer,
|
||||
typename iterator_traits<_Iterator>::reference> {
|
||||
protected:
|
||||
_Iterator current;
|
||||
typedef reverse_iterator<_Iterator> _Self;
|
||||
public:
|
||||
typedef typename iterator_traits<_Iterator>::difference_type difference_type;
|
||||
// pointer type required for arrow operator hidden behind _STLP_DEFINE_ARROW_OPERATOR:
|
||||
typedef typename iterator_traits<_Iterator>::pointer pointer;
|
||||
typedef typename iterator_traits<_Iterator>::reference reference;
|
||||
typedef _Iterator iterator_type;
|
||||
public:
|
||||
reverse_iterator() {}
|
||||
explicit reverse_iterator(iterator_type __x) : current(__x) {}
|
||||
reverse_iterator(const _Self& __x) : current(__x.current) {}
|
||||
_Self& operator = (const _Self& __x) { current = __x.base(); return *this; }
|
||||
# if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _Iter>
|
||||
reverse_iterator(const reverse_iterator<_Iter>& __x) : current(__x.base()) {}
|
||||
template <class _Iter>
|
||||
_Self& operator = (const reverse_iterator<_Iter>& __x) { current = __x.base(); return *this; }
|
||||
# endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
iterator_type base() const { return current; }
|
||||
reference operator*() const {
|
||||
_Iterator __tmp = current;
|
||||
return *--__tmp;
|
||||
}
|
||||
_STLP_DEFINE_ARROW_OPERATOR
|
||||
_Self& operator++() {
|
||||
--current;
|
||||
return *this;
|
||||
}
|
||||
_Self operator++(int) {
|
||||
_Self __tmp = *this;
|
||||
--current;
|
||||
return __tmp;
|
||||
}
|
||||
_Self& operator--() {
|
||||
++current;
|
||||
return *this;
|
||||
}
|
||||
_Self operator--(int) {
|
||||
_Self __tmp = *this;
|
||||
++current;
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
_Self operator+(difference_type __n) const { return _Self(current - __n); }
|
||||
_Self& operator+=(difference_type __n) {
|
||||
current -= __n;
|
||||
return *this;
|
||||
}
|
||||
_Self operator-(difference_type __n) const { return _Self(current + __n); }
|
||||
_Self& operator-=(difference_type __n) {
|
||||
current += __n;
|
||||
return *this;
|
||||
}
|
||||
reference operator[](difference_type __n) const { return *(*this + __n); }
|
||||
};
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL operator==(const reverse_iterator<_Iterator>& __x,
|
||||
const reverse_iterator<_Iterator>& __y)
|
||||
{ return __x.base() == __y.base(); }
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL operator<(const reverse_iterator<_Iterator>& __x,
|
||||
const reverse_iterator<_Iterator>& __y)
|
||||
{ return __y.base() < __x.base(); }
|
||||
|
||||
# if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL operator!=(const reverse_iterator<_Iterator>& __x,
|
||||
const reverse_iterator<_Iterator>& __y)
|
||||
{ return !(__x == __y); }
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL operator>(const reverse_iterator<_Iterator>& __x,
|
||||
const reverse_iterator<_Iterator>& __y)
|
||||
{ return __y < __x; }
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL operator<=(const reverse_iterator<_Iterator>& __x,
|
||||
const reverse_iterator<_Iterator>& __y)
|
||||
{ return !(__y < __x); }
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL operator>=(const reverse_iterator<_Iterator>& __x,
|
||||
const reverse_iterator<_Iterator>& __y)
|
||||
{ return !(__x < __y); }
|
||||
# endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
|
||||
|
||||
template <class _Iterator>
|
||||
# if defined (__SUNPRO_CC)
|
||||
inline ptrdiff_t _STLP_CALL
|
||||
# else
|
||||
inline typename reverse_iterator<_Iterator>::difference_type _STLP_CALL
|
||||
# endif
|
||||
operator-(const reverse_iterator<_Iterator>& __x,
|
||||
const reverse_iterator<_Iterator>& __y)
|
||||
{ return __y.base() - __x.base(); }
|
||||
|
||||
template <class _Iterator, class _DifferenceType>
|
||||
inline reverse_iterator<_Iterator> _STLP_CALL
|
||||
operator+(_DifferenceType n,const reverse_iterator<_Iterator>& x)
|
||||
{ return x.operator+(n); }
|
||||
#endif
|
||||
|
||||
template <class _Container>
|
||||
class back_insert_iterator
|
||||
: public iterator<output_iterator_tag, void, void, void, void> {
|
||||
typedef back_insert_iterator<_Container> _Self;
|
||||
protected:
|
||||
//c is a Standard name (24.4.2.1), do no make it STLport naming convention compliant.
|
||||
_Container *container;
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
typedef output_iterator_tag iterator_category;
|
||||
|
||||
explicit back_insert_iterator(_Container& __x) : container(&__x) {}
|
||||
|
||||
_Self& operator=(const _Self& __other) {
|
||||
container = __other.container;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator=(const typename _Container::value_type& __val) {
|
||||
container->push_back(__val);
|
||||
return *this;
|
||||
}
|
||||
_Self& operator*() { return *this; }
|
||||
_Self& operator++() { return *this; }
|
||||
_Self operator++(int) { return *this; }
|
||||
};
|
||||
|
||||
template <class _Container>
|
||||
inline back_insert_iterator<_Container> _STLP_CALL back_inserter(_Container& __x)
|
||||
{ return back_insert_iterator<_Container>(__x); }
|
||||
|
||||
template <class _Container>
|
||||
class front_insert_iterator
|
||||
: public iterator<output_iterator_tag, void, void, void, void> {
|
||||
typedef front_insert_iterator<_Container> _Self;
|
||||
protected:
|
||||
//c is a Standard name (24.4.2.3), do no make it STLport naming convention compliant.
|
||||
_Container *container;
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
typedef output_iterator_tag iterator_category;
|
||||
explicit front_insert_iterator(_Container& __x) : container(&__x) {}
|
||||
|
||||
_Self& operator=(const _Self& __other) {
|
||||
container = __other.container;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator=(const typename _Container::value_type& __val) {
|
||||
container->push_front(__val);
|
||||
return *this;
|
||||
}
|
||||
_Self& operator*() { return *this; }
|
||||
_Self& operator++() { return *this; }
|
||||
_Self operator++(int) { return *this; }
|
||||
};
|
||||
|
||||
template <class _Container>
|
||||
inline front_insert_iterator<_Container> _STLP_CALL front_inserter(_Container& __x)
|
||||
{ return front_insert_iterator<_Container>(__x); }
|
||||
|
||||
template <class _Container>
|
||||
class insert_iterator
|
||||
: public iterator<output_iterator_tag, void, void, void, void> {
|
||||
typedef insert_iterator<_Container> _Self;
|
||||
protected:
|
||||
//container is a Standard name (24.4.2.5), do no make it STLport naming convention compliant.
|
||||
_Container *container;
|
||||
typename _Container::iterator _M_iter;
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
typedef output_iterator_tag iterator_category;
|
||||
insert_iterator(_Container& __x, typename _Container::iterator __i)
|
||||
: container(&__x), _M_iter(__i) {}
|
||||
|
||||
_Self& operator=(_Self const& __other) {
|
||||
container = __other.container;
|
||||
_M_iter = __other._M_iter;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator=(const typename _Container::value_type& __val) {
|
||||
_M_iter = container->insert(_M_iter, __val);
|
||||
++_M_iter;
|
||||
return *this;
|
||||
}
|
||||
_Self& operator*() { return *this; }
|
||||
_Self& operator++() { return *this; }
|
||||
_Self& operator++(int) { return *this; }
|
||||
};
|
||||
|
||||
template <class _Container, class _Iterator>
|
||||
inline insert_iterator<_Container> _STLP_CALL
|
||||
inserter(_Container& __x, _Iterator __i) {
|
||||
typedef typename _Container::iterator __iter;
|
||||
return insert_iterator<_Container>(__x, __iter(__i));
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if ! defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) || defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
|
||||
# include <stl/_iterator_old.h>
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_ITERATOR_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
525
extern/STLport/5.2.1/stlport/stl/_iterator_base.h
vendored
Normal file
525
extern/STLport/5.2.1/stlport/stl/_iterator_base.h
vendored
Normal file
@@ -0,0 +1,525 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996-1998
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
|
||||
#define _STLP_INTERNAL_ITERATOR_BASE_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSTDDEF
|
||||
# include <stl/_cstddef.h>
|
||||
#endif
|
||||
|
||||
//# if defined (_STLP_IMPORT_VENDOR_CSTD) && ! defined (_STLP_VENDOR_GLOBAL_CSTD)
|
||||
//_STLP_BEGIN_NAMESPACE
|
||||
//using namespace _STLP_VENDOR_CSTD;
|
||||
//_STLP_END_NAMESPACE
|
||||
//#endif /* _STLP_IMPORT_VENDOR_CSTD */
|
||||
|
||||
#if !defined(_STLP_USE_OLD_HP_ITERATOR_QUERIES) && !defined(_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
# ifndef _STLP_TYPE_TRAITS_H
|
||||
# include <stl/type_traits.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
struct input_iterator_tag {};
|
||||
struct output_iterator_tag {};
|
||||
struct forward_iterator_tag : public input_iterator_tag {};
|
||||
struct bidirectional_iterator_tag : public forward_iterator_tag {};
|
||||
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
|
||||
|
||||
template <class _Category, class _Tp, _STLP_DFL_TMPL_PARAM(_Distance,ptrdiff_t),
|
||||
_STLP_DFL_TMPL_PARAM(_Pointer,_Tp*), _STLP_DFL_TMPL_PARAM(_Reference,_Tp&) >
|
||||
struct iterator {
|
||||
typedef _Category iterator_category;
|
||||
typedef _Tp value_type;
|
||||
typedef _Distance difference_type;
|
||||
typedef _Pointer pointer;
|
||||
typedef _Reference reference;
|
||||
};
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct iterator<output_iterator_tag, void, void, void, void> {
|
||||
typedef output_iterator_tag iterator_category;
|
||||
#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
|
||||
# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_STD::iterator_category(_It)
|
||||
# define _STLP_DISTANCE_TYPE(_It, _Tp) _STLP_STD::distance_type(_It)
|
||||
# define _STLP_VALUE_TYPE(_It, _Tp) _STLP_STD::value_type(_It)
|
||||
//Old HP iterator queries do not give information about the iterator
|
||||
//associated reference type so we consider that it is not a real reference.
|
||||
# define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) __false_type()
|
||||
#else
|
||||
# if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
# define _STLP_VALUE_TYPE(_It, _Tp) (_STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::value_type*)0
|
||||
# define _STLP_DISTANCE_TYPE(_It, _Tp) (_STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::difference_type*)0
|
||||
# if defined (__BORLANDC__) || defined (__SUNPRO_CC) || ( defined (__MWERKS__) && (__MWERKS__ <= 0x2303)) || \
|
||||
(defined (__sgi) && defined (_COMPILER_VERSION)) || defined (__DMC__)
|
||||
# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_STD::iterator_traits< _Tp >::iterator_category()
|
||||
# else
|
||||
# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::iterator_category()
|
||||
# endif
|
||||
# define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) _STLP_STD::_IsRefType< _STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::reference >::_Ret()
|
||||
# else
|
||||
# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_STD::__iterator_category(_It, _STLP_STD::_IsPtrType<_Tp>::_Ret())
|
||||
# define _STLP_DISTANCE_TYPE(_It, _Tp) _STLP_STD::__distance_type(_It, _STLP_STD::_IsPtrType<_Tp>::_Ret())
|
||||
# define _STLP_VALUE_TYPE(_It, _Tp) _STLP_STD::__value_type(_It, _STLP_STD::_IsPtrType<_Tp>::_Ret())
|
||||
# define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) __false_type()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_DONT_REDEFINE_STD) && defined (_STLP_WHOLE_NATIVE_STD)
|
||||
/* In this mode we will see both STLport implementation and native
|
||||
* one. To allow some interaction between both implementations through
|
||||
* iterators we have to map std iterator categories to stlport ones. This
|
||||
* way we will be able to initialize STLport containers with native
|
||||
* iterators, the other side won't work except when STLport iterators are
|
||||
* simple pointers. */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <iterator>
|
||||
# else
|
||||
# include _STLP_NATIVE_HEADER(iterator)
|
||||
# endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _IteCat>
|
||||
struct _CategoryMapping
|
||||
{ typedef _IteCat _Tag; };
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct _CategoryMapping<::std::input_iterator_tag>
|
||||
{ typedef input_iterator_tag _Tag; };
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct _CategoryMapping<::std::output_iterator_tag>
|
||||
{ typedef output_iterator_tag _Tag; };
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct _CategoryMapping<::std::forward_iterator_tag>
|
||||
{ typedef forward_iterator_tag _Tag; };
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct _CategoryMapping<::std::bidirectional_iterator_tag>
|
||||
{ typedef bidirectional_iterator_tag _Tag; };
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct _CategoryMapping<::std::random_access_iterator_tag>
|
||||
{ typedef random_access_iterator_tag _Tag; };
|
||||
|
||||
template <class _Iterator>
|
||||
struct iterator_traits {
|
||||
typedef typename _Iterator::iterator_category _OriginalTag;
|
||||
typedef typename _CategoryMapping<_OriginalTag>::_Tag iterator_category;
|
||||
#else
|
||||
template <class _Iterator>
|
||||
struct iterator_traits {
|
||||
typedef typename _Iterator::iterator_category iterator_category;
|
||||
#endif
|
||||
typedef typename _Iterator::value_type value_type;
|
||||
typedef typename _Iterator::difference_type difference_type;
|
||||
typedef typename _Iterator::pointer pointer;
|
||||
typedef typename _Iterator::reference reference;
|
||||
};
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (__SUNPRO_CC)
|
||||
# define _STLP_DIFFERENCE_TYPE(_Iterator) typename iterator_traits<_Iterator>::difference_type
|
||||
#else
|
||||
# define _STLP_DIFFERENCE_TYPE(_Iterator) ptrdiff_t
|
||||
#endif
|
||||
|
||||
#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
|
||||
|
||||
// fbp : this order keeps gcc happy
|
||||
template <class _Tp>
|
||||
struct iterator_traits<const _Tp*> {
|
||||
typedef random_access_iterator_tag iterator_category;
|
||||
typedef _Tp value_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef const _Tp* pointer;
|
||||
typedef const _Tp& reference;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct iterator_traits<_Tp*> {
|
||||
typedef random_access_iterator_tag iterator_category;
|
||||
typedef _Tp value_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef _Tp& reference;
|
||||
};
|
||||
|
||||
# if defined (__BORLANDC__)
|
||||
template <class _Tp>
|
||||
struct iterator_traits<_Tp* const> {
|
||||
typedef random_access_iterator_tag iterator_category;
|
||||
typedef _Tp value_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef const _Tp* pointer;
|
||||
typedef const _Tp& reference;
|
||||
};
|
||||
# endif
|
||||
|
||||
#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
#include <stl/_ptrs_specialize.h>
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef _STLP_USE_OLD_HP_ITERATOR_QUERIES
|
||||
// The overloaded functions iterator_category, distance_type, and
|
||||
// value_type are not part of the C++ standard. (They have been
|
||||
// replaced by struct iterator_traits.) They are included for
|
||||
// backward compatibility with the HP STL.
|
||||
// We introduce internal names for these functions.
|
||||
|
||||
# ifndef _STLP_CLASS_PARTIAL_SPECIALIZATION
|
||||
|
||||
template <class _Tp>
|
||||
inline _STLP_STD::random_access_iterator_tag
|
||||
__iterator_category(const _Tp*, const __true_type&)
|
||||
{ return _STLP_STD::random_access_iterator_tag(); }
|
||||
|
||||
template <class _Iter>
|
||||
inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_STD::iterator_traits<_Iter>::iterator_category
|
||||
__iterator_category(const _Iter&, const __false_type&) {
|
||||
typedef _STLP_TYPENAME _STLP_STD::iterator_traits<_Iter>::iterator_category _Category;
|
||||
return _Category();
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline ptrdiff_t*
|
||||
__distance_type(const _Tp*, const __true_type&)
|
||||
{ return __STATIC_CAST(ptrdiff_t*, 0); }
|
||||
|
||||
template <class _Iter>
|
||||
inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_STD::iterator_traits<_Iter>::difference_type*
|
||||
__distance_type(const _Iter&, const __false_type&) {
|
||||
typedef _STLP_TYPENAME _STLP_STD::iterator_traits<_Iter>::difference_type _diff_type;
|
||||
return __STATIC_CAST(_diff_type*,0);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _Tp*
|
||||
__value_type(const _Tp*, const __true_type&)
|
||||
{ return __STATIC_CAST(_Tp*, 0); }
|
||||
|
||||
template <class _Iter>
|
||||
inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_STD::iterator_traits<_Iter>::value_type*
|
||||
__value_type(const _Iter&, const __false_type&) {
|
||||
typedef _STLP_TYPENAME _STLP_STD::iterator_traits<_Iter>::value_type _value_type;
|
||||
return __STATIC_CAST(_value_type*,0);
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
#else /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */
|
||||
template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>
|
||||
inline _Category _STLP_CALL iterator_category(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return _Category(); }
|
||||
template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>
|
||||
inline _Tp* _STLP_CALL value_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return __STATIC_CAST(_Tp*, 0); }
|
||||
template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>
|
||||
inline _Distance* _STLP_CALL distance_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return __STATIC_CAST(_Distance*, 0); }
|
||||
template <class _Tp>
|
||||
inline random_access_iterator_tag _STLP_CALL iterator_category(const _Tp*) { return random_access_iterator_tag(); }
|
||||
template <class _Tp>
|
||||
inline _Tp* _STLP_CALL value_type(const _Tp*) { return __STATIC_CAST(_Tp*, 0); }
|
||||
template <class _Tp>
|
||||
inline ptrdiff_t* _STLP_CALL distance_type(const _Tp*) { return __STATIC_CAST(ptrdiff_t*, 0); }
|
||||
#endif /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */
|
||||
|
||||
#if !defined (_STLP_NO_ANACHRONISMS)
|
||||
// The base classes input_iterator, output_iterator, forward_iterator,
|
||||
// bidirectional_iterator, and random_access_iterator are not part of
|
||||
// the C++ standard. (They have been replaced by struct iterator.)
|
||||
// They are included for backward compatibility with the HP STL.
|
||||
template <class _Tp, class _Distance> struct input_iterator :
|
||||
public iterator <input_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
|
||||
struct output_iterator : public iterator <output_iterator_tag, void, void, void, void> {};
|
||||
template <class _Tp, class _Distance> struct forward_iterator :
|
||||
public iterator<forward_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
|
||||
template <class _Tp, class _Distance> struct bidirectional_iterator :
|
||||
public iterator<bidirectional_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
|
||||
template <class _Tp, class _Distance> struct random_access_iterator :
|
||||
public iterator<random_access_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
|
||||
|
||||
# if defined (_STLP_BASE_MATCH_BUG) && defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
|
||||
template <class _Tp, class _Distance>
|
||||
inline input_iterator_tag _STLP_CALL
|
||||
iterator_category(const input_iterator<_Tp, _Distance>&) { return input_iterator_tag(); }
|
||||
inline output_iterator_tag _STLP_CALL
|
||||
iterator_category(const output_iterator&) { return output_iterator_tag(); }
|
||||
template <class _Tp, class _Distance>
|
||||
inline forward_iterator_tag _STLP_CALL
|
||||
iterator_category(const forward_iterator<_Tp, _Distance>&) { return forward_iterator_tag(); }
|
||||
template <class _Tp, class _Distance>
|
||||
inline bidirectional_iterator_tag _STLP_CALL
|
||||
iterator_category(const bidirectional_iterator<_Tp, _Distance>&) { return bidirectional_iterator_tag(); }
|
||||
template <class _Tp, class _Distance>
|
||||
inline random_access_iterator_tag _STLP_CALL
|
||||
iterator_category(const random_access_iterator<_Tp, _Distance>&) { return random_access_iterator_tag(); }
|
||||
template <class _Tp, class _Distance>
|
||||
inline _Tp* _STLP_CALL value_type(const input_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
|
||||
template <class _Tp, class _Distance>
|
||||
inline _Tp* _STLP_CALL value_type(const forward_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
|
||||
template <class _Tp, class _Distance>
|
||||
inline _Tp* _STLP_CALL value_type(const bidirectional_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
|
||||
template <class _Tp, class _Distance>
|
||||
inline _Tp* _STLP_CALL value_type(const random_access_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
|
||||
template <class _Tp, class _Distance>
|
||||
inline _Distance* _STLP_CALL distance_type(const input_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); }
|
||||
template <class _Tp, class _Distance>
|
||||
inline _Distance* _STLP_CALL distance_type(const forward_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); }
|
||||
template <class _Tp, class _Distance>
|
||||
inline _Distance* _STLP_CALL distance_type(const bidirectional_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0);}
|
||||
template <class _Tp, class _Distance>
|
||||
inline _Distance* _STLP_CALL distance_type(const random_access_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); }
|
||||
# endif
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _InputIterator>
|
||||
inline _STLP_DIFFERENCE_TYPE(_InputIterator) _STLP_CALL
|
||||
__distance(const _InputIterator& __first, const _InputIterator& __last,
|
||||
const input_iterator_tag &) {
|
||||
_STLP_DIFFERENCE_TYPE(_InputIterator) __n = 0;
|
||||
_InputIterator __it(__first);
|
||||
while (__it != __last) {
|
||||
++__it; ++__n;
|
||||
}
|
||||
return __n;
|
||||
}
|
||||
|
||||
#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
|
||||
template <class _ForwardIterator>
|
||||
inline _STLP_DIFFERENCE_TYPE(_ForwardIterator) _STLP_CALL
|
||||
__distance(const _ForwardIterator& __first, const _ForwardIterator& __last,
|
||||
const forward_iterator_tag &) {
|
||||
_STLP_DIFFERENCE_TYPE(_ForwardIterator) __n = 0;
|
||||
_ForwardIterator __it(__first);
|
||||
while (__it != __last) {
|
||||
++__it; ++__n;
|
||||
}
|
||||
return __n;
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator>
|
||||
_STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_BidirectionalIterator) _STLP_CALL
|
||||
__distance(const _BidirectionalIterator& __first, const _BidirectionalIterator& __last,
|
||||
const bidirectional_iterator_tag &) {
|
||||
_STLP_DIFFERENCE_TYPE(_BidirectionalIterator) __n = 0;
|
||||
_BidirectionalIterator __it(__first);
|
||||
while (__it != __last) {
|
||||
++__it; ++__n;
|
||||
}
|
||||
return __n;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _RandomAccessIterator>
|
||||
inline _STLP_DIFFERENCE_TYPE(_RandomAccessIterator) _STLP_CALL
|
||||
__distance(const _RandomAccessIterator& __first, const _RandomAccessIterator& __last,
|
||||
const random_access_iterator_tag &)
|
||||
{ return __last - __first; }
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _InputIterator>
|
||||
inline _STLP_DIFFERENCE_TYPE(_InputIterator) _STLP_CALL
|
||||
distance(_InputIterator __first, _InputIterator __last)
|
||||
{ return _STLP_PRIV __distance(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); }
|
||||
|
||||
#if !defined (_STLP_NO_ANACHRONISMS)
|
||||
template <class _InputIterator, class _Distance>
|
||||
inline void _STLP_CALL distance(const _InputIterator& __first,
|
||||
const _InputIterator& __last, _Distance& __n)
|
||||
{ __n += _STLP_STD::distance(__first, __last); }
|
||||
|
||||
# if defined (_STLP_MSVC)
|
||||
// MSVC specific
|
||||
template <class _InputIterator, class _Dist>
|
||||
inline void _STLP_CALL _Distance(_InputIterator __first,
|
||||
_InputIterator __last, _Dist& __n)
|
||||
{ __n += _STLP_STD::distance(__first, __last); }
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// fbp: those are being used for iterator/const_iterator definitions everywhere
|
||||
template <class _Tp>
|
||||
struct _Nonconst_traits;
|
||||
|
||||
template <class _Tp>
|
||||
struct _Const_traits {
|
||||
typedef _Tp value_type;
|
||||
typedef const _Tp& reference;
|
||||
typedef const _Tp* pointer;
|
||||
typedef _Const_traits<_Tp> _ConstTraits;
|
||||
typedef _Nonconst_traits<_Tp> _NonConstTraits;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct _Nonconst_traits {
|
||||
typedef _Tp value_type;
|
||||
typedef _Tp& reference;
|
||||
typedef _Tp* pointer;
|
||||
typedef _Const_traits<_Tp> _ConstTraits;
|
||||
typedef _Nonconst_traits<_Tp> _NonConstTraits;
|
||||
};
|
||||
|
||||
/*
|
||||
* dums: A special iterator/const_iterator traits for set and multiset for which even
|
||||
* the iterator is not mutable
|
||||
*/
|
||||
template <class _Tp>
|
||||
struct _Nonconst_Const_traits;
|
||||
|
||||
template <class _Tp>
|
||||
struct _Const_Const_traits {
|
||||
typedef _Tp value_type;
|
||||
typedef const _Tp& reference;
|
||||
typedef const _Tp* pointer;
|
||||
typedef _Const_Const_traits<_Tp> _ConstTraits;
|
||||
typedef _Nonconst_Const_traits<_Tp> _NonConstTraits;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct _Nonconst_Const_traits {
|
||||
typedef _Tp value_type;
|
||||
typedef const _Tp& reference;
|
||||
typedef const _Tp* pointer;
|
||||
typedef _Const_Const_traits<_Tp> _ConstTraits;
|
||||
typedef _Nonconst_Const_traits<_Tp> _NonConstTraits;
|
||||
};
|
||||
|
||||
/*
|
||||
* A macro to generate a new iterator traits from one of the
|
||||
* previous one. Changing the iterator traits type make iterators
|
||||
* from different containers not comparable.
|
||||
*/
|
||||
#define _STLP_CREATE_ITERATOR_TRAITS_BASE(Motif, Traits) \
|
||||
template <class _Tp> \
|
||||
struct _##Motif; \
|
||||
template <class _Tp> \
|
||||
struct _Const##Motif : public _STLP_STD::_Const_##Traits<_Tp> { \
|
||||
typedef _Const##Motif<_Tp> _ConstTraits; \
|
||||
typedef _##Motif<_Tp> _NonConstTraits; \
|
||||
}; \
|
||||
template <class _Tp> \
|
||||
struct _##Motif : public _STLP_STD::_Nonconst_##Traits<_Tp> { \
|
||||
typedef _Const##Motif<_Tp> _ConstTraits; \
|
||||
typedef _##Motif<_Tp> _NonConstTraits; \
|
||||
};
|
||||
|
||||
#define _STLP_CREATE_ITERATOR_TRAITS(Motif, Traits) \
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE \
|
||||
_STLP_CREATE_ITERATOR_TRAITS_BASE(Motif, Traits) \
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
#define _STLP_CREATE_HASH_ITERATOR_TRAITS(Motif, Traits) \
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE \
|
||||
_STLP_CREATE_ITERATOR_TRAITS_BASE(NonLocal##Motif, Traits) \
|
||||
_STLP_CREATE_ITERATOR_TRAITS_BASE(Local##Motif, Traits) \
|
||||
template <class _Tp> \
|
||||
struct _##Motif { \
|
||||
typedef _ConstNonLocal##Motif<_Tp> _ConstTraits; \
|
||||
typedef _NonLocal##Motif<_Tp> _NonConstTraits; \
|
||||
typedef _ConstLocal##Motif<_Tp> _ConstLocalTraits; \
|
||||
typedef _Local##Motif<_Tp> _NonConstLocalTraits; \
|
||||
}; \
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
/*
|
||||
# if defined (_STLP_BASE_TYPEDEF_BUG)
|
||||
// this workaround is needed for SunPro 4.0.1
|
||||
template <class _Traits>
|
||||
struct __cnst_traits_aux : private _Traits {
|
||||
typedef typename _Traits::value_type value_type;
|
||||
};
|
||||
# define __TRAITS_VALUE_TYPE(_Traits) __cnst_traits_aux<_Traits>::value_type
|
||||
# else
|
||||
# define __TRAITS_VALUE_TYPE(_Traits) _Traits::value_type
|
||||
# endif
|
||||
*/
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _InputIter, class _Distance>
|
||||
_STLP_INLINE_LOOP void _STLP_CALL
|
||||
__advance(_InputIter& __i, _Distance __n, const input_iterator_tag &)
|
||||
{ while (__n--) ++__i; }
|
||||
|
||||
// fbp : added output iterator tag variant
|
||||
template <class _InputIter, class _Distance>
|
||||
_STLP_INLINE_LOOP void _STLP_CALL
|
||||
__advance(_InputIter& __i, _Distance __n, const output_iterator_tag &)
|
||||
{ while (__n--) ++__i; }
|
||||
|
||||
#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
|
||||
template <class _ForwardIterator, class _Distance>
|
||||
_STLP_INLINE_LOOP void _STLP_CALL
|
||||
__advance(_ForwardIterator& i, _Distance n, const forward_iterator_tag &)
|
||||
{ while (n--) ++i; }
|
||||
#endif
|
||||
|
||||
template <class _BidirectionalIterator, class _Distance>
|
||||
_STLP_INLINE_LOOP void _STLP_CALL
|
||||
__advance(_BidirectionalIterator& __i, _Distance __n,
|
||||
const bidirectional_iterator_tag &) {
|
||||
if (__n > 0)
|
||||
while (__n--) ++__i;
|
||||
else
|
||||
while (__n++) --__i;
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Distance>
|
||||
inline void _STLP_CALL
|
||||
__advance(_RandomAccessIterator& __i, _Distance __n,
|
||||
const random_access_iterator_tag &)
|
||||
{ __i += __n; }
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _InputIterator, class _Distance>
|
||||
inline void _STLP_CALL advance(_InputIterator& __i, _Distance __n)
|
||||
{ _STLP_PRIV __advance(__i, __n, _STLP_ITERATOR_CATEGORY(__i, _InputIterator)); }
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_ITERATOR_BASE_H */
|
||||
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
334
extern/STLport/5.2.1/stlport/stl/_iterator_old.h
vendored
Normal file
334
extern/STLport/5.2.1/stlport/stl/_iterator_old.h
vendored
Normal file
@@ -0,0 +1,334 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996-1998
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_OLD_H
|
||||
#define _STLP_INTERNAL_ITERATOR_OLD_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
|
||||
# include <stl/_iterator_base.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
|
||||
|
||||
template <class _Container>
|
||||
inline output_iterator_tag _STLP_CALL
|
||||
iterator_category(const back_insert_iterator<_Container>&) { return output_iterator_tag(); }
|
||||
template <class _Container>
|
||||
inline output_iterator_tag _STLP_CALL
|
||||
iterator_category(const front_insert_iterator<_Container>&) { return output_iterator_tag(); }
|
||||
template <class _Container>
|
||||
inline output_iterator_tag _STLP_CALL
|
||||
iterator_category(const insert_iterator<_Container>&) { return output_iterator_tag(); }
|
||||
|
||||
#endif
|
||||
|
||||
template <class _BidirectionalIterator, class _Tp,
|
||||
_STLP_DFL_TMPL_PARAM(_Reference, _Tp& ),
|
||||
#if defined (_STLP_MSVC50_COMPATIBILITY)
|
||||
# define __Reference _Reference, class _Pointer
|
||||
# define Reference__ _Reference, _Pointer
|
||||
_STLP_DFL_TMPL_PARAM(_Pointer, _Tp*),
|
||||
#else
|
||||
# define __Reference _Reference
|
||||
# define Reference__ _Reference
|
||||
#endif
|
||||
_STLP_DFL_TYPE_PARAM(_Distance, ptrdiff_t)>
|
||||
class reverse_bidirectional_iterator {
|
||||
typedef reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,
|
||||
Reference__, _Distance> _Self;
|
||||
// friend inline bool operator== _STLP_NULL_TMPL_ARGS (const _Self& x, const _Self& y);
|
||||
protected:
|
||||
_BidirectionalIterator current;
|
||||
public:
|
||||
typedef bidirectional_iterator_tag iterator_category;
|
||||
typedef _Tp value_type;
|
||||
typedef _Distance difference_type;
|
||||
# if defined (_STLP_MSVC50_COMPATIBILITY)
|
||||
typedef _Pointer pointer;
|
||||
# else
|
||||
typedef _Tp* pointer;
|
||||
# endif
|
||||
typedef _Reference reference;
|
||||
|
||||
reverse_bidirectional_iterator() {}
|
||||
explicit reverse_bidirectional_iterator(_BidirectionalIterator __x)
|
||||
: current(__x) {}
|
||||
_BidirectionalIterator base() const { return current; }
|
||||
_Reference operator*() const {
|
||||
_BidirectionalIterator __tmp = current;
|
||||
return *(--__tmp);
|
||||
}
|
||||
|
||||
_STLP_DEFINE_ARROW_OPERATOR
|
||||
|
||||
_Self& operator++() {
|
||||
--current;
|
||||
return *this;
|
||||
}
|
||||
_Self operator++(int) {
|
||||
_Self __tmp = *this;
|
||||
--current;
|
||||
return __tmp;
|
||||
}
|
||||
_Self& operator--() {
|
||||
++current;
|
||||
return *this;
|
||||
}
|
||||
_Self operator--(int) {
|
||||
_Self __tmp = *this;
|
||||
++current;
|
||||
return __tmp;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
|
||||
template <class _BidirectionalIterator, class _Tp, class __Reference,
|
||||
class _Distance>
|
||||
inline bidirectional_iterator_tag _STLP_CALL
|
||||
iterator_category(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, Reference__, _Distance>&)
|
||||
{ return bidirectional_iterator_tag(); }
|
||||
template <class _BidirectionalIterator, class _Tp, class __Reference,
|
||||
class _Distance>
|
||||
inline _Tp* _STLP_CALL
|
||||
value_type(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, Reference__, _Distance>&)
|
||||
{ return (_Tp*) 0; }
|
||||
template <class _BidirectionalIterator, class _Tp, class __Reference,
|
||||
class _Distance>
|
||||
inline _Distance* _STLP_CALL
|
||||
distance_type(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, Reference__, _Distance>&)
|
||||
{ return (_Distance*) 0; }
|
||||
#endif
|
||||
|
||||
template <class _BidirectionalIterator, class _Tp, class __Reference,
|
||||
class _Distance>
|
||||
inline bool _STLP_CALL operator==(
|
||||
const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,
|
||||
Reference__, _Distance>& __x,
|
||||
const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,
|
||||
Reference__, _Distance>& __y)
|
||||
{ return __x.base() == __y.base(); }
|
||||
|
||||
#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
|
||||
|
||||
template <class _BiIter, class _Tp, class __Reference, class _Distance>
|
||||
inline bool _STLP_CALL operator!=(
|
||||
const reverse_bidirectional_iterator<_BiIter, _Tp, Reference__, _Distance>& __x,
|
||||
const reverse_bidirectional_iterator<_BiIter, _Tp, Reference__, _Distance>& __y)
|
||||
{ return !(__x == __y); }
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION )
|
||||
|
||||
// This is the old version of reverse_iterator, as found in the original
|
||||
// HP STL. It does not use partial specialization.
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp,
|
||||
_STLP_DFL_TMPL_PARAM(_Reference,_Tp&),
|
||||
# if defined (_STLP_MSVC50_COMPATIBILITY)
|
||||
_STLP_DFL_TMPL_PARAM(_Pointer, _Tp*),
|
||||
# endif
|
||||
_STLP_DFL_TYPE_PARAM(_Distance,ptrdiff_t)>
|
||||
class reverse_iterator {
|
||||
typedef reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance> _Self;
|
||||
protected:
|
||||
_RandomAccessIterator __current;
|
||||
public:
|
||||
typedef random_access_iterator_tag iterator_category;
|
||||
typedef _Tp value_type;
|
||||
typedef _Distance difference_type;
|
||||
# if defined (_STLP_MSVC50_COMPATIBILITY)
|
||||
typedef _Pointer pointer;
|
||||
# else
|
||||
typedef _Tp* pointer;
|
||||
# endif
|
||||
typedef _Reference reference;
|
||||
|
||||
reverse_iterator() {}
|
||||
reverse_iterator(const _Self& __x) : __current(__x.base()) {}
|
||||
explicit reverse_iterator(_RandomAccessIterator __x) : __current(__x) {}
|
||||
_Self& operator=(const _Self& __x) {__current = __x.base(); return *this; }
|
||||
|
||||
_RandomAccessIterator base() const { return __current; }
|
||||
_Reference operator*() const { return *(__current - (difference_type)1); }
|
||||
|
||||
_STLP_DEFINE_ARROW_OPERATOR
|
||||
|
||||
_Self& operator++() {
|
||||
--__current;
|
||||
return *this;
|
||||
}
|
||||
_Self operator++(int) {
|
||||
_Self __tmp = *this;
|
||||
--__current;
|
||||
return __tmp;
|
||||
}
|
||||
_Self& operator--() {
|
||||
++__current;
|
||||
return *this;
|
||||
}
|
||||
_Self operator--(int) {
|
||||
_Self __tmp = *this;
|
||||
++__current;
|
||||
return __tmp;
|
||||
}
|
||||
_Self operator+(_Distance __n) const {
|
||||
return _Self(__current - __n);
|
||||
}
|
||||
_Self& operator+=(_Distance __n) {
|
||||
__current -= __n;
|
||||
return *this;
|
||||
}
|
||||
_Self operator-(_Distance __n) const {
|
||||
return _Self(__current + __n);
|
||||
}
|
||||
_Self& operator-=(_Distance __n) {
|
||||
__current += __n;
|
||||
return *this;
|
||||
}
|
||||
_Reference operator[](_Distance __n) const { return *(*this + __n); }
|
||||
};
|
||||
|
||||
# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
|
||||
template <class _RandomAccessIterator, class _Tp,
|
||||
class __Reference, class _Distance>
|
||||
inline random_access_iterator_tag _STLP_CALL
|
||||
iterator_category(const reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>&)
|
||||
{ return random_access_iterator_tag(); }
|
||||
template <class _RandomAccessIterator, class _Tp,
|
||||
class __Reference, class _Distance>
|
||||
inline _Tp* _STLP_CALL value_type(const reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>&)
|
||||
{ return (_Tp*) 0; }
|
||||
template <class _RandomAccessIterator, class _Tp,
|
||||
class __Reference, class _Distance>
|
||||
inline _Distance* _STLP_CALL
|
||||
distance_type(const reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>&)
|
||||
{ return (_Distance*) 0; }
|
||||
# endif
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp,
|
||||
class __Reference, class _Distance>
|
||||
inline bool _STLP_CALL
|
||||
operator==(const reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>& __x,
|
||||
const reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>& __y)
|
||||
{
|
||||
return __x.base() == __y.base();
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp,
|
||||
class __Reference, class _Distance>
|
||||
inline bool _STLP_CALL
|
||||
operator<(const reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>& __x,
|
||||
const reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>& __y)
|
||||
{
|
||||
return __y.base() < __x.base();
|
||||
}
|
||||
|
||||
# ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp,
|
||||
class __Reference, class _Distance>
|
||||
inline bool _STLP_CALL
|
||||
operator!=(const reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>& __x,
|
||||
const reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>& __y) {
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp,
|
||||
class __Reference, class _Distance>
|
||||
inline bool _STLP_CALL
|
||||
operator>(const reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>& __x,
|
||||
const reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>& __y) {
|
||||
return __y < __x;
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp,
|
||||
class __Reference, class _Distance>
|
||||
inline bool _STLP_CALL
|
||||
operator<=(const reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>& __x,
|
||||
const reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>& __y) {
|
||||
return !(__y < __x);
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp,
|
||||
class __Reference, class _Distance>
|
||||
inline bool _STLP_CALL
|
||||
operator>=(const reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>& __x,
|
||||
const reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>& __y) {
|
||||
return !(__x < __y);
|
||||
}
|
||||
|
||||
# endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp,
|
||||
class __Reference, class _Distance>
|
||||
inline _Distance _STLP_CALL
|
||||
operator-(const reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>& __x,
|
||||
const reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>& __y)
|
||||
{
|
||||
return __y.base() - __x.base();
|
||||
}
|
||||
|
||||
template <class _RandomAccessIterator, class _Tp,
|
||||
class __Reference, class _Distance>
|
||||
inline reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance> _STLP_CALL
|
||||
operator+(_Distance __n,
|
||||
const reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>& __x)
|
||||
{
|
||||
return reverse_iterator<_RandomAccessIterator, _Tp,
|
||||
Reference__, _Distance>(__x.base() - __n);
|
||||
}
|
||||
|
||||
#endif /* ! defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION ) */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_ITERATOR_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
405
extern/STLport/5.2.1/stlport/stl/_limits.c
vendored
Normal file
405
extern/STLport/5.2.1/stlport/stl/_limits.c
vendored
Normal file
@@ -0,0 +1,405 @@
|
||||
/*
|
||||
* Copyright (c) 1998,1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_LIMITS_C
|
||||
#define _STLP_LIMITS_C
|
||||
|
||||
#ifndef _STLP_INTERNAL_LIMITS
|
||||
# include <stl/_limits.h>
|
||||
#endif
|
||||
|
||||
//==========================================================
|
||||
// numeric_limits static members
|
||||
//==========================================================
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION)
|
||||
|
||||
# define __declare_numeric_base_member(__type, __mem) \
|
||||
template <class __number> \
|
||||
const __type _Numeric_limits_base<__number>:: __mem
|
||||
|
||||
__declare_numeric_base_member(bool, is_specialized);
|
||||
__declare_numeric_base_member(int, digits);
|
||||
__declare_numeric_base_member(int, digits10);
|
||||
__declare_numeric_base_member(bool, is_signed);
|
||||
__declare_numeric_base_member(bool, is_integer);
|
||||
__declare_numeric_base_member(bool, is_exact);
|
||||
__declare_numeric_base_member(int, radix);
|
||||
__declare_numeric_base_member(int, min_exponent);
|
||||
__declare_numeric_base_member(int, max_exponent);
|
||||
__declare_numeric_base_member(int, min_exponent10);
|
||||
__declare_numeric_base_member(int, max_exponent10);
|
||||
__declare_numeric_base_member(bool, has_infinity);
|
||||
__declare_numeric_base_member(bool, has_quiet_NaN);
|
||||
__declare_numeric_base_member(bool, has_signaling_NaN);
|
||||
__declare_numeric_base_member(float_denorm_style, has_denorm);
|
||||
__declare_numeric_base_member(bool, has_denorm_loss);
|
||||
__declare_numeric_base_member(bool, is_iec559);
|
||||
__declare_numeric_base_member(bool, is_bounded);
|
||||
__declare_numeric_base_member(bool, is_modulo);
|
||||
__declare_numeric_base_member(bool, traps);
|
||||
__declare_numeric_base_member(bool, tinyness_before);
|
||||
__declare_numeric_base_member(float_round_style, round_style);
|
||||
|
||||
# undef __declare_numeric_base_member
|
||||
|
||||
# define __declare_integer_limits_member(__type, __mem) \
|
||||
template <class _Int, _STLP_LIMITS_MIN_TYPE __imin, _STLP_LIMITS_MAX_TYPE __imax, int __idigits, bool __ismod> \
|
||||
const __type _Integer_limits<_Int, __imin, __imax, __idigits, __ismod>:: __mem
|
||||
|
||||
__declare_integer_limits_member(bool, is_specialized);
|
||||
__declare_integer_limits_member(int, digits);
|
||||
__declare_integer_limits_member(int, digits10);
|
||||
__declare_integer_limits_member(bool, is_signed);
|
||||
__declare_integer_limits_member(bool, is_integer);
|
||||
__declare_integer_limits_member(bool, is_exact);
|
||||
__declare_integer_limits_member(int, radix);
|
||||
__declare_integer_limits_member(bool, is_bounded);
|
||||
__declare_integer_limits_member(bool, is_modulo);
|
||||
# undef __declare_integer_limits_member
|
||||
|
||||
# if defined (__GNUC__) && (__GNUC__ != 2 || __GNUC_MINOR__ > 96) && (__GNUC__ != 3 || __GNUC_MINOR__ == 0) && (__GNUC__ <= 3)
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
# define __declare_numeric_limits_member(__integer) \
|
||||
_STLP_TEMPLATE_NULL const int numeric_limits<__integer>::digits; \
|
||||
_STLP_TEMPLATE_NULL const int numeric_limits<__integer>::digits10; \
|
||||
_STLP_TEMPLATE_NULL const int numeric_limits<__integer>::radix; \
|
||||
_STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_specialized; \
|
||||
_STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_signed; \
|
||||
_STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_integer; \
|
||||
_STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_exact; \
|
||||
_STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_bounded; \
|
||||
_STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_modulo
|
||||
|
||||
__declare_numeric_limits_member(_STLP_LONG_LONG);
|
||||
__declare_numeric_limits_member(unsigned _STLP_LONG_LONG);
|
||||
|
||||
# undef __declare_numeric_limits_member
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
# endif
|
||||
|
||||
# define __declare_float_limits_member(__type, __mem) \
|
||||
template <class __number, \
|
||||
int __Digits, int __Digits10, \
|
||||
int __MinExp, int __MaxExp, \
|
||||
int __MinExp10, int __MaxExp10, \
|
||||
bool __IsIEC559, \
|
||||
float_denorm_style __DenormStyle, \
|
||||
float_round_style __RoundStyle> \
|
||||
const __type _Floating_limits< __number, __Digits, __Digits10, \
|
||||
__MinExp, __MaxExp, __MinExp10, __MaxExp10, \
|
||||
__IsIEC559, __DenormStyle, __RoundStyle>::\
|
||||
__mem
|
||||
|
||||
__declare_float_limits_member(bool, is_specialized);
|
||||
__declare_float_limits_member(int, digits);
|
||||
__declare_float_limits_member(int, digits10);
|
||||
__declare_float_limits_member(bool, is_signed);
|
||||
__declare_float_limits_member(int, radix);
|
||||
__declare_float_limits_member(int, min_exponent);
|
||||
__declare_float_limits_member(int, max_exponent);
|
||||
__declare_float_limits_member(int, min_exponent10);
|
||||
__declare_float_limits_member(int, max_exponent10);
|
||||
__declare_float_limits_member(bool, has_infinity);
|
||||
__declare_float_limits_member(bool, has_quiet_NaN);
|
||||
__declare_float_limits_member(bool, has_signaling_NaN);
|
||||
__declare_float_limits_member(float_denorm_style, has_denorm);
|
||||
__declare_float_limits_member(bool, has_denorm_loss);
|
||||
__declare_float_limits_member(bool, is_iec559);
|
||||
__declare_float_limits_member(bool, is_bounded);
|
||||
__declare_float_limits_member(bool, traps);
|
||||
__declare_float_limits_member(bool, tinyness_before);
|
||||
__declare_float_limits_member(float_round_style, round_style);
|
||||
# undef __declare_float_limits_member
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION)
|
||||
|
||||
# if defined (__GNUC__) || defined (__BORLANDC__)
|
||||
# define _STLP_ADDITIONAL_OPEN_BRACKET {
|
||||
# define _STLP_ADDITIONAL_CLOSE_BRACKET }
|
||||
# else
|
||||
# define _STLP_ADDITIONAL_OPEN_BRACKET
|
||||
# define _STLP_ADDITIONAL_CLOSE_BRACKET
|
||||
# endif
|
||||
|
||||
/* The following code has been extracted from the boost libraries (www.boost.org) and
|
||||
* adapted with the STLport portability macros. Advantage on previous technique is that
|
||||
* computation of infinity and NaN values is only based on big/little endianess, compiler
|
||||
* float, double or long double representation is taken into account thanks to the sizeof
|
||||
* operator. */
|
||||
template<class _Number, unsigned short _Word>
|
||||
struct float_helper {
|
||||
union _WordsNumber {
|
||||
unsigned short _Words[8];
|
||||
_Number _num;
|
||||
};
|
||||
static _Number get_word_higher() _STLP_NOTHROW {
|
||||
_WordsNumber __tmp = { _STLP_ADDITIONAL_OPEN_BRACKET _Word, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET };
|
||||
return __tmp._num;
|
||||
}
|
||||
static _Number get_word_lower() _STLP_NOTHROW {
|
||||
_WordsNumber __tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET };
|
||||
__tmp._Words[(sizeof(_Number) >= 12 ? 10 : sizeof(_Number)) / sizeof(unsigned short) - 1] = _Word;
|
||||
return __tmp._num;
|
||||
}
|
||||
static _Number get_from_last_word() _STLP_NOTHROW {
|
||||
# if defined (_STLP_BIG_ENDIAN)
|
||||
return get_word_higher();
|
||||
# else /* _STLP_LITTLE_ENDIAN */
|
||||
return get_word_lower();
|
||||
# endif
|
||||
}
|
||||
static _Number get_from_first_word() _STLP_NOTHROW {
|
||||
# if defined (_STLP_BIG_ENDIAN)
|
||||
return get_word_lower();
|
||||
# else /* _STLP_LITTLE_ENDIAN */
|
||||
return get_word_higher();
|
||||
# endif
|
||||
}
|
||||
};
|
||||
|
||||
# if !defined (_STLP_NO_LONG_DOUBLE) && !defined (_STLP_BIG_ENDIAN)
|
||||
template<class _Number, unsigned short _Word1, unsigned short _Word2>
|
||||
struct float_helper2 {
|
||||
union _WordsNumber {
|
||||
unsigned short _Words[8];
|
||||
_Number _num;
|
||||
};
|
||||
//static _Number get_word_higher() _STLP_NOTHROW {
|
||||
// _WordsNumber __tmp = { _STLP_ADDITIONAL_OPEN_BRACKET _Word1, _Word2, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET };
|
||||
// return __tmp._num;
|
||||
//}
|
||||
static _Number get_word_lower() _STLP_NOTHROW {
|
||||
_WordsNumber __tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET };
|
||||
__tmp._Words[(sizeof(_Number) >= 12 ? 10 : sizeof(_Number)) / sizeof(unsigned short) - 2] = _Word1;
|
||||
__tmp._Words[(sizeof(_Number) >= 12 ? 10 : sizeof(_Number)) / sizeof(unsigned short) - 1] = _Word2;
|
||||
return __tmp._num;
|
||||
}
|
||||
static _Number get_from_last_word() _STLP_NOTHROW {
|
||||
//# if defined (_STLP_BIG_ENDIAN)
|
||||
// return get_word_higher();
|
||||
//# else /* _STLP_LITTLE_ENDIAN */
|
||||
return get_word_lower();
|
||||
//# endif
|
||||
}
|
||||
};
|
||||
# endif
|
||||
|
||||
/* Former values kept in case moving to boost code has introduce a regression on
|
||||
* some platform. */
|
||||
#if 0
|
||||
# if defined (_STLP_BIG_ENDIAN)
|
||||
# if defined (__OS400__)
|
||||
# define _STLP_FLOAT_INF_REP { 0x7f80, 0 }
|
||||
# define _STLP_FLOAT_QNAN_REP { 0xffc0, 0 }
|
||||
# define _STLP_FLOAT_SNAN_REP { 0xff80, 0 }
|
||||
# define _STLP_DOUBLE_INF_REP { 0x7ff0, 0, 0, 0 }
|
||||
# define _STLP_DOUBLE_QNAN_REP { 0xfff8, 0, 0, 0 }
|
||||
# define _STLP_DOUBLE_SNAN_REP { 0xfff0, 0, 0, 0 }
|
||||
# define _STLP_LDOUBLE_INF_REP { 0x7ff0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
# define _STLP_LDOUBLE_QNAN_REP { 0xfff8, 0, 0, 0, 0, 0, 0, 0 }
|
||||
# define _STLP_LDOUBLE_SNAN_REP { 0xfff0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
# else /* __OS400__ */
|
||||
# define _STLP_FLOAT_INF_REP { 0x7f80, 0 }
|
||||
# define _STLP_FLOAT_QNAN_REP { 0x7fc1, 0 }
|
||||
# define _STLP_FLOAT_SNAN_REP { 0x7f81, 0 }
|
||||
# define _STLP_DOUBLE_INF_REP { 0x7ff0, 0, 0, 0 }
|
||||
# define _STLP_DOUBLE_QNAN_REP { 0x7ff9, 0, 0, 0 }
|
||||
# define _STLP_DOUBLE_SNAN_REP { 0x7ff1, 0, 0, 0 }
|
||||
# define _STLP_LDOUBLE_INF_REP { 0x7ff0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
# define _STLP_LDOUBLE_QNAN_REP { 0x7ff1, 0, 0, 0, 0, 0, 0, 0 }
|
||||
# define _STLP_LDOUBLE_SNAN_REP { 0x7ff9, 0, 0, 0, 0, 0, 0, 0 }
|
||||
# endif /* __OS400__ */
|
||||
# else /* _STLP_LITTLE_ENDIAN */
|
||||
# if defined(__DECCXX)
|
||||
# define _STLP_FLOAT_INF_REP { 0, 0x7f80 }
|
||||
# define _STLP_FLOAT_QNAN_REP { 0, 0xffc0 }
|
||||
# define _STLP_FLOAT_SNAN_REP { 0x5555, 0x7f85 }
|
||||
# define _STLP_DOUBLE_INF_REP { 0, 0, 0, 0x7ff0 }
|
||||
# define _STLP_DOUBLE_QNAN_REP { 0, 0, 0, 0xfff8 }
|
||||
# define _STLP_DOUBLE_SNAN_REP { 0x5555, 0x5555, 0x5555, 0x7ff5 }
|
||||
# define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0, 0, 0, 0, 0x7fff }
|
||||
# define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0, 0, 0, 0x8000, 0xffff }
|
||||
# define _STLP_LDOUBLE_SNAN_REP { 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x5555, 0x7fff}
|
||||
# else
|
||||
# define _STLP_FLOAT_INF_REP { 0, 0x7f80 }
|
||||
# define _STLP_FLOAT_QNAN_REP { 0, 0x7fc0 }
|
||||
# define _STLP_FLOAT_SNAN_REP { 0, 0x7fa0 }
|
||||
# define _STLP_DOUBLE_INF_REP { 0, 0, 0, 0x7ff0 }
|
||||
# define _STLP_DOUBLE_QNAN_REP { 0, 0, 0, 0x7ff8 }
|
||||
# define _STLP_DOUBLE_SNAN_REP { 0, 0, 0, 0x7ff4 }
|
||||
# if defined (_STLP_MSVC) || defined (__ICL)
|
||||
# define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0x7FF0, 0 }
|
||||
# define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0xFFF8, 0 }
|
||||
# define _STLP_LDOUBLE_SNAN_REP { 0, 0, 0, 0xFFF8, 0 }
|
||||
# elif defined (__BORLANDC__)
|
||||
# define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0x8000, 0x7fff }
|
||||
# define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0xc000, 0x7fff }
|
||||
# define _STLP_LDOUBLE_SNAN_REP { 0, 0, 0, 0xa000, 0x7fff }
|
||||
# else
|
||||
# define _STLP_LDOUBLE_INF_REP { 0, 0, 0, 0x8000, 0x7fff, 0 }
|
||||
# define _STLP_LDOUBLE_QNAN_REP { 0, 0, 0, 0xa000, 0x7fff, 0 }
|
||||
# define _STLP_LDOUBLE_SNAN_REP { 0, 0, 0, 0xc000, 0x7fff, 0 }
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
union _F_rep {
|
||||
unsigned short rep[2];
|
||||
float val;
|
||||
};
|
||||
union _D_rep {
|
||||
unsigned short rep[4];
|
||||
double val;
|
||||
};
|
||||
|
||||
# ifndef _STLP_NO_LONG_DOUBLE
|
||||
union _LD_rep {
|
||||
unsigned short rep[8];
|
||||
long double val;
|
||||
};
|
||||
# endif
|
||||
#endif
|
||||
|
||||
template <class __dummy>
|
||||
float _STLP_CALL _LimG<__dummy>::get_F_inf() {
|
||||
typedef float_helper<float, 0x7f80u> _FloatHelper;
|
||||
return _FloatHelper::get_from_last_word();
|
||||
}
|
||||
template <class __dummy>
|
||||
float _STLP_CALL _LimG<__dummy>::get_F_qNaN() {
|
||||
typedef float_helper<float, 0x7f81u> _FloatHelper;
|
||||
return _FloatHelper::get_from_last_word();
|
||||
}
|
||||
template <class __dummy>
|
||||
float _STLP_CALL _LimG<__dummy>::get_F_sNaN() {
|
||||
typedef float_helper<float, 0x7fc1u> _FloatHelper;
|
||||
return _FloatHelper::get_from_last_word();
|
||||
}
|
||||
template <class __dummy>
|
||||
float _STLP_CALL _LimG<__dummy>::get_F_denormMin() {
|
||||
typedef float_helper<float, 0x0001u> _FloatHelper;
|
||||
return _FloatHelper::get_from_first_word();
|
||||
}
|
||||
|
||||
template <int __use_double_limits>
|
||||
class _NumericLimitsAccess;
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _NumericLimitsAccess<1> {
|
||||
public:
|
||||
static double get_inf() {
|
||||
typedef float_helper<double, 0x7ff0u> _FloatHelper;
|
||||
return _FloatHelper::get_from_last_word();
|
||||
}
|
||||
static double get_qNaN() {
|
||||
typedef float_helper<double, 0x7ff1u> _FloatHelper;
|
||||
return _FloatHelper::get_from_last_word();
|
||||
}
|
||||
static double get_sNaN() {
|
||||
typedef float_helper<double, 0x7ff9u> _FloatHelper;
|
||||
return _FloatHelper::get_from_last_word();
|
||||
}
|
||||
};
|
||||
|
||||
template <class __dummy>
|
||||
double _STLP_CALL _LimG<__dummy>::get_D_inf()
|
||||
{ return _NumericLimitsAccess<1>::get_inf(); }
|
||||
template <class __dummy>
|
||||
double _STLP_CALL _LimG<__dummy>::get_D_qNaN()
|
||||
{ return _NumericLimitsAccess<1>::get_qNaN(); }
|
||||
template <class __dummy>
|
||||
double _STLP_CALL _LimG<__dummy>::get_D_sNaN()
|
||||
{ return _NumericLimitsAccess<1>::get_sNaN(); }
|
||||
template <class __dummy>
|
||||
double _STLP_CALL _LimG<__dummy>::get_D_denormMin() {
|
||||
typedef float_helper<double, 0x0001u> _FloatHelper;
|
||||
return _FloatHelper::get_from_first_word();
|
||||
}
|
||||
|
||||
# if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _NumericLimitsAccess<0> {
|
||||
public:
|
||||
static long double get_inf() {
|
||||
# if defined (_STLP_BIG_ENDIAN)
|
||||
typedef float_helper<long double, 0x7ff0u> _FloatHelper;
|
||||
# else
|
||||
typedef float_helper2<long double, 0x8000u, 0x7fffu> _FloatHelper;
|
||||
# endif
|
||||
return _FloatHelper::get_from_last_word();
|
||||
}
|
||||
static long double get_qNaN() {
|
||||
# if defined (_STLP_BIG_ENDIAN)
|
||||
typedef float_helper<long double, 0x7ff1u> _FloatHelper;
|
||||
# else
|
||||
typedef float_helper2<long double, 0xc000u, 0x7fffu> _FloatHelper;
|
||||
# endif
|
||||
return _FloatHelper::get_from_last_word();
|
||||
}
|
||||
static long double get_sNaN() {
|
||||
# if defined (_STLP_BIG_ENDIAN)
|
||||
typedef float_helper<long double, 0x7ff9u> _FloatHelper;
|
||||
# else
|
||||
typedef float_helper2<long double, 0x9000u, 0x7fffu> _FloatHelper;
|
||||
# endif
|
||||
return _FloatHelper::get_from_last_word();
|
||||
}
|
||||
};
|
||||
|
||||
template <class __dummy>
|
||||
long double _STLP_CALL _LimG<__dummy>::get_LD_inf() {
|
||||
const int __use_double_limits = sizeof(double) == sizeof(long double) ? 1 : 0;
|
||||
return _NumericLimitsAccess<__use_double_limits>::get_inf();
|
||||
}
|
||||
template <class __dummy>
|
||||
long double _STLP_CALL _LimG<__dummy>::get_LD_qNaN() {
|
||||
const int __use_double_limits = sizeof(double) == sizeof(long double) ? 1 : 0;
|
||||
return _NumericLimitsAccess<__use_double_limits>::get_qNaN();
|
||||
}
|
||||
template <class __dummy>
|
||||
long double _STLP_CALL _LimG<__dummy>::get_LD_sNaN() {
|
||||
const int __use_double_limits = sizeof(double) == sizeof(long double) ? 1 : 0;
|
||||
return _NumericLimitsAccess<__use_double_limits>::get_sNaN();
|
||||
}
|
||||
template <class __dummy>
|
||||
long double _STLP_CALL _LimG<__dummy>::get_LD_denormMin() {
|
||||
typedef float_helper<long double, 0x0001u> _FloatHelper;
|
||||
return _FloatHelper::get_from_first_word();
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif /* _STLP_EXPOSE_GLOBALS_IMPLEMENTATION */
|
||||
|
||||
#undef _STLP_LIMITS_MIN_TYPE
|
||||
#undef _STLP_LIMITS_MAX_TYPE
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_LIMITS_C_INCLUDED */
|
||||
519
extern/STLport/5.2.1/stlport/stl/_limits.h
vendored
Normal file
519
extern/STLport/5.2.1/stlport/stl/_limits.h
vendored
Normal file
@@ -0,0 +1,519 @@
|
||||
/*
|
||||
* Copyright (c) 1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This may be not portable code. Parts of numeric_limits<> are
|
||||
* inherently machine-dependent. At present this file is suitable
|
||||
* for the MIPS, SPARC, Alpha and ia32 architectures.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_LIMITS
|
||||
#define _STLP_INTERNAL_LIMITS
|
||||
|
||||
#ifndef _STLP_CLIMITS
|
||||
# include <climits>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_CFLOAT
|
||||
# include <cfloat>
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_HAS_WCHAR_T) && !defined (_STLP_INTERNAL_CWCHAR)
|
||||
# include <stl/_cwchar.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
enum float_round_style {
|
||||
round_indeterminate = -1,
|
||||
round_toward_zero = 0,
|
||||
round_to_nearest = 1,
|
||||
round_toward_infinity = 2,
|
||||
round_toward_neg_infinity = 3
|
||||
};
|
||||
|
||||
enum float_denorm_style {
|
||||
denorm_indeterminate = -1,
|
||||
denorm_absent = 0,
|
||||
denorm_present = 1
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
// Base class for all specializations of numeric_limits.
|
||||
template <class __number>
|
||||
class _Numeric_limits_base {
|
||||
public:
|
||||
|
||||
static __number (_STLP_CALL min)() _STLP_NOTHROW { return __number(); }
|
||||
static __number (_STLP_CALL max)() _STLP_NOTHROW { return __number(); }
|
||||
|
||||
_STLP_STATIC_CONSTANT(int, digits = 0);
|
||||
_STLP_STATIC_CONSTANT(int, digits10 = 0);
|
||||
_STLP_STATIC_CONSTANT(int, radix = 0);
|
||||
_STLP_STATIC_CONSTANT(int, min_exponent = 0);
|
||||
_STLP_STATIC_CONSTANT(int, min_exponent10 = 0);
|
||||
_STLP_STATIC_CONSTANT(int, max_exponent = 0);
|
||||
_STLP_STATIC_CONSTANT(int, max_exponent10 = 0);
|
||||
|
||||
_STLP_STATIC_CONSTANT(float_denorm_style, has_denorm = denorm_absent);
|
||||
_STLP_STATIC_CONSTANT(float_round_style, round_style = round_toward_zero);
|
||||
|
||||
_STLP_STATIC_CONSTANT(bool, is_specialized = false);
|
||||
_STLP_STATIC_CONSTANT(bool, is_signed = false);
|
||||
_STLP_STATIC_CONSTANT(bool, is_integer = false);
|
||||
_STLP_STATIC_CONSTANT(bool, is_exact = false);
|
||||
_STLP_STATIC_CONSTANT(bool, has_infinity = false);
|
||||
_STLP_STATIC_CONSTANT(bool, has_quiet_NaN = false);
|
||||
_STLP_STATIC_CONSTANT(bool, has_signaling_NaN = false);
|
||||
_STLP_STATIC_CONSTANT(bool, has_denorm_loss = false);
|
||||
_STLP_STATIC_CONSTANT(bool, is_iec559 = false);
|
||||
_STLP_STATIC_CONSTANT(bool, is_bounded = false);
|
||||
_STLP_STATIC_CONSTANT(bool, is_modulo = false);
|
||||
_STLP_STATIC_CONSTANT(bool, traps = false);
|
||||
_STLP_STATIC_CONSTANT(bool, tinyness_before = false);
|
||||
|
||||
static __number _STLP_CALL epsilon() _STLP_NOTHROW { return __number(); }
|
||||
static __number _STLP_CALL round_error() _STLP_NOTHROW { return __number(); }
|
||||
|
||||
static __number _STLP_CALL infinity() _STLP_NOTHROW { return __number(); }
|
||||
static __number _STLP_CALL quiet_NaN() _STLP_NOTHROW { return __number(); }
|
||||
static __number _STLP_CALL signaling_NaN() _STLP_NOTHROW { return __number(); }
|
||||
static __number _STLP_CALL denorm_min() _STLP_NOTHROW { return __number(); }
|
||||
};
|
||||
|
||||
// Base class for integers.
|
||||
|
||||
#ifdef _STLP_LIMITED_DEFAULT_TEMPLATES
|
||||
# ifdef _STLP_LONG_LONG
|
||||
# define _STLP_LIMITS_MIN_TYPE _STLP_LONG_LONG
|
||||
# define _STLP_LIMITS_MAX_TYPE unsigned _STLP_LONG_LONG
|
||||
# else
|
||||
# define _STLP_LIMITS_MIN_TYPE long
|
||||
# define _STLP_LIMITS_MAX_TYPE unsigned long
|
||||
# endif
|
||||
#else
|
||||
# define _STLP_LIMITS_MIN_TYPE _Int
|
||||
# define _STLP_LIMITS_MAX_TYPE _Int
|
||||
#endif /* _STLP_LIMITED_DEFAULT_TEMPLATES */
|
||||
|
||||
template <class _Int,
|
||||
_STLP_LIMITS_MIN_TYPE __imin,
|
||||
_STLP_LIMITS_MAX_TYPE __imax,
|
||||
int __idigits, bool __ismod>
|
||||
class _Integer_limits : public _Numeric_limits_base<_Int> {
|
||||
public:
|
||||
|
||||
static _Int (_STLP_CALL min) () _STLP_NOTHROW { return (_Int)__imin; }
|
||||
static _Int (_STLP_CALL max) () _STLP_NOTHROW { return (_Int)__imax; }
|
||||
|
||||
_STLP_STATIC_CONSTANT(int, digits = (__idigits < 0) ? ((int)((sizeof(_Int) * (CHAR_BIT))) - ((__imin == 0) ? 0 : 1)) : (__idigits));
|
||||
_STLP_STATIC_CONSTANT(int, digits10 = (digits * 301UL) / 1000);
|
||||
_STLP_STATIC_CONSTANT(int, radix = 2);
|
||||
_STLP_STATIC_CONSTANT(bool, is_specialized = true);
|
||||
_STLP_STATIC_CONSTANT(bool, is_signed = (__imin != 0));
|
||||
_STLP_STATIC_CONSTANT(bool, is_integer = true);
|
||||
_STLP_STATIC_CONSTANT(bool, is_exact = true);
|
||||
_STLP_STATIC_CONSTANT(bool, is_bounded = true);
|
||||
_STLP_STATIC_CONSTANT(bool, is_modulo = __ismod);
|
||||
};
|
||||
|
||||
// Base class for floating-point numbers.
|
||||
template <class __number,
|
||||
int __Digits, int __Digits10,
|
||||
int __MinExp, int __MaxExp,
|
||||
int __MinExp10, int __MaxExp10,
|
||||
bool __IsIEC559,
|
||||
float_denorm_style __DenormStyle,
|
||||
float_round_style __RoundStyle>
|
||||
class _Floating_limits : public _Numeric_limits_base<__number> {
|
||||
public:
|
||||
|
||||
_STLP_STATIC_CONSTANT(int, digits = __Digits);
|
||||
_STLP_STATIC_CONSTANT(int, digits10 = __Digits10);
|
||||
_STLP_STATIC_CONSTANT(int, radix = FLT_RADIX);
|
||||
_STLP_STATIC_CONSTANT(int, min_exponent = __MinExp);
|
||||
_STLP_STATIC_CONSTANT(int, max_exponent = __MaxExp);
|
||||
_STLP_STATIC_CONSTANT(int, min_exponent10 = __MinExp10);
|
||||
_STLP_STATIC_CONSTANT(int, max_exponent10 = __MaxExp10);
|
||||
|
||||
_STLP_STATIC_CONSTANT(float_denorm_style, has_denorm = __DenormStyle);
|
||||
_STLP_STATIC_CONSTANT(float_round_style, round_style = __RoundStyle);
|
||||
|
||||
_STLP_STATIC_CONSTANT(bool, is_specialized = true);
|
||||
_STLP_STATIC_CONSTANT(bool, is_signed = true);
|
||||
|
||||
_STLP_STATIC_CONSTANT(bool, has_infinity = true);
|
||||
#if (!defined (_STLP_MSVC) || (_STLP_MSVC > 1300)) && \
|
||||
(!defined (__BORLANDC__) || (__BORLANDC__ >= 0x590)) && \
|
||||
(!defined (_CRAY) || defined (_CRAYIEEE))
|
||||
_STLP_STATIC_CONSTANT(bool, has_quiet_NaN = true);
|
||||
_STLP_STATIC_CONSTANT(bool, has_signaling_NaN = true);
|
||||
#else
|
||||
_STLP_STATIC_CONSTANT(bool, has_quiet_NaN = false);
|
||||
_STLP_STATIC_CONSTANT(bool, has_signaling_NaN = false);
|
||||
#endif
|
||||
|
||||
_STLP_STATIC_CONSTANT(bool, is_iec559 = __IsIEC559 && has_infinity && has_quiet_NaN && has_signaling_NaN && (has_denorm == denorm_present));
|
||||
_STLP_STATIC_CONSTANT(bool, has_denorm_loss = false);
|
||||
_STLP_STATIC_CONSTANT(bool, is_bounded = true);
|
||||
_STLP_STATIC_CONSTANT(bool, traps = true);
|
||||
_STLP_STATIC_CONSTANT(bool, tinyness_before = false);
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
// Class numeric_limits
|
||||
|
||||
// The unspecialized class.
|
||||
|
||||
template<class _Tp>
|
||||
class numeric_limits : public _STLP_PRIV _Numeric_limits_base<_Tp> {};
|
||||
|
||||
// Specializations for all built-in integral types.
|
||||
|
||||
#if !defined (_STLP_NO_BOOL)
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<bool>
|
||||
: public _STLP_PRIV _Integer_limits<bool, false, true, 1, false>
|
||||
{};
|
||||
#endif /* _STLP_NO_BOOL */
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<char>
|
||||
: public _STLP_PRIV _Integer_limits<char, CHAR_MIN, CHAR_MAX, -1, true>
|
||||
{};
|
||||
|
||||
#if !defined (_STLP_NO_SIGNED_BUILTINS)
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<signed char>
|
||||
: public _STLP_PRIV _Integer_limits<signed char, SCHAR_MIN, SCHAR_MAX, -1, true>
|
||||
{};
|
||||
#endif
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<unsigned char>
|
||||
: public _STLP_PRIV _Integer_limits<unsigned char, 0, UCHAR_MAX, -1, true>
|
||||
{};
|
||||
|
||||
#if !(defined (_STLP_NO_WCHAR_T) || defined (_STLP_WCHAR_T_IS_USHORT))
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<wchar_t>
|
||||
: public _STLP_PRIV _Integer_limits<wchar_t, WCHAR_MIN, WCHAR_MAX, -1, true>
|
||||
{};
|
||||
|
||||
#endif
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<short>
|
||||
: public _STLP_PRIV _Integer_limits<short, SHRT_MIN, SHRT_MAX, -1, true>
|
||||
{};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<unsigned short>
|
||||
: public _STLP_PRIV _Integer_limits<unsigned short, 0, USHRT_MAX, -1, true>
|
||||
{};
|
||||
|
||||
#if defined (__xlC__) && (__xlC__ == 0x500)
|
||||
# undef INT_MIN
|
||||
# define INT_MIN -2147483648
|
||||
#endif
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<int>
|
||||
: public _STLP_PRIV _Integer_limits<int, INT_MIN, INT_MAX, -1, true>
|
||||
{};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<unsigned int>
|
||||
: public _STLP_PRIV _Integer_limits<unsigned int, 0, UINT_MAX, -1, true>
|
||||
{};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<long>
|
||||
: public _STLP_PRIV _Integer_limits<long, LONG_MIN, LONG_MAX, -1, true>
|
||||
{};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<unsigned long>
|
||||
: public _STLP_PRIV _Integer_limits<unsigned long, 0, ULONG_MAX, -1, true>
|
||||
{};
|
||||
|
||||
#if defined (_STLP_LONG_LONG)
|
||||
|
||||
# if defined (_STLP_MSVC) || defined (__BORLANDC__)
|
||||
# define LONGLONG_MAX 0x7fffffffffffffffi64
|
||||
# define LONGLONG_MIN (-LONGLONG_MAX-1i64)
|
||||
# define ULONGLONG_MAX 0xffffffffffffffffUi64
|
||||
# else
|
||||
# ifndef LONGLONG_MAX
|
||||
# define LONGLONG_MAX 0x7fffffffffffffffLL
|
||||
# endif
|
||||
# ifndef LONGLONG_MIN
|
||||
# define LONGLONG_MIN (-LONGLONG_MAX-1LL)
|
||||
# endif
|
||||
# ifndef ULONGLONG_MAX
|
||||
# define ULONGLONG_MAX 0xffffffffffffffffULL
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if !defined (__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ <= 96) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 3)
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<_STLP_LONG_LONG>
|
||||
: public _STLP_PRIV _Integer_limits<_STLP_LONG_LONG, LONGLONG_MIN, LONGLONG_MAX, -1, true>
|
||||
{};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<unsigned _STLP_LONG_LONG>
|
||||
: public _STLP_PRIV _Integer_limits<unsigned _STLP_LONG_LONG, 0, ULONGLONG_MAX, -1, true>
|
||||
{};
|
||||
# else /* gcc 2.97 (after 2000-11-01), 2.98, 3.0 */
|
||||
/*
|
||||
newest gcc has new mangling scheme, that has problem
|
||||
with generating name [instantiated] of template specialization like
|
||||
_Integer_limits<_STLP_LONG_LONG, LONGLONG_MIN, LONGLONG_MAX, -1, true>
|
||||
~~~~~~~~~~~~ ~~~~~~~~~~~~
|
||||
Below is code that solve this problem.
|
||||
- ptr
|
||||
*/
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<_STLP_LONG_LONG>
|
||||
: public _STLP_PRIV _Numeric_limits_base<_STLP_LONG_LONG> {
|
||||
public:
|
||||
|
||||
static _STLP_LONG_LONG (_STLP_CALL min) () _STLP_NOTHROW { return LONGLONG_MIN; }
|
||||
static _STLP_LONG_LONG (_STLP_CALL max) () _STLP_NOTHROW { return LONGLONG_MAX; }
|
||||
|
||||
_STLP_STATIC_CONSTANT(int, digits = ((int)((sizeof(_STLP_LONG_LONG) * (CHAR_BIT))) - 1));
|
||||
_STLP_STATIC_CONSTANT(int, digits10 = (digits * 301UL) / 1000);
|
||||
_STLP_STATIC_CONSTANT(int, radix = 2);
|
||||
_STLP_STATIC_CONSTANT(bool, is_specialized = true);
|
||||
_STLP_STATIC_CONSTANT(bool, is_signed = true);
|
||||
_STLP_STATIC_CONSTANT(bool, is_integer = true);
|
||||
_STLP_STATIC_CONSTANT(bool, is_exact = true);
|
||||
_STLP_STATIC_CONSTANT(bool, is_bounded = true);
|
||||
_STLP_STATIC_CONSTANT(bool, is_modulo = true);
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<unsigned _STLP_LONG_LONG>
|
||||
: public _STLP_PRIV _Numeric_limits_base<unsigned _STLP_LONG_LONG> {
|
||||
public:
|
||||
|
||||
static unsigned _STLP_LONG_LONG (_STLP_CALL min) () _STLP_NOTHROW { return 0ULL; }
|
||||
static unsigned _STLP_LONG_LONG (_STLP_CALL max) () _STLP_NOTHROW { return ULONGLONG_MAX; }
|
||||
|
||||
_STLP_STATIC_CONSTANT(int, digits = ((int)((sizeof(unsigned _STLP_LONG_LONG) * (CHAR_BIT)))));
|
||||
_STLP_STATIC_CONSTANT(int, digits10 = (digits * 301UL) / 1000);
|
||||
_STLP_STATIC_CONSTANT(int, radix = 2);
|
||||
_STLP_STATIC_CONSTANT(bool, is_specialized = true);
|
||||
_STLP_STATIC_CONSTANT(bool, is_signed = false);
|
||||
_STLP_STATIC_CONSTANT(bool, is_integer = true);
|
||||
_STLP_STATIC_CONSTANT(bool, is_exact = true);
|
||||
_STLP_STATIC_CONSTANT(bool, is_bounded = true);
|
||||
_STLP_STATIC_CONSTANT(bool, is_modulo = true);
|
||||
};
|
||||
|
||||
# endif /* __GNUC__ > 2000-11-01 */
|
||||
|
||||
#endif /* _STLP_LONG_LONG */
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
// Specializations for all built-in floating-point types.
|
||||
template <class __dummy>
|
||||
class _LimG {
|
||||
public:
|
||||
static float _STLP_CALL get_F_inf();
|
||||
static float _STLP_CALL get_F_qNaN();
|
||||
static float _STLP_CALL get_F_sNaN();
|
||||
static float _STLP_CALL get_F_denormMin();
|
||||
static double _STLP_CALL get_D_inf();
|
||||
static double _STLP_CALL get_D_qNaN();
|
||||
static double _STLP_CALL get_D_sNaN();
|
||||
static double _STLP_CALL get_D_denormMin();
|
||||
|
||||
#if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
static long double _STLP_CALL get_LD_inf();
|
||||
static long double _STLP_CALL get_LD_qNaN();
|
||||
static long double _STLP_CALL get_LD_sNaN();
|
||||
static long double _STLP_CALL get_LD_denormMin();
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS _LimG<bool>;
|
||||
#endif
|
||||
|
||||
#if defined (__GNUC__)
|
||||
# if defined (__FLT_DENORM_MIN__)
|
||||
# define _STLP_FLT_DENORM_MIN __FLT_DENORM_MIN__
|
||||
# else
|
||||
# define _STLP_FLT_DENORM_STYLE denorm_absent
|
||||
# endif
|
||||
# if defined (__DBL_DENORM_MIN__)
|
||||
# define _STLP_DBL_DENORM_MIN __DBL_DENORM_MIN__
|
||||
# else
|
||||
# define _STLP_DBL_DENORM_STYLE denorm_absent
|
||||
# endif
|
||||
# if defined (__LDBL_DENORM_MIN__)
|
||||
# define _STLP_LDBL_DENORM_MIN __LDBL_DENORM_MIN__
|
||||
# else
|
||||
# define _STLP_LDBL_DENORM_STYLE denorm_absent
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If compiler do not expose thanks to some macro its status regarding
|
||||
* denormalized floating point numbers, we consider that denormalization
|
||||
* is present. Unit tests will tell us if compiler do not support them. */
|
||||
#if !defined (_STLP_FLT_DENORM_STYLE)
|
||||
# define _STLP_FLT_DENORM_STYLE denorm_present
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_DBL_DENORM_STYLE)
|
||||
# define _STLP_DBL_DENORM_STYLE denorm_present
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_LDBL_DENORM_STYLE)
|
||||
# define _STLP_LDBL_DENORM_STYLE denorm_present
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<float>
|
||||
: public _STLP_PRIV _Floating_limits<float,
|
||||
FLT_MANT_DIG, // Binary digits of precision
|
||||
FLT_DIG, // Decimal digits of precision
|
||||
FLT_MIN_EXP, // Minimum exponent
|
||||
FLT_MAX_EXP, // Maximum exponent
|
||||
FLT_MIN_10_EXP, // Minimum base 10 exponent
|
||||
FLT_MAX_10_EXP, // Maximum base 10 exponent
|
||||
true,
|
||||
_STLP_FLT_DENORM_STYLE,
|
||||
round_to_nearest> {
|
||||
public:
|
||||
static float (_STLP_CALL min) () _STLP_NOTHROW { return FLT_MIN; }
|
||||
static float _STLP_CALL denorm_min() _STLP_NOTHROW
|
||||
#if defined (_STLP_FLT_DENORM_MIN)
|
||||
{ return _STLP_FLT_DENORM_MIN; }
|
||||
#else
|
||||
{ return _STLP_FLT_DENORM_STYLE ? _STLP_PRIV _LimG<bool>::get_F_denormMin() : FLT_MIN; }
|
||||
#endif
|
||||
static float (_STLP_CALL max) () _STLP_NOTHROW { return FLT_MAX; }
|
||||
static float _STLP_CALL epsilon() _STLP_NOTHROW { return FLT_EPSILON; }
|
||||
static float _STLP_CALL round_error() _STLP_NOTHROW { return 0.5f; } // Units: ulps.
|
||||
static float _STLP_CALL infinity() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_F_inf(); }
|
||||
static float _STLP_CALL quiet_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_F_qNaN(); }
|
||||
static float _STLP_CALL signaling_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_F_sNaN(); }
|
||||
};
|
||||
|
||||
#undef _STLP_FLT_DENORM_MIN
|
||||
#undef _STLP_FLT_DNORM_STYLE
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<double>
|
||||
: public _STLP_PRIV _Floating_limits<double,
|
||||
DBL_MANT_DIG, // Binary digits of precision
|
||||
DBL_DIG, // Decimal digits of precision
|
||||
DBL_MIN_EXP, // Minimum exponent
|
||||
DBL_MAX_EXP, // Maximum exponent
|
||||
DBL_MIN_10_EXP, // Minimum base 10 exponent
|
||||
DBL_MAX_10_EXP, // Maximum base 10 exponent
|
||||
true,
|
||||
_STLP_DBL_DENORM_STYLE,
|
||||
round_to_nearest> {
|
||||
public:
|
||||
static double (_STLP_CALL min)() _STLP_NOTHROW { return DBL_MIN; }
|
||||
static double _STLP_CALL denorm_min() _STLP_NOTHROW
|
||||
#if defined (_STLP_DBL_DENORM_MIN)
|
||||
{ return _STLP_DBL_DENORM_MIN; }
|
||||
#else
|
||||
{ return _STLP_DBL_DENORM_STYLE ? _STLP_PRIV _LimG<bool>::get_D_denormMin() : DBL_MIN; }
|
||||
#endif
|
||||
static double (_STLP_CALL max)() _STLP_NOTHROW { return DBL_MAX; }
|
||||
static double _STLP_CALL epsilon() _STLP_NOTHROW { return DBL_EPSILON; }
|
||||
static double _STLP_CALL round_error() _STLP_NOTHROW { return 0.5; } // Units: ulps.
|
||||
static double _STLP_CALL infinity() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_D_inf(); }
|
||||
static double _STLP_CALL quiet_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_D_qNaN(); }
|
||||
static double _STLP_CALL signaling_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_D_sNaN(); }
|
||||
};
|
||||
|
||||
#if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class numeric_limits<long double>
|
||||
: public _STLP_PRIV _Floating_limits<long double,
|
||||
LDBL_MANT_DIG, // Binary digits of precision
|
||||
LDBL_DIG, // Decimal digits of precision
|
||||
LDBL_MIN_EXP, // Minimum exponent
|
||||
LDBL_MAX_EXP, // Maximum exponent
|
||||
LDBL_MIN_10_EXP,// Minimum base 10 exponent
|
||||
LDBL_MAX_10_EXP,// Maximum base 10 exponent
|
||||
false, // do not conform to iec559
|
||||
_STLP_LDBL_DENORM_STYLE,
|
||||
round_to_nearest> {
|
||||
public:
|
||||
static long double (_STLP_CALL min) () _STLP_NOTHROW { return LDBL_MIN; }
|
||||
static long double _STLP_CALL denorm_min() _STLP_NOTHROW
|
||||
#if defined (_STLP_LDBL_DENORM_MIN)
|
||||
{ return _STLP_LDBL_DENORM_MIN; }
|
||||
#else
|
||||
{ return _STLP_LDBL_DENORM_STYLE ? _STLP_PRIV _LimG<bool>::get_LD_denormMin() : LDBL_MIN; }
|
||||
#endif
|
||||
_STLP_STATIC_CONSTANT(bool, is_iec559 = false);
|
||||
static long double (_STLP_CALL max) () _STLP_NOTHROW { return LDBL_MAX; }
|
||||
static long double _STLP_CALL epsilon() _STLP_NOTHROW { return LDBL_EPSILON; }
|
||||
static long double _STLP_CALL round_error() _STLP_NOTHROW { return 0.5l; }
|
||||
static long double _STLP_CALL infinity() _STLP_NOTHROW
|
||||
//For MSVC, long double is nothing more than an alias for double.
|
||||
#if !defined (_STLP_MSVC)
|
||||
{ return _STLP_PRIV _LimG<bool>::get_LD_inf(); }
|
||||
#else
|
||||
{ return _STLP_PRIV _LimG<bool>::get_D_inf(); }
|
||||
#endif
|
||||
static long double _STLP_CALL quiet_NaN() _STLP_NOTHROW
|
||||
#if !defined (_STLP_MSVC)
|
||||
{ return _STLP_PRIV _LimG<bool>::get_LD_qNaN(); }
|
||||
#else
|
||||
{ return _STLP_PRIV _LimG<bool>::get_D_qNaN(); }
|
||||
#endif
|
||||
static long double _STLP_CALL signaling_NaN() _STLP_NOTHROW
|
||||
#if !defined (_STLP_MSVC)
|
||||
{ return _STLP_PRIV _LimG<bool>::get_LD_sNaN(); }
|
||||
#else
|
||||
{ return _STLP_PRIV _LimG<bool>::get_D_sNaN(); }
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// We write special values (Inf and NaN) as bit patterns and
|
||||
// cast the the appropriate floating-point types.
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_limits.c>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
250
extern/STLport/5.2.1/stlport/stl/_list.c
vendored
Normal file
250
extern/STLport/5.2.1/stlport/stl/_list.c
vendored
Normal file
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_LIST_C
|
||||
#define _STLP_LIST_C
|
||||
|
||||
#ifndef _STLP_INTERNAL_LIST_H
|
||||
# include <stl/_list.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_CARRAY_H
|
||||
# include <stl/_carray.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_RANGE_ERRORS_H
|
||||
# include <stl/_range_errors.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION)
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
_List_global<_Dummy>::_Transfer(_List_node_base* __position,
|
||||
_List_node_base* __first, _List_node_base* __last) {
|
||||
if (__position != __last) {
|
||||
// Remove [first, last) from its old position.
|
||||
__last->_M_prev->_M_next = __position;
|
||||
__first->_M_prev->_M_next = __last;
|
||||
__position->_M_prev->_M_next = __first;
|
||||
|
||||
// Splice [first, last) into its new position.
|
||||
_Node_base* __tmp = __position->_M_prev;
|
||||
__position->_M_prev = __last->_M_prev;
|
||||
__last->_M_prev = __first->_M_prev;
|
||||
__first->_M_prev = __tmp;
|
||||
}
|
||||
}
|
||||
#endif /* _STLP_EXPOSE_GLOBALS_IMPLEMENTATION */
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
void _List_base<_Tp,_Alloc>::clear() {
|
||||
_Node* __cur = __STATIC_CAST(_Node*, _M_node._M_data._M_next);
|
||||
while (
|
||||
#if defined (__BORLANDC__) // runtime error
|
||||
__cur &&
|
||||
#endif
|
||||
__cur != &(_M_node._M_data)) {
|
||||
_Node* __tmp = __cur;
|
||||
__cur = __STATIC_CAST(_Node*, __cur->_M_next);
|
||||
_STLP_STD::_Destroy(&__tmp->_M_data);
|
||||
this->_M_node.deallocate(__tmp, 1);
|
||||
}
|
||||
_M_node._M_data._M_next = &_M_node._M_data;
|
||||
_M_node._M_data._M_prev = &_M_node._M_data;
|
||||
}
|
||||
|
||||
#if defined (_STLP_NESTED_TYPE_PARAM_BUG)
|
||||
# define size_type size_t
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_USE_PTR_SPECIALIZATIONS)
|
||||
# define list _STLP_PTR_IMPL_NAME(list)
|
||||
#elif defined (_STLP_DEBUG)
|
||||
# define list _STLP_NON_DBG_NAME(list)
|
||||
#else
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
void list<_Tp, _Alloc>::resize(size_type __new_size, const _Tp& __x) {
|
||||
iterator __i = begin();
|
||||
size_type __len = 0;
|
||||
for ( ; __i != end() && __len < __new_size; ++__i, ++__len);
|
||||
|
||||
if (__len == __new_size)
|
||||
erase(__i, end());
|
||||
else // __i == end()
|
||||
insert(end(), __new_size - __len, __x);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list<_Tp, _Alloc>& __x) {
|
||||
if (this != &__x) {
|
||||
iterator __first1 = begin();
|
||||
iterator __last1 = end();
|
||||
const_iterator __first2 = __x.begin();
|
||||
const_iterator __last2 = __x.end();
|
||||
while (__first1 != __last1 && __first2 != __last2)
|
||||
*__first1++ = *__first2++;
|
||||
if (__first2 == __last2)
|
||||
erase(__first1, __last1);
|
||||
else
|
||||
insert(__last1, __first2, __last2);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
void list<_Tp, _Alloc>::_M_fill_assign(size_type __n, const _Tp& __val) {
|
||||
iterator __i = begin();
|
||||
for ( ; __i != end() && __n > 0; ++__i, --__n)
|
||||
*__i = __val;
|
||||
if (__n > 0)
|
||||
insert(end(), __n, __val);
|
||||
else
|
||||
erase(__i, end());
|
||||
}
|
||||
|
||||
#if !defined (list)
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Alloc, class _Predicate>
|
||||
void _S_remove_if(list<_Tp, _Alloc>& __that, _Predicate __pred) {
|
||||
typedef typename list<_Tp, _Alloc>::iterator _Literator;
|
||||
_Literator __first = __that.begin();
|
||||
_Literator __last = __that.end();
|
||||
while (__first != __last) {
|
||||
_Literator __next = __first;
|
||||
++__next;
|
||||
if (__pred(*__first)) __that.erase(__first);
|
||||
__first = __next;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc, class _BinaryPredicate>
|
||||
void _S_unique(list<_Tp, _Alloc>& __that, _BinaryPredicate __binary_pred) {
|
||||
typedef typename list<_Tp, _Alloc>::iterator _Literator;
|
||||
_Literator __first = __that.begin();
|
||||
_Literator __last = __that.end();
|
||||
if (__first == __last) return;
|
||||
_Literator __next = __first;
|
||||
while (++__next != __last) {
|
||||
if (__binary_pred(*__first, *__next))
|
||||
__that.erase(__next);
|
||||
else
|
||||
__first = __next;
|
||||
__next = __first;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc, class _StrictWeakOrdering>
|
||||
void _S_merge(list<_Tp, _Alloc>& __that, list<_Tp, _Alloc>& __x,
|
||||
_StrictWeakOrdering __comp) {
|
||||
typedef typename list<_Tp, _Alloc>::iterator _Literator;
|
||||
_Literator __first1 = __that.begin();
|
||||
_Literator __last1 = __that.end();
|
||||
_Literator __first2 = __x.begin();
|
||||
_Literator __last2 = __x.end();
|
||||
if (__that.get_allocator() == __x.get_allocator()) {
|
||||
while (__first1 != __last1 && __first2 != __last2) {
|
||||
if (__comp(*__first2, *__first1)) {
|
||||
_STLP_VERBOSE_ASSERT(!__comp(*__first1, *__first2), _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
|
||||
_Literator __next = __first2;
|
||||
_List_global_inst::_Transfer(__first1._M_node, __first2._M_node, (++__next)._M_node);
|
||||
__first2 = __next;
|
||||
}
|
||||
else
|
||||
++__first1;
|
||||
}
|
||||
if (__first2 != __last2)
|
||||
_List_global_inst::_Transfer(__last1._M_node, __first2._M_node, __last2._M_node);
|
||||
}
|
||||
else {
|
||||
while (__first1 != __last1 && __first2 != __last2) {
|
||||
if (__comp(*__first2, *__first1)) {
|
||||
_STLP_VERBOSE_ASSERT(!__comp(*__first1, *__first2), _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
|
||||
__first1 = __that.insert(__first1, *__first2);
|
||||
}
|
||||
else
|
||||
++__first1;
|
||||
}
|
||||
if (__first2 != __last2) {
|
||||
__that.insert(__first1, __first2, __last2);
|
||||
}
|
||||
__x.clear();
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc, class _StrictWeakOrdering>
|
||||
void _S_sort(list<_Tp, _Alloc>& __that, _StrictWeakOrdering __comp) {
|
||||
// Do nothing if the list has length 0 or 1.
|
||||
if (__that._M_node._M_data._M_next == &__that._M_node._M_data ||
|
||||
__that._M_node._M_data._M_next->_M_next == &__that._M_node._M_data)
|
||||
return;
|
||||
|
||||
list<_Tp, _Alloc> __carry(__that.get_allocator());
|
||||
const int NB = 64;
|
||||
_STLP_PRIV _CArray<list<_Tp, _Alloc>, NB> __counter(__carry);
|
||||
int __fill = 0;
|
||||
while (!__that.empty()) {
|
||||
__carry.splice(__carry.begin(), __that, __that.begin());
|
||||
int __i = 0;
|
||||
while (__i < __fill && !__counter[__i].empty()) {
|
||||
_S_merge(__counter[__i], __carry, __comp);
|
||||
__carry.swap(__counter[__i++]);
|
||||
}
|
||||
__carry.swap(__counter[__i]);
|
||||
if (__i == __fill) {
|
||||
++__fill;
|
||||
if (__fill >= NB) {
|
||||
//Looks like the list has too many elements to be sorted with this algorithm:
|
||||
__stl_throw_overflow_error("list::sort");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int __i = 1; __i < __fill; ++__i)
|
||||
_S_merge(__counter[__i], __counter[__i - 1], __comp);
|
||||
__that.swap(__counter[__fill - 1]);
|
||||
}
|
||||
|
||||
#if defined (list)
|
||||
# undef list
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_LIST_C */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
742
extern/STLport/5.2.1/stlport/stl/_list.h
vendored
Normal file
742
extern/STLport/5.2.1/stlport/stl/_list.h
vendored
Normal file
@@ -0,0 +1,742 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_LIST_IMPL_H
|
||||
#define _STLP_INTERNAL_LIST_IMPL_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALGOBASE_H
|
||||
# include <stl/_algobase.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALLOC_H
|
||||
# include <stl/_alloc.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_H
|
||||
# include <stl/_iterator.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_CONSTRUCT_H
|
||||
# include <stl/_construct.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
|
||||
# include <stl/_function_base.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
struct _List_node_base {
|
||||
_List_node_base* _M_next;
|
||||
_List_node_base* _M_prev;
|
||||
};
|
||||
|
||||
template <class _Dummy>
|
||||
class _List_global {
|
||||
public:
|
||||
typedef _List_node_base _Node_base;
|
||||
static void _STLP_CALL _Transfer(_Node_base* __pos,
|
||||
_Node_base* __first, _Node_base* __last);
|
||||
};
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS _List_global<bool>;
|
||||
#endif
|
||||
typedef _List_global<bool> _List_global_inst;
|
||||
|
||||
template <class _Tp>
|
||||
class _List_node : public _List_node_base {
|
||||
public:
|
||||
_Tp _M_data;
|
||||
__TRIVIAL_STUFF(_List_node)
|
||||
};
|
||||
|
||||
struct _List_iterator_base {
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef bidirectional_iterator_tag iterator_category;
|
||||
|
||||
_List_node_base* _M_node;
|
||||
|
||||
_List_iterator_base(_List_node_base* __x) : _M_node(__x) {}
|
||||
|
||||
void _M_incr() { _M_node = _M_node->_M_next; }
|
||||
void _M_decr() { _M_node = _M_node->_M_prev; }
|
||||
};
|
||||
|
||||
|
||||
template<class _Tp, class _Traits>
|
||||
struct _List_iterator : public _List_iterator_base {
|
||||
typedef _Tp value_type;
|
||||
typedef typename _Traits::pointer pointer;
|
||||
typedef typename _Traits::reference reference;
|
||||
|
||||
typedef _List_iterator<_Tp, _Traits> _Self;
|
||||
typedef typename _Traits::_NonConstTraits _NonConstTraits;
|
||||
typedef _List_iterator<_Tp, _NonConstTraits> iterator;
|
||||
typedef typename _Traits::_ConstTraits _ConstTraits;
|
||||
typedef _List_iterator<_Tp, _ConstTraits> const_iterator;
|
||||
|
||||
typedef bidirectional_iterator_tag iterator_category;
|
||||
typedef _List_node<_Tp> _Node;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
|
||||
explicit _List_iterator(_List_node_base* __x) : _List_iterator_base(__x) {}
|
||||
_List_iterator() : _List_iterator_base(0) {}
|
||||
//copy constructor for iterator and constructor from iterator for const_iterator
|
||||
_List_iterator(const iterator& __x) : _List_iterator_base(__x._M_node) {}
|
||||
|
||||
reference operator*() const { return __STATIC_CAST(_Node*, this->_M_node)->_M_data; }
|
||||
|
||||
_STLP_DEFINE_ARROW_OPERATOR
|
||||
|
||||
_Self& operator++() {
|
||||
this->_M_incr();
|
||||
return *this;
|
||||
}
|
||||
_Self operator++(int) {
|
||||
_Self __tmp = *this;
|
||||
this->_M_incr();
|
||||
return __tmp;
|
||||
}
|
||||
_Self& operator--() {
|
||||
this->_M_decr();
|
||||
return *this;
|
||||
}
|
||||
_Self operator--(int) {
|
||||
_Self __tmp = *this;
|
||||
this->_M_decr();
|
||||
return __tmp;
|
||||
}
|
||||
bool operator==(const_iterator __y ) const {
|
||||
return this->_M_node == __y._M_node;
|
||||
}
|
||||
bool operator!=(const_iterator __y ) const {
|
||||
return this->_M_node != __y._M_node;
|
||||
}
|
||||
};
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
template <class _Tp, class _Traits>
|
||||
struct __type_traits<_STLP_PRIV _List_iterator<_Tp, _Traits> > {
|
||||
typedef __false_type has_trivial_default_constructor;
|
||||
typedef __true_type has_trivial_copy_constructor;
|
||||
typedef __true_type has_trivial_assignment_operator;
|
||||
typedef __true_type has_trivial_destructor;
|
||||
typedef __false_type is_POD_type;
|
||||
};
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
template <class _Tp, class _Traits>
|
||||
inline _Tp* value_type(const _STLP_PRIV _List_iterator<_Tp, _Traits>&) { return 0; }
|
||||
inline bidirectional_iterator_tag iterator_category(const _STLP_PRIV _List_iterator_base&) { return bidirectional_iterator_tag();}
|
||||
inline ptrdiff_t* distance_type(const _STLP_PRIV _List_iterator_base&) { return 0; }
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
#endif
|
||||
|
||||
// Base class that encapsulates details of allocators and helps
|
||||
// to simplify EH
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
class _List_base {
|
||||
protected:
|
||||
_STLP_FORCE_ALLOCATORS(_Tp, _Alloc)
|
||||
typedef _List_node_base _Node_base;
|
||||
typedef _List_node<_Tp> _Node;
|
||||
typedef _List_base<_Tp, _Alloc> _Self;
|
||||
typedef typename _Alloc_traits<_Node, _Alloc>::allocator_type _Node_allocator_type;
|
||||
public:
|
||||
typedef _STLP_alloc_proxy<_Node_base, _Node, _Node_allocator_type> _AllocProxy;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
allocator_type get_allocator() const
|
||||
{ return _STLP_CONVERT_ALLOCATOR((const _Node_allocator_type&)_M_node, _Tp); }
|
||||
|
||||
_List_base(const allocator_type& __a) : _M_node(_STLP_CONVERT_ALLOCATOR(__a, _Node), _Node_base())
|
||||
{ _M_empty_initialize(); }
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
_List_base(__move_source<_Self> src) :
|
||||
_M_node(__move_source<_AllocProxy>(src.get()._M_node)) {
|
||||
if (src.get().empty())
|
||||
//We force this to empty.
|
||||
_M_empty_initialize();
|
||||
else {
|
||||
src.get()._M_empty_initialize();
|
||||
_M_node._M_data._M_prev->_M_next = _M_node._M_data._M_next->_M_prev = &_M_node._M_data;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
~_List_base()
|
||||
{ clear(); }
|
||||
|
||||
void clear();
|
||||
bool empty() const { return _M_node._M_data._M_next == &_M_node._M_data; }
|
||||
|
||||
void _M_empty_initialize() {
|
||||
_M_node._M_data._M_next = &_M_node._M_data;
|
||||
_M_node._M_data._M_prev = _M_node._M_data._M_next;
|
||||
}
|
||||
|
||||
public:
|
||||
_AllocProxy _M_node;
|
||||
};
|
||||
|
||||
#if defined (_STLP_USE_PTR_SPECIALIZATIONS)
|
||||
# define list _STLP_PTR_IMPL_NAME(list)
|
||||
#elif defined (_STLP_DEBUG)
|
||||
# define list _STLP_NON_DBG_NAME(list)
|
||||
#else
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
#endif
|
||||
|
||||
template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
|
||||
class list;
|
||||
|
||||
#if !defined (list)
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
#endif
|
||||
|
||||
// helper functions to reduce code duplication
|
||||
template <class _Tp, class _Alloc, class _Predicate>
|
||||
void _S_remove_if(list<_Tp, _Alloc>& __that, _Predicate __pred);
|
||||
|
||||
template <class _Tp, class _Alloc, class _BinaryPredicate>
|
||||
void _S_unique(list<_Tp, _Alloc>& __that, _BinaryPredicate __binary_pred);
|
||||
|
||||
template <class _Tp, class _Alloc, class _StrictWeakOrdering>
|
||||
void _S_merge(list<_Tp, _Alloc>& __that, list<_Tp, _Alloc>& __x,
|
||||
_StrictWeakOrdering __comp);
|
||||
|
||||
template <class _Tp, class _Alloc, class _StrictWeakOrdering>
|
||||
void _S_sort(list<_Tp, _Alloc>& __that, _StrictWeakOrdering __comp);
|
||||
|
||||
#if !defined (list)
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
class list : public _STLP_PRIV _List_base<_Tp, _Alloc>
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (list)
|
||||
, public __stlport_class<list<_Tp, _Alloc> >
|
||||
#endif
|
||||
{
|
||||
typedef _STLP_PRIV _List_base<_Tp, _Alloc> _Base;
|
||||
typedef list<_Tp, _Alloc> _Self;
|
||||
typedef _STLP_PRIV _List_node<_Tp> _Node;
|
||||
typedef _STLP_PRIV _List_node_base _Node_base;
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
_STLP_FORCE_ALLOCATORS(_Tp, _Alloc)
|
||||
typedef typename _Base::allocator_type allocator_type;
|
||||
typedef bidirectional_iterator_tag _Iterator_category;
|
||||
|
||||
public:
|
||||
typedef _STLP_PRIV _List_iterator<_Tp, _Nonconst_traits<_Tp> > iterator;
|
||||
typedef _STLP_PRIV _List_iterator<_Tp, _Const_traits<_Tp> > const_iterator;
|
||||
_STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS;
|
||||
|
||||
protected:
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
_Node_base* _M_create_node(const_reference __x = value_type()) {
|
||||
#else
|
||||
_Node_base* _M_create_node(const_reference __x) {
|
||||
#endif
|
||||
_Node* __p = this->_M_node.allocate(1);
|
||||
_STLP_TRY {
|
||||
_Copy_Construct(&__p->_M_data, __x);
|
||||
}
|
||||
_STLP_UNWIND(this->_M_node.deallocate(__p, 1))
|
||||
return __p;
|
||||
}
|
||||
|
||||
#if defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
_Node_base* _M_create_node() {
|
||||
_Node* __p = this->_M_node.allocate(1);
|
||||
_STLP_TRY {
|
||||
_STLP_STD::_Construct(&__p->_M_data);
|
||||
}
|
||||
_STLP_UNWIND(this->_M_node.deallocate(__p, 1))
|
||||
return __p;
|
||||
}
|
||||
#endif
|
||||
|
||||
public:
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
explicit list(size_type __n, const_reference __val = _STLP_DEFAULT_CONSTRUCTED(value_type),
|
||||
const allocator_type& __a = allocator_type())
|
||||
#else
|
||||
explicit list(size_type __n)
|
||||
: _STLP_PRIV _List_base<_Tp, _Alloc>(allocator_type())
|
||||
{ this->insert(begin(), __n, _STLP_DEFAULT_CONSTRUCTED(value_type)); }
|
||||
list(size_type __n, const_reference __val)
|
||||
: _STLP_PRIV _List_base<_Tp, _Alloc>(allocator_type())
|
||||
{ this->insert(begin(), __n, __val); }
|
||||
list(size_type __n, const_reference __val, const allocator_type& __a)
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
: _STLP_PRIV _List_base<_Tp, _Alloc>(__a)
|
||||
{ this->insert(begin(), __n, __val); }
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
// We don't need any dispatching tricks here, because insert does all of
|
||||
// that anyway.
|
||||
template <class _InputIterator>
|
||||
list(_InputIterator __first, _InputIterator __last,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
||||
: _STLP_PRIV _List_base<_Tp, _Alloc>(__a)
|
||||
{ _M_insert(begin(), __first, __last); }
|
||||
|
||||
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
|
||||
template <class _InputIterator>
|
||||
list(_InputIterator __first, _InputIterator __last)
|
||||
: _STLP_PRIV _List_base<_Tp, _Alloc>(allocator_type())
|
||||
{ _M_insert(begin(), __first, __last); }
|
||||
# endif
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
list(const value_type* __first, const value_type* __last,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _STLP_PRIV _List_base<_Tp, _Alloc>(__a)
|
||||
{ _M_insert(begin(), __first, __last); }
|
||||
list(const_iterator __first, const_iterator __last,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _STLP_PRIV _List_base<_Tp, _Alloc>(__a)
|
||||
{ _M_insert(begin(), __first, __last); }
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
explicit list(const allocator_type& __a = allocator_type())
|
||||
#else
|
||||
list()
|
||||
: _STLP_PRIV _List_base<_Tp, _Alloc>(allocator_type()) {}
|
||||
list(const allocator_type& __a)
|
||||
#endif
|
||||
: _STLP_PRIV _List_base<_Tp, _Alloc>(__a) {}
|
||||
|
||||
list(const _Self& __x) : _STLP_PRIV _List_base<_Tp, _Alloc>(__x.get_allocator())
|
||||
{ _M_insert(begin(), __x.begin(), __x.end()); }
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
list(__move_source<_Self> src)
|
||||
: _STLP_PRIV _List_base<_Tp, _Alloc>(__move_source<_Base>(src.get())) {}
|
||||
#endif
|
||||
|
||||
~list() {}
|
||||
|
||||
_Self& operator = (const _Self& __x);
|
||||
|
||||
iterator begin() { return iterator(this->_M_node._M_data._M_next); }
|
||||
const_iterator begin() const { return const_iterator(this->_M_node._M_data._M_next); }
|
||||
|
||||
iterator end() { return iterator(&this->_M_node._M_data); }
|
||||
const_iterator end() const { return const_iterator(__CONST_CAST(_Node_base*, &this->_M_node._M_data)); }
|
||||
|
||||
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
||||
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
|
||||
|
||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
||||
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
|
||||
|
||||
size_type size() const {
|
||||
size_type __result = _STLP_STD::distance(begin(), end());
|
||||
return __result;
|
||||
}
|
||||
size_type max_size() const { return size_type(-1); }
|
||||
|
||||
reference front() { return *begin(); }
|
||||
const_reference front() const { return *begin(); }
|
||||
reference back() { return *(--end()); }
|
||||
const_reference back() const { return *(--end()); }
|
||||
|
||||
private:
|
||||
void _M_swap_aux(_Self& __x) {
|
||||
__x._M_node._M_swap_alloc(this->_M_node);
|
||||
__x._M_node._M_data._M_next = this->_M_node._M_data._M_next;
|
||||
__x._M_node._M_data._M_next->_M_prev = &__x._M_node._M_data;
|
||||
__x._M_node._M_data._M_prev = this->_M_node._M_data._M_prev;
|
||||
__x._M_node._M_data._M_prev->_M_next = &__x._M_node._M_data;
|
||||
this->_M_empty_initialize();
|
||||
}
|
||||
|
||||
public:
|
||||
void swap(_Self& __x) {
|
||||
if (__x.empty()) {
|
||||
if (this->empty()) {
|
||||
return;
|
||||
}
|
||||
this->_M_swap_aux(__x);
|
||||
} else if (this->empty()) {
|
||||
__x._M_swap_aux(*this);
|
||||
} else {
|
||||
this->_M_node.swap(__x._M_node);
|
||||
_STLP_STD::swap(this->_M_node._M_data._M_prev->_M_next, __x._M_node._M_data._M_prev->_M_next);
|
||||
_STLP_STD::swap(this->_M_node._M_data._M_next->_M_prev, __x._M_node._M_data._M_next->_M_prev);
|
||||
}
|
||||
}
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(_Self& __x) { swap(__x); }
|
||||
#endif
|
||||
|
||||
#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
|
||||
iterator insert(iterator __pos, const_reference __x = value_type())
|
||||
#else
|
||||
iterator insert(iterator __pos, const_reference __x)
|
||||
#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
|
||||
{
|
||||
_Node_base* __tmp = _M_create_node(__x);
|
||||
_Node_base* __n = __pos._M_node;
|
||||
_Node_base* __p = __n->_M_prev;
|
||||
__tmp->_M_next = __n;
|
||||
__tmp->_M_prev = __p;
|
||||
__p->_M_next = __tmp;
|
||||
__n->_M_prev = __tmp;
|
||||
return iterator(__tmp);
|
||||
}
|
||||
|
||||
private:
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void _M_insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
|
||||
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
|
||||
_M_insert_dispatch(__pos, __first, __last, _Integral());
|
||||
}
|
||||
|
||||
// Check whether it's an integral type. If so, it's not an iterator.
|
||||
template<class _Integer>
|
||||
void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
|
||||
const __true_type& /*_IsIntegral*/) {
|
||||
_M_fill_insert(__pos, __n, __x);
|
||||
}
|
||||
template <class _InputIter>
|
||||
void _M_insert_dispatch(iterator __pos,
|
||||
_InputIter __first, _InputIter __last,
|
||||
const __false_type& /*_IsIntegral*/) {
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
void _M_insert(iterator __pos, const value_type* __first, const value_type* __last) {
|
||||
for (; __first != __last; ++__first)
|
||||
insert(__pos, *__first);
|
||||
}
|
||||
void _M_insert(iterator __pos, const_iterator __first, const_iterator __last) {
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
//We use a temporary list to avoid the auto reference troubles (infinite loop)
|
||||
for (; __first != __last; ++__first)
|
||||
insert(__pos, *__first);
|
||||
}
|
||||
|
||||
public:
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
|
||||
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
|
||||
_M_splice_insert_dispatch(__pos, __first, __last, _Integral());
|
||||
}
|
||||
|
||||
private:
|
||||
// Check whether it's an integral type. If so, it's not an iterator.
|
||||
template<class _Integer>
|
||||
void _M_splice_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
|
||||
const __true_type& /*_IsIntegral*/) {
|
||||
_M_fill_insert(__pos, __n, __x);
|
||||
}
|
||||
template <class _InputIter>
|
||||
void _M_splice_insert_dispatch(iterator __pos,
|
||||
_InputIter __first, _InputIter __last,
|
||||
const __false_type& /*_IsIntegral*/) {
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
void insert(iterator __pos, const value_type* __first, const value_type* __last) {
|
||||
_Self __tmp(__first, __last, this->get_allocator());
|
||||
_STLP_ASSERT(__tmp.get_allocator() == this->get_allocator())
|
||||
splice(__pos, __tmp);
|
||||
}
|
||||
void insert(iterator __pos, const_iterator __first, const_iterator __last) {
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
//We use a temporary list to avoid the auto reference troubles (infinite loop)
|
||||
_Self __tmp(__first, __last, this->get_allocator());
|
||||
splice(__pos, __tmp);
|
||||
}
|
||||
|
||||
public:
|
||||
void insert(iterator __pos, size_type __n, const_reference __x)
|
||||
{ _M_fill_insert(__pos, __n, __x); }
|
||||
|
||||
private:
|
||||
void _M_fill_insert(iterator __pos, size_type __n, const_reference __x) {
|
||||
for ( ; __n > 0; --__n)
|
||||
insert(__pos, __x);
|
||||
}
|
||||
|
||||
public:
|
||||
void push_front(const_reference __x) { insert(begin(), __x); }
|
||||
void push_back (const_reference __x) { insert(end(), __x); }
|
||||
|
||||
#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
|
||||
iterator insert(iterator __pos)
|
||||
{ return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(value_type)); }
|
||||
void push_front() {insert(begin());}
|
||||
void push_back() {insert(end());}
|
||||
# endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
|
||||
|
||||
iterator erase(iterator __pos) {
|
||||
_Node_base* __next_node = __pos._M_node->_M_next;
|
||||
_Node_base* __prev_node = __pos._M_node->_M_prev;
|
||||
_Node* __n = __STATIC_CAST(_Node*, __pos._M_node);
|
||||
__prev_node->_M_next = __next_node;
|
||||
__next_node->_M_prev = __prev_node;
|
||||
_STLP_STD::_Destroy(&__n->_M_data);
|
||||
this->_M_node.deallocate(__n, 1);
|
||||
return iterator(__next_node);
|
||||
}
|
||||
|
||||
iterator erase(iterator __first, iterator __last) {
|
||||
while (__first != __last)
|
||||
erase(__first++);
|
||||
return __last;
|
||||
}
|
||||
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
void resize(size_type __new_size, const_reference __x = value_type());
|
||||
#else
|
||||
void resize(size_type __new_size, const_reference __x);
|
||||
void resize(size_type __new_size)
|
||||
{ this->resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(value_type)); }
|
||||
#endif /*!_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
|
||||
void pop_front() { erase(begin()); }
|
||||
void pop_back() {
|
||||
iterator __tmp = end();
|
||||
erase(--__tmp);
|
||||
}
|
||||
|
||||
public:
|
||||
// assign(), a generalized assignment member function. Two
|
||||
// versions: one that takes a count, and one that takes a range.
|
||||
// The range version is a member template, so we dispatch on whether
|
||||
// or not the type is an integer.
|
||||
|
||||
void assign(size_type __n, const_reference __val) { _M_fill_assign(__n, __val); }
|
||||
|
||||
void _M_fill_assign(size_type __n, const_reference __val);
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void assign(_InputIterator __first, _InputIterator __last) {
|
||||
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
|
||||
_M_assign_dispatch(__first, __last, _Integral());
|
||||
}
|
||||
|
||||
template <class _Integer>
|
||||
void _M_assign_dispatch(_Integer __n, _Integer __val,
|
||||
const __true_type& /*_IsIntegral*/) {
|
||||
_M_fill_assign(__n, __val);
|
||||
}
|
||||
|
||||
template <class _InputIterator>
|
||||
void _M_assign_dispatch(_InputIterator __first2, _InputIterator __last2,
|
||||
const __false_type& /*_IsIntegral*/) {
|
||||
#else
|
||||
void assign(const value_type *__first2, const value_type *__last2) {
|
||||
iterator __first1 = begin();
|
||||
iterator __last1 = end();
|
||||
for ( ; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
|
||||
*__first1 = *__first2;
|
||||
if (__first2 == __last2)
|
||||
erase(__first1, __last1);
|
||||
else
|
||||
insert(__last1, __first2, __last2);
|
||||
}
|
||||
void assign(const_iterator __first2, const_iterator __last2) {
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
iterator __first1 = begin();
|
||||
iterator __last1 = end();
|
||||
for ( ; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
|
||||
*__first1 = *__first2;
|
||||
if (__first2 == __last2)
|
||||
erase(__first1, __last1);
|
||||
else
|
||||
insert(__last1, __first2, __last2);
|
||||
}
|
||||
|
||||
public:
|
||||
void splice(iterator __pos, _Self& __x) {
|
||||
if (!__x.empty()) {
|
||||
if (this->get_allocator() == __x.get_allocator()) {
|
||||
_STLP_PRIV _List_global_inst::_Transfer(__pos._M_node, __x.begin()._M_node, __x.end()._M_node);
|
||||
}
|
||||
else {
|
||||
insert(__pos, __x.begin(), __x.end());
|
||||
__x.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
void splice(iterator __pos, _Self& __x, iterator __i) {
|
||||
iterator __j = __i;
|
||||
++__j;
|
||||
if (__pos == __i || __pos == __j) return;
|
||||
if (this->get_allocator() == __x.get_allocator()) {
|
||||
_STLP_PRIV _List_global_inst::_Transfer(__pos._M_node, __i._M_node, __j._M_node);
|
||||
}
|
||||
else {
|
||||
insert(__pos, *__i);
|
||||
__x.erase(__i);
|
||||
}
|
||||
}
|
||||
void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) {
|
||||
if (__first != __last) {
|
||||
if (this->get_allocator() == __x.get_allocator()) {
|
||||
_STLP_PRIV _List_global_inst::_Transfer(__pos._M_node, __first._M_node, __last._M_node);
|
||||
}
|
||||
else {
|
||||
insert(__pos, __first, __last);
|
||||
__x.erase(__first, __last);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void remove(const_reference __val) {
|
||||
iterator __first = begin();
|
||||
iterator __last = end();
|
||||
while (__first != __last) {
|
||||
iterator __next = __first;
|
||||
++__next;
|
||||
if (__val == *__first) erase(__first);
|
||||
__first = __next;
|
||||
}
|
||||
}
|
||||
|
||||
void unique()
|
||||
{ _STLP_PRIV _S_unique(*this, equal_to<value_type>()); }
|
||||
|
||||
void merge(_Self& __x)
|
||||
{ _STLP_PRIV _S_merge(*this, __x, less<value_type>()); }
|
||||
|
||||
void reverse() {
|
||||
_Node_base* __p = &this->_M_node._M_data;
|
||||
_Node_base* __tmp = __p;
|
||||
do {
|
||||
_STLP_STD::swap(__tmp->_M_next, __tmp->_M_prev);
|
||||
__tmp = __tmp->_M_prev; // Old next node is now prev.
|
||||
} while (__tmp != __p);
|
||||
}
|
||||
|
||||
void sort()
|
||||
{ _STLP_PRIV _S_sort(*this, less<value_type>()); }
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _Predicate>
|
||||
void remove_if(_Predicate __pred)
|
||||
{ _STLP_PRIV _S_remove_if(*this, __pred); }
|
||||
template <class _BinaryPredicate>
|
||||
void unique(_BinaryPredicate __binary_pred)
|
||||
{ _STLP_PRIV _S_unique(*this, __binary_pred); }
|
||||
|
||||
template <class _StrictWeakOrdering>
|
||||
void merge(_Self& __x,
|
||||
_StrictWeakOrdering __comp) {
|
||||
_STLP_PRIV _S_merge(*this, __x, __comp);
|
||||
}
|
||||
|
||||
template <class _StrictWeakOrdering>
|
||||
void sort(_StrictWeakOrdering __comp)
|
||||
{ _STLP_PRIV _S_sort(*this, __comp); }
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
};
|
||||
|
||||
#if defined (list)
|
||||
# undef list
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_list.c>
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_USE_PTR_SPECIALIZATIONS)
|
||||
# include <stl/pointers/_list.h>
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_DEBUG)
|
||||
# include <stl/debug/_list.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
_STLP_INLINE_LOOP bool _STLP_CALL
|
||||
operator==(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y) {
|
||||
typedef typename list<_Tp,_Alloc>::const_iterator const_iterator;
|
||||
const_iterator __end1 = __x.end();
|
||||
const_iterator __end2 = __y.end();
|
||||
|
||||
const_iterator __i1 = __x.begin();
|
||||
const_iterator __i2 = __y.begin();
|
||||
while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) {
|
||||
++__i1;
|
||||
++__i2;
|
||||
}
|
||||
return __i1 == __end1 && __i2 == __end2;
|
||||
}
|
||||
|
||||
#define _STLP_EQUAL_OPERATOR_SPECIALIZED
|
||||
#define _STLP_TEMPLATE_HEADER template <class _Tp, class _Alloc>
|
||||
#define _STLP_TEMPLATE_CONTAINER list<_Tp, _Alloc>
|
||||
#include <stl/_relops_cont.h>
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#undef _STLP_TEMPLATE_HEADER
|
||||
#undef _STLP_EQUAL_OPERATOR_SPECIALIZED
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
template <class _Tp, class _Alloc>
|
||||
struct __move_traits<list<_Tp, _Alloc> > {
|
||||
typedef __true_type implemented;
|
||||
typedef typename __move_traits<_Alloc>::complete complete;
|
||||
};
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_LIST_IMPL_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
364
extern/STLport/5.2.1/stlport/stl/_locale.h
vendored
Normal file
364
extern/STLport/5.2.1/stlport/stl/_locale.h
vendored
Normal file
@@ -0,0 +1,364 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
// WARNING: This is an internal header file, included by other C++
|
||||
// standard library headers. You should not attempt to use this header
|
||||
// file directly.
|
||||
|
||||
|
||||
#ifndef _STLP_INTERNAL_LOCALE_H
|
||||
#define _STLP_INTERNAL_LOCALE_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSTDLIB
|
||||
# include <stl/_cstdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_CWCHAR
|
||||
# include <stl/_cwchar.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_THREADS_H
|
||||
# include <stl/_threads.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_STRING_FWD_H
|
||||
# include <stl/_string_fwd.h>
|
||||
#endif
|
||||
|
||||
#include <stl/_facets_fwd.h>
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
class _Locale_impl; // Forward declaration of opaque type.
|
||||
class locale;
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
bool __locale_do_operator_call(const locale& __loc,
|
||||
const basic_string<_CharT, _Traits, _Alloc>& __x,
|
||||
const basic_string<_CharT, _Traits, _Alloc>& __y);
|
||||
|
||||
_STLP_DECLSPEC _Locale_impl * _STLP_CALL _get_Locale_impl( _Locale_impl *locimpl );
|
||||
_STLP_DECLSPEC _Locale_impl * _STLP_CALL _copy_Nameless_Locale_impl( _Locale_impl *locimpl );
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Facet>
|
||||
bool _HasFacet(const locale& __loc, const _Facet* __facet) _STLP_NOTHROW;
|
||||
|
||||
template <class _Facet>
|
||||
_Facet* _UseFacet(const locale& __loc, const _Facet* __facet);
|
||||
|
||||
template <class _Facet>
|
||||
void _InsertFacet(locale& __loc, _Facet* __facet);
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \
|
||||
defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY)
|
||||
# define locale _STLP_NO_MEM_T_NAME(loc)
|
||||
#endif
|
||||
|
||||
class _STLP_CLASS_DECLSPEC locale {
|
||||
public:
|
||||
// types:
|
||||
class _STLP_CLASS_DECLSPEC facet : protected _Refcount_Base {
|
||||
protected:
|
||||
/* Here we filter __init_count user value to 0 or 1 because __init_count is a
|
||||
* size_t instance and _Refcount_Base use __stl_atomic_t instances that might
|
||||
* have lower sizeof and generate roll issues. 1 is enough to keep the facet
|
||||
* alive when required. */
|
||||
explicit facet(size_t __init_count = 0) : _Refcount_Base( __init_count == 0 ? 0 : 1 ) {}
|
||||
virtual ~facet();
|
||||
friend class locale;
|
||||
friend class _Locale_impl;
|
||||
friend facet * _STLP_CALL _get_facet( facet * );
|
||||
friend void _STLP_CALL _release_facet( facet *& );
|
||||
|
||||
private: // Invalidate assignment and copying.
|
||||
facet(const facet& ) /* : _Refcount_Base(1) {} */;
|
||||
void operator=(const facet&);
|
||||
};
|
||||
|
||||
#if defined (__MVS__) || defined (__OS400__)
|
||||
struct
|
||||
#else
|
||||
class
|
||||
#endif
|
||||
_STLP_CLASS_DECLSPEC id {
|
||||
public:
|
||||
size_t _M_index;
|
||||
static size_t _S_max;
|
||||
};
|
||||
|
||||
typedef int category;
|
||||
_STLP_STATIC_CONSTANT(category, none = 0x000);
|
||||
_STLP_STATIC_CONSTANT(category, collate = 0x010);
|
||||
_STLP_STATIC_CONSTANT(category, ctype = 0x020);
|
||||
_STLP_STATIC_CONSTANT(category, monetary = 0x040);
|
||||
_STLP_STATIC_CONSTANT(category, numeric = 0x100);
|
||||
_STLP_STATIC_CONSTANT(category, time = 0x200);
|
||||
_STLP_STATIC_CONSTANT(category, messages = 0x400);
|
||||
_STLP_STATIC_CONSTANT(category, all = collate | ctype | monetary | numeric | time | messages);
|
||||
|
||||
// construct/copy/destroy:
|
||||
locale() _STLP_NOTHROW;
|
||||
locale(const locale&) _STLP_NOTHROW;
|
||||
explicit locale(const char *);
|
||||
locale(const locale&, const char*, category);
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
|
||||
template <class _Facet>
|
||||
locale(const locale& __loc, _Facet* __f) {
|
||||
if ( __f != 0 ) {
|
||||
this->_M_impl = _get_Locale_impl( _copy_Nameless_Locale_impl( __loc._M_impl ) );
|
||||
_STLP_PRIV _InsertFacet(*this, __f);
|
||||
} else {
|
||||
this->_M_impl = _get_Locale_impl( __loc._M_impl );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// those are for internal use
|
||||
locale(_Locale_impl*);
|
||||
|
||||
public:
|
||||
locale(const locale&, const locale&, category);
|
||||
const locale& operator=(const locale&) _STLP_NOTHROW;
|
||||
|
||||
#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
|
||||
protected:
|
||||
#endif
|
||||
~locale() _STLP_NOTHROW;
|
||||
|
||||
public:
|
||||
#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS) && \
|
||||
!defined(_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
|
||||
template <class _Facet>
|
||||
locale combine(const locale& __loc) const {
|
||||
_Facet *__facet = 0;
|
||||
if (!_STLP_PRIV _HasFacet(__loc, __facet))
|
||||
_M_throw_on_combine_error(__loc.name());
|
||||
|
||||
return locale(*this, _STLP_PRIV _UseFacet(__loc, __facet));
|
||||
}
|
||||
#endif
|
||||
|
||||
// locale operations:
|
||||
string name() const;
|
||||
|
||||
bool operator==(const locale&) const;
|
||||
bool operator!=(const locale&) const;
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES) || defined (_STLP_INLINE_MEMBER_TEMPLATES) || (defined(__MWERKS__) && __MWERKS__ <= 0x2301)
|
||||
bool operator()(const string& __x, const string& __y) const;
|
||||
# ifndef _STLP_NO_WCHAR_T
|
||||
bool operator()(const wstring& __x, const wstring& __y) const;
|
||||
# endif
|
||||
#elif !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
bool operator()(const basic_string<_CharT, _Traits, _Alloc>& __x,
|
||||
const basic_string<_CharT, _Traits, _Alloc>& __y) const
|
||||
{ return __locale_do_operator_call(*this, __x, __y); }
|
||||
#endif
|
||||
|
||||
// global locale objects:
|
||||
#if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
|
||||
static locale _STLP_CALL global(const locale&);
|
||||
#else
|
||||
static _Locale_impl* _STLP_CALL global(const locale&);
|
||||
#endif
|
||||
static const locale& _STLP_CALL classic();
|
||||
|
||||
//protected: // Helper functions for locale globals.
|
||||
facet* _M_get_facet(const id&) const;
|
||||
// same, but throws
|
||||
facet* _M_use_facet(const id&) const;
|
||||
static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_on_combine_error(const string& name);
|
||||
static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_on_null_name();
|
||||
static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_on_creation_failure(int __err_code,
|
||||
const char* name, const char* facet);
|
||||
|
||||
//protected: // More helper functions.
|
||||
void _M_insert(facet* __f, id& __id);
|
||||
|
||||
// friends:
|
||||
friend class _Locale_impl;
|
||||
|
||||
protected: // Data members
|
||||
_Locale_impl* _M_impl;
|
||||
_Locale_impl* _M_get_impl() const { return _M_impl; }
|
||||
};
|
||||
|
||||
#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \
|
||||
defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY)
|
||||
# undef locale
|
||||
# define _Locale _STLP_NO_MEM_T_NAME(loc)
|
||||
|
||||
class locale : public _Locale {
|
||||
public:
|
||||
|
||||
// construct/copy/destroy:
|
||||
locale() _STLP_NOTHROW {
|
||||
#if defined (_STLP_CHECK_RUNTIME_COMPATIBILITY)
|
||||
_STLP_CHECK_RUNTIME_COMPATIBILITY();
|
||||
#endif
|
||||
}
|
||||
locale(const locale& __loc) _STLP_NOTHROW : _Locale(__loc) {}
|
||||
explicit locale(const char *__str) : _Locale(__str) {}
|
||||
locale(const locale& __loc, const char* __str, category __cat)
|
||||
: _Locale(__loc, __str, __cat) {}
|
||||
|
||||
template <class _Facet>
|
||||
locale(const locale& __loc, _Facet* __f)
|
||||
: _Locale(__f != 0 ? _copy_Nameless_Locale_impl(__loc._M_impl) : __loc._M_impl) {
|
||||
if ( __f != 0 ) {
|
||||
_STLP_PRIV _InsertFacet(*this, __f);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// those are for internal use
|
||||
locale(_Locale_impl* __impl) : _Locale(__impl) {}
|
||||
locale(const _Locale& __loc) : _Locale(__loc) {}
|
||||
|
||||
public:
|
||||
|
||||
locale(const locale& __loc1, const locale& __loc2, category __cat)
|
||||
: _Locale(__loc1, __loc2, __cat) {}
|
||||
|
||||
const locale& operator=(const locale& __loc) _STLP_NOTHROW {
|
||||
_Locale::operator=(__loc);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Facet>
|
||||
locale combine(const locale& __loc) const {
|
||||
_Facet *__facet = 0;
|
||||
if (!_STLP_PRIV _HasFacet(__loc, __facet))
|
||||
_M_throw_on_combine_error(__loc.name());
|
||||
|
||||
return locale(*this, _STLP_PRIV _UseFacet(__loc, __facet));
|
||||
}
|
||||
|
||||
// locale operations:
|
||||
bool operator==(const locale& __loc) const { return _Locale::operator==(__loc); }
|
||||
bool operator!=(const locale& __loc) const { return _Locale::operator!=(__loc); }
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
bool operator()(const basic_string<_CharT, _Traits, _Alloc>& __x,
|
||||
const basic_string<_CharT, _Traits, _Alloc>& __y) const
|
||||
{ return __locale_do_operator_call(*this, __x, __y); }
|
||||
|
||||
// global locale objects:
|
||||
static locale _STLP_CALL global(const locale& __loc) {
|
||||
return _Locale::global(__loc);
|
||||
}
|
||||
static const locale& _STLP_CALL classic() {
|
||||
return __STATIC_CAST(const locale&, _Locale::classic());
|
||||
}
|
||||
|
||||
// friends:
|
||||
friend class _Locale_impl;
|
||||
};
|
||||
|
||||
# undef _Locale
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// locale globals
|
||||
|
||||
template <class _Facet>
|
||||
inline const _Facet&
|
||||
#ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
|
||||
_Use_facet<_Facet>::operator *() const
|
||||
#else
|
||||
use_facet(const locale& __loc)
|
||||
#endif
|
||||
{
|
||||
_Facet *__facet = 0;
|
||||
return *(_STLP_PRIV _UseFacet(__loc, __facet));
|
||||
}
|
||||
|
||||
template <class _Facet>
|
||||
#ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
|
||||
struct has_facet {
|
||||
const locale& __loc;
|
||||
has_facet(const locale& __p_loc) : __loc(__p_loc) {}
|
||||
operator bool() const _STLP_NOTHROW
|
||||
#else
|
||||
inline bool has_facet(const locale& __loc) _STLP_NOTHROW
|
||||
#endif
|
||||
{
|
||||
_Facet *__facet = 0;
|
||||
return _STLP_PRIV _HasFacet(__loc, __facet);
|
||||
}
|
||||
|
||||
#ifdef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS
|
||||
}; // close class definition
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
/* _GetFacetId is a helper function that allow delaying access to
|
||||
* facet id static instance in the library source code to avoid
|
||||
* the other static instances that many compilers are generating
|
||||
* in all dynamic library or executable when instanciating facet
|
||||
* template class.
|
||||
*/
|
||||
template <class _Facet>
|
||||
inline locale::id& _GetFacetId(const _Facet*)
|
||||
{ return _Facet::id; }
|
||||
|
||||
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_get<char, istreambuf_iterator<char, char_traits<char> > >*);
|
||||
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_put<char, ostreambuf_iterator<char, char_traits<char> > >*);
|
||||
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_get<char, istreambuf_iterator<char, char_traits<char> > >*);
|
||||
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_put<char, ostreambuf_iterator<char, char_traits<char> > >*);
|
||||
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_get<char, istreambuf_iterator<char, char_traits<char> > >*);
|
||||
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_put<char, ostreambuf_iterator<char, char_traits<char> > >*);
|
||||
|
||||
#ifndef _STLP_NO_WCHAR_T
|
||||
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >*);
|
||||
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >*);
|
||||
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >*);
|
||||
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >*);
|
||||
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >*);
|
||||
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >*);
|
||||
#endif
|
||||
|
||||
template <class _Facet>
|
||||
inline bool _HasFacet(const locale& __loc, const _Facet* __facet) _STLP_NOTHROW
|
||||
{ return (__loc._M_get_facet(_GetFacetId(__facet)) != 0); }
|
||||
|
||||
template <class _Facet>
|
||||
inline _Facet* _UseFacet(const locale& __loc, const _Facet* __facet)
|
||||
{ return __STATIC_CAST(_Facet*, __loc._M_use_facet(_GetFacetId(__facet))); }
|
||||
|
||||
template <class _Facet>
|
||||
inline void _InsertFacet(locale& __loc, _Facet* __facet)
|
||||
{ __loc._M_insert(__facet, _GetFacetId(__facet)); }
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_LOCALE_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
435
extern/STLport/5.2.1/stlport/stl/_map.h
vendored
Normal file
435
extern/STLport/5.2.1/stlport/stl/_map.h
vendored
Normal file
@@ -0,0 +1,435 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_MAP_H
|
||||
#define _STLP_INTERNAL_MAP_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_TREE_H
|
||||
# include <stl/_tree.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
//Specific iterator traits creation
|
||||
_STLP_CREATE_ITERATOR_TRAITS(MapTraitsT, traits)
|
||||
|
||||
template <class _Key, class _Tp, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key> ),
|
||||
_STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) >
|
||||
class map
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
||||
: public __stlport_class<map<_Key, _Tp, _Compare, _Alloc> >
|
||||
#endif
|
||||
{
|
||||
typedef map<_Key, _Tp, _Compare, _Alloc> _Self;
|
||||
public:
|
||||
|
||||
// typedefs:
|
||||
|
||||
typedef _Key key_type;
|
||||
typedef _Tp data_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<_STLP_CONST _Key, _Tp> value_type;
|
||||
typedef _Compare key_compare;
|
||||
|
||||
class value_compare
|
||||
: public binary_function<value_type, value_type, bool> {
|
||||
friend class map<_Key,_Tp,_Compare,_Alloc>;
|
||||
protected :
|
||||
//c is a Standard name (23.3.1), do no make it STLport naming convention compliant.
|
||||
_Compare comp;
|
||||
value_compare(_Compare __c) : comp(__c) {}
|
||||
public:
|
||||
bool operator()(const value_type& __x, const value_type& __y) const
|
||||
{ return comp(__x.first, __y.first); }
|
||||
};
|
||||
|
||||
protected:
|
||||
typedef _STLP_PRIV _MapTraitsT<value_type> _MapTraits;
|
||||
|
||||
public:
|
||||
//Following typedef have to be public for __move_traits specialization.
|
||||
typedef _STLP_PRIV _Rb_tree<key_type, key_compare,
|
||||
value_type, _STLP_SELECT1ST(value_type, _Key),
|
||||
_MapTraits, _Alloc> _Rep_type;
|
||||
|
||||
typedef typename _Rep_type::pointer pointer;
|
||||
typedef typename _Rep_type::const_pointer const_pointer;
|
||||
typedef typename _Rep_type::reference reference;
|
||||
typedef typename _Rep_type::const_reference const_reference;
|
||||
typedef typename _Rep_type::iterator iterator;
|
||||
typedef typename _Rep_type::const_iterator const_iterator;
|
||||
typedef typename _Rep_type::reverse_iterator reverse_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename _Rep_type::size_type size_type;
|
||||
typedef typename _Rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::allocator_type allocator_type;
|
||||
|
||||
private:
|
||||
_Rep_type _M_t; // red-black tree representing map
|
||||
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
||||
|
||||
public:
|
||||
// allocation/deallocation
|
||||
map() : _M_t(_Compare(), allocator_type()) {}
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
explicit map(const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
#else
|
||||
explicit map(const _Compare& __comp)
|
||||
: _M_t(__comp, allocator_type()) {}
|
||||
explicit map(const _Compare& __comp, const allocator_type& __a)
|
||||
#endif
|
||||
: _M_t(__comp, __a) {}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
map(_InputIterator __first, _InputIterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
|
||||
template <class _InputIterator>
|
||||
map(_InputIterator __first, _InputIterator __last, const _Compare& __comp,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
||||
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
|
||||
|
||||
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
|
||||
template <class _InputIterator>
|
||||
map(_InputIterator __first, _InputIterator __last, const _Compare& __comp)
|
||||
: _M_t(__comp, allocator_type()) { _M_t.insert_unique(__first, __last); }
|
||||
# endif
|
||||
|
||||
#else
|
||||
map(const value_type* __first, const value_type* __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
|
||||
map(const value_type* __first,
|
||||
const value_type* __last, const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
|
||||
|
||||
map(const_iterator __first, const_iterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
|
||||
map(const_iterator __first, const_iterator __last, const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
map(const _Self& __x) : _M_t(__x._M_t) {}
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
map(__move_source<_Self> src)
|
||||
: _M_t(__move_source<_Rep_type>(src.get()._M_t)) {}
|
||||
#endif
|
||||
|
||||
_Self& operator=(const _Self& __x) {
|
||||
_M_t = __x._M_t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// accessors:
|
||||
key_compare key_comp() const { return _M_t.key_comp(); }
|
||||
value_compare value_comp() const { return value_compare(_M_t.key_comp()); }
|
||||
allocator_type get_allocator() const { return _M_t.get_allocator(); }
|
||||
|
||||
iterator begin() { return _M_t.begin(); }
|
||||
const_iterator begin() const { return _M_t.begin(); }
|
||||
iterator end() { return _M_t.end(); }
|
||||
const_iterator end() const { return _M_t.end(); }
|
||||
reverse_iterator rbegin() { return _M_t.rbegin(); }
|
||||
const_reverse_iterator rbegin() const { return _M_t.rbegin(); }
|
||||
reverse_iterator rend() { return _M_t.rend(); }
|
||||
const_reverse_iterator rend() const { return _M_t.rend(); }
|
||||
bool empty() const { return _M_t.empty(); }
|
||||
size_type size() const { return _M_t.size(); }
|
||||
size_type max_size() const { return _M_t.max_size(); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
_Tp& operator[](const _KT& __k) {
|
||||
iterator __i = lower_bound(__k);
|
||||
// __i->first is greater than or equivalent to __k.
|
||||
if (__i == end() || key_comp()(__k, (*__i).first))
|
||||
__i = insert(__i, value_type(__k, _STLP_DEFAULT_CONSTRUCTED(_Tp)));
|
||||
return (*__i).second;
|
||||
}
|
||||
void swap(_Self& __x) { _M_t.swap(__x._M_t); }
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(_Self& __x) { swap(__x); }
|
||||
#endif
|
||||
|
||||
// insert/erase
|
||||
pair<iterator,bool> insert(const value_type& __x)
|
||||
{ return _M_t.insert_unique(__x); }
|
||||
iterator insert(iterator __pos, const value_type& __x)
|
||||
{ return _M_t.insert_unique(__pos, __x); }
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __first, _InputIterator __last)
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
#else
|
||||
void insert(const value_type* __first, const value_type* __last)
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
void insert(const_iterator __first, const_iterator __last)
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
void erase(iterator __pos) { _M_t.erase(__pos); }
|
||||
size_type erase(const key_type& __x) { return _M_t.erase_unique(__x); }
|
||||
void erase(iterator __first, iterator __last) { _M_t.erase(__first, __last); }
|
||||
void clear() { _M_t.clear(); }
|
||||
|
||||
// map operations:
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator find(const _KT& __x) { return _M_t.find(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator find(const _KT& __x) const { return _M_t.find(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type count(const _KT& __x) const { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<iterator,iterator> equal_range(const _KT& __x)
|
||||
{ return _M_t.equal_range_unique(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<const_iterator,const_iterator> equal_range(const _KT& __x) const
|
||||
{ return _M_t.equal_range_unique(__x); }
|
||||
};
|
||||
|
||||
//Specific iterator traits creation
|
||||
_STLP_CREATE_ITERATOR_TRAITS(MultimapTraitsT, traits)
|
||||
|
||||
template <class _Key, class _Tp, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key> ),
|
||||
_STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) >
|
||||
class multimap
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
||||
: public __stlport_class<multimap<_Key, _Tp, _Compare, _Alloc> >
|
||||
#endif
|
||||
{
|
||||
typedef multimap<_Key, _Tp, _Compare, _Alloc> _Self;
|
||||
public:
|
||||
|
||||
// typedefs:
|
||||
|
||||
typedef _Key key_type;
|
||||
typedef _Tp data_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<_STLP_CONST _Key, _Tp> value_type;
|
||||
typedef _Compare key_compare;
|
||||
|
||||
class value_compare : public binary_function<value_type, value_type, bool> {
|
||||
friend class multimap<_Key,_Tp,_Compare,_Alloc>;
|
||||
protected:
|
||||
//comp is a Standard name (23.3.2), do no make it STLport naming convention compliant.
|
||||
_Compare comp;
|
||||
value_compare(_Compare __c) : comp(__c) {}
|
||||
public:
|
||||
bool operator()(const value_type& __x, const value_type& __y) const
|
||||
{ return comp(__x.first, __y.first); }
|
||||
};
|
||||
|
||||
protected:
|
||||
//Specific iterator traits creation
|
||||
typedef _STLP_PRIV _MultimapTraitsT<value_type> _MultimapTraits;
|
||||
|
||||
public:
|
||||
//Following typedef have to be public for __move_traits specialization.
|
||||
typedef _STLP_PRIV _Rb_tree<key_type, key_compare,
|
||||
value_type, _STLP_SELECT1ST(value_type, _Key),
|
||||
_MultimapTraits, _Alloc> _Rep_type;
|
||||
|
||||
typedef typename _Rep_type::pointer pointer;
|
||||
typedef typename _Rep_type::const_pointer const_pointer;
|
||||
typedef typename _Rep_type::reference reference;
|
||||
typedef typename _Rep_type::const_reference const_reference;
|
||||
typedef typename _Rep_type::iterator iterator;
|
||||
typedef typename _Rep_type::const_iterator const_iterator;
|
||||
typedef typename _Rep_type::reverse_iterator reverse_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename _Rep_type::size_type size_type;
|
||||
typedef typename _Rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::allocator_type allocator_type;
|
||||
|
||||
private:
|
||||
_Rep_type _M_t; // red-black tree representing multimap
|
||||
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
||||
|
||||
public:
|
||||
// allocation/deallocation
|
||||
multimap() : _M_t(_Compare(), allocator_type()) { }
|
||||
explicit multimap(const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { }
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
template <class _InputIterator>
|
||||
multimap(_InputIterator __first, _InputIterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
|
||||
template <class _InputIterator>
|
||||
multimap(_InputIterator __first, _InputIterator __last,
|
||||
const _Compare& __comp)
|
||||
: _M_t(__comp, allocator_type()) { _M_t.insert_equal(__first, __last); }
|
||||
# endif
|
||||
template <class _InputIterator>
|
||||
multimap(_InputIterator __first, _InputIterator __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
||||
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
||||
#else
|
||||
multimap(const value_type* __first, const value_type* __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
multimap(const value_type* __first, const value_type* __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
||||
|
||||
multimap(const_iterator __first, const_iterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
multimap(const_iterator __first, const_iterator __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
multimap(const _Self& __x) : _M_t(__x._M_t) {}
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
multimap(__move_source<_Self> src)
|
||||
: _M_t(__move_source<_Rep_type>(src.get()._M_t)) {}
|
||||
#endif
|
||||
|
||||
_Self& operator=(const _Self& __x) {
|
||||
_M_t = __x._M_t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// accessors:
|
||||
|
||||
key_compare key_comp() const { return _M_t.key_comp(); }
|
||||
value_compare value_comp() const { return value_compare(_M_t.key_comp()); }
|
||||
allocator_type get_allocator() const { return _M_t.get_allocator(); }
|
||||
|
||||
iterator begin() { return _M_t.begin(); }
|
||||
const_iterator begin() const { return _M_t.begin(); }
|
||||
iterator end() { return _M_t.end(); }
|
||||
const_iterator end() const { return _M_t.end(); }
|
||||
reverse_iterator rbegin() { return _M_t.rbegin(); }
|
||||
const_reverse_iterator rbegin() const { return _M_t.rbegin(); }
|
||||
reverse_iterator rend() { return _M_t.rend(); }
|
||||
const_reverse_iterator rend() const { return _M_t.rend(); }
|
||||
bool empty() const { return _M_t.empty(); }
|
||||
size_type size() const { return _M_t.size(); }
|
||||
size_type max_size() const { return _M_t.max_size(); }
|
||||
void swap(_Self& __x) { _M_t.swap(__x._M_t); }
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(_Self& __x) { swap(__x); }
|
||||
#endif
|
||||
|
||||
// insert/erase
|
||||
iterator insert(const value_type& __x) { return _M_t.insert_equal(__x); }
|
||||
iterator insert(iterator __pos, const value_type& __x) { return _M_t.insert_equal(__pos, __x); }
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __first, _InputIterator __last)
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
#else
|
||||
void insert(const value_type* __first, const value_type* __last)
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
void insert(const_iterator __first, const_iterator __last)
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
void erase(iterator __pos) { _M_t.erase(__pos); }
|
||||
size_type erase(const key_type& __x) { return _M_t.erase(__x); }
|
||||
void erase(iterator __first, iterator __last) { _M_t.erase(__first, __last); }
|
||||
void clear() { _M_t.clear(); }
|
||||
|
||||
// multimap operations:
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator find(const _KT& __x) { return _M_t.find(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator find(const _KT& __x) const { return _M_t.find(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type count(const _KT& __x) const { return _M_t.count(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<iterator,iterator> equal_range(const _KT& __x)
|
||||
{ return _M_t.equal_range(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<const_iterator,const_iterator> equal_range(const _KT& __x) const
|
||||
{ return _M_t.equal_range(__x); }
|
||||
};
|
||||
|
||||
#define _STLP_TEMPLATE_HEADER template <class _Key, class _Tp, class _Compare, class _Alloc>
|
||||
#define _STLP_TEMPLATE_CONTAINER map<_Key,_Tp,_Compare,_Alloc>
|
||||
#include <stl/_relops_cont.h>
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#define _STLP_TEMPLATE_CONTAINER multimap<_Key,_Tp,_Compare,_Alloc>
|
||||
#include <stl/_relops_cont.h>
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#undef _STLP_TEMPLATE_HEADER
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
template <class _Key, class _Tp, class _Compare, class _Alloc>
|
||||
struct __move_traits<map<_Key,_Tp,_Compare,_Alloc> > :
|
||||
_STLP_PRIV __move_traits_aux<typename map<_Key,_Tp,_Compare,_Alloc>::_Rep_type>
|
||||
{};
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Alloc>
|
||||
struct __move_traits<multimap<_Key,_Tp,_Compare,_Alloc> > :
|
||||
_STLP_PRIV __move_traits_aux<typename multimap<_Key,_Tp,_Compare,_Alloc>::_Rep_type>
|
||||
{};
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_MAP_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
41
extern/STLport/5.2.1/stlport/stl/_mbstate_t.h
vendored
Normal file
41
extern/STLport/5.2.1/stlport/stl/_mbstate_t.h
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_MBSTATE_T
|
||||
#define _STLP_INTERNAL_MBSTATE_T
|
||||
|
||||
#if (defined (__OpenBSD__) || defined (__FreeBSD__) || defined (__hpux)) && defined (__GNUC__) && !defined (_GLIBCPP_HAVE_MBSTATE_T)
|
||||
# define _STLP_CPP_MBSTATE_T /* mbstate_t defined in native <cwchar>, so not defined in C! */
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_NO_NATIVE_MBSTATE_T) || defined (_STLP_CPP_MBSTATE_T) && !defined (_MBSTATE_T)
|
||||
# define _STLP_USE_OWN_MBSTATE_T
|
||||
# define _MBSTATE_T
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_USE_OWN_MBSTATE_T)
|
||||
# if !defined (_STLP_CPP_MBSTATE_T) || !defined (__cplusplus) || !defined (_STLP_USE_NEW_C_HEADERS)
|
||||
typedef int mbstate_t;
|
||||
# endif
|
||||
|
||||
# if !defined (_STLP_CPP_MBSTATE_T) && defined (__cplusplus) && defined (_STLP_USE_NAMESPACES)
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
using ::mbstate_t;
|
||||
_STLP_END_NAMESPACE
|
||||
# endif
|
||||
|
||||
#endif /* _STLP_USE_OWN_MBSTATE_T */
|
||||
|
||||
#endif /* _STLP_INTERNAL_MBSTATE_T */
|
||||
185
extern/STLport/5.2.1/stlport/stl/_messages_facets.h
vendored
Normal file
185
extern/STLport/5.2.1/stlport/stl/_messages_facets.h
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
// WARNING: This is an internal header file, included by other C++
|
||||
// standard library headers. You should not attempt to use this header
|
||||
// file directly.
|
||||
|
||||
|
||||
#ifndef _STLP_INTERNAL_MESSAGES_H
|
||||
#define _STLP_INTERNAL_MESSAGES_H
|
||||
|
||||
#ifndef _STLP_IOS_BASE_H
|
||||
# include <stl/_ios_base.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_C_LOCALE_H
|
||||
# include <stl/c_locale.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_STRING_H
|
||||
# include <stl/_string.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
// messages facets
|
||||
|
||||
class messages_base {
|
||||
public:
|
||||
typedef int catalog;
|
||||
};
|
||||
|
||||
template <class _CharT> class messages {};
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
class _Messages;
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC messages<char> : public locale::facet, public messages_base {
|
||||
public:
|
||||
typedef messages_base::catalog catalog;
|
||||
typedef char char_type;
|
||||
typedef string string_type;
|
||||
|
||||
explicit messages(size_t __refs = 0);
|
||||
|
||||
catalog open(const string& __fn, const locale& __loc) const
|
||||
{ return do_open(__fn, __loc); }
|
||||
string_type get(catalog __c, int __set, int __msgid,
|
||||
const string_type& __dfault) const
|
||||
{ return do_get(__c, __set, __msgid, __dfault); }
|
||||
inline void close(catalog __c) const
|
||||
{ do_close(__c); }
|
||||
|
||||
static _STLP_STATIC_DECLSPEC locale::id id;
|
||||
|
||||
protected:
|
||||
~messages() {}
|
||||
|
||||
virtual catalog do_open(const string& __fn, const locale& __loc) const
|
||||
{ return -1; }
|
||||
virtual string_type do_get(catalog __c, int __set, int __msgid,
|
||||
const string_type& __dfault) const
|
||||
{ return __dfault; }
|
||||
virtual void do_close(catalog __c) const
|
||||
{}
|
||||
};
|
||||
|
||||
#if !defined (_STLP_NO_WCHAR_T)
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC messages<wchar_t> : public locale::facet, public messages_base {
|
||||
public:
|
||||
typedef messages_base::catalog catalog;
|
||||
typedef wchar_t char_type;
|
||||
typedef wstring string_type;
|
||||
|
||||
explicit messages(size_t __refs = 0);
|
||||
|
||||
inline catalog open(const string& __fn, const locale& __loc) const
|
||||
{ return do_open(__fn, __loc); }
|
||||
inline string_type get(catalog __c, int __set, int __msgid,
|
||||
const string_type& __dfault) const
|
||||
{ return do_get(__c, __set, __msgid, __dfault); }
|
||||
inline void close(catalog __c) const
|
||||
{ do_close(__c); }
|
||||
|
||||
static _STLP_STATIC_DECLSPEC locale::id id;
|
||||
|
||||
protected:
|
||||
~messages() {}
|
||||
|
||||
virtual catalog do_open(const string& __fn, const locale& __loc) const
|
||||
{ return -1; }
|
||||
virtual string_type do_get(catalog __c, int __set, int __msgid,
|
||||
const string_type& __dfault) const
|
||||
{ return __dfault; }
|
||||
virtual void do_close(catalog __c) const
|
||||
{}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template <class _CharT> class messages_byname {};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC messages_byname<char> : public messages<char> {
|
||||
friend class _Locale_impl;
|
||||
public:
|
||||
typedef messages_base::catalog catalog;
|
||||
typedef string string_type;
|
||||
|
||||
explicit messages_byname(const char* __name, size_t __refs = 0);
|
||||
|
||||
protected:
|
||||
~messages_byname();
|
||||
|
||||
virtual catalog do_open(const string& __fn, const locale& __loc) const;
|
||||
virtual string_type do_get(catalog __c, int __set, int __msgid,
|
||||
const string_type& __dfault) const;
|
||||
virtual void do_close(catalog __c) const;
|
||||
|
||||
private:
|
||||
messages_byname(_Locale_messages*);
|
||||
typedef messages_byname<char> _Self;
|
||||
//explicitely defined as private to avoid warnings:
|
||||
messages_byname(_Self const&);
|
||||
_Self& operator = (_Self const&);
|
||||
|
||||
_STLP_PRIV _Messages* _M_impl;
|
||||
};
|
||||
|
||||
#if !defined (_STLP_NO_WCHAR_T)
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC messages_byname<wchar_t> : public messages<wchar_t> {
|
||||
friend class _Locale_impl;
|
||||
public:
|
||||
typedef messages_base::catalog catalog;
|
||||
typedef wstring string_type;
|
||||
|
||||
explicit messages_byname(const char* __name, size_t __refs = 0);
|
||||
|
||||
protected:
|
||||
~messages_byname();
|
||||
|
||||
virtual catalog do_open(const string& __fn, const locale& __loc) const;
|
||||
virtual string_type do_get(catalog __c, int __set, int __msgid,
|
||||
const string_type& __dfault) const;
|
||||
virtual void do_close(catalog __c) const;
|
||||
|
||||
private:
|
||||
messages_byname(_Locale_messages*);
|
||||
typedef messages_byname<wchar_t> _Self;
|
||||
//explicitely defined as private to avoid warnings:
|
||||
messages_byname(_Self const&);
|
||||
_Self& operator = (_Self const&);
|
||||
|
||||
_STLP_PRIV _Messages* _M_impl;
|
||||
};
|
||||
#endif /* WCHAR_T */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_MESSAGES_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
527
extern/STLport/5.2.1/stlport/stl/_monetary.c
vendored
Normal file
527
extern/STLport/5.2.1/stlport/stl/_monetary.c
vendored
Normal file
@@ -0,0 +1,527 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_MONETARY_C
|
||||
#define _STLP_MONETARY_C
|
||||
|
||||
# ifndef _STLP_INTERNAL_MONETARY_H
|
||||
# include <stl/_monetary.h>
|
||||
# endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_IOS_H
|
||||
# include <stl/_ios.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_NUM_PUT_H
|
||||
# include <stl/_num_put.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_NUM_GET_H
|
||||
# include <stl/_num_get.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _CharT, class _InputIterator>
|
||||
locale::id money_get<_CharT, _InputIterator>::id;
|
||||
|
||||
template <class _CharT, class _OutputIterator>
|
||||
locale::id money_put<_CharT, _OutputIterator>::id;
|
||||
|
||||
// money_get facets
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
// helper functions for do_get
|
||||
template <class _InIt1, class _InIt2>
|
||||
pair<_InIt1, bool> __get_string( _InIt1 __first, _InIt1 __last,
|
||||
_InIt2 __str_first, _InIt2 __str_last) {
|
||||
while ( __first != __last && __str_first != __str_last && *__first == *__str_first ) {
|
||||
++__first;
|
||||
++__str_first;
|
||||
}
|
||||
return make_pair(__first, __str_first == __str_last);
|
||||
}
|
||||
|
||||
template <class _InIt, class _OuIt, class _CharT>
|
||||
bool
|
||||
__get_monetary_value(_InIt& __first, _InIt __last, _OuIt __out_ite,
|
||||
const ctype<_CharT>& _c_type,
|
||||
_CharT __point, int __frac_digits, _CharT __sep,
|
||||
const string& __grouping, bool &__syntax_ok) {
|
||||
if (__first == __last || !_c_type.is(ctype_base::digit, *__first))
|
||||
return false;
|
||||
|
||||
char __group_sizes[128];
|
||||
char* __group_sizes_end = __grouping.empty()? 0 : __group_sizes;
|
||||
char __current_group_size = 0;
|
||||
|
||||
while (__first != __last) {
|
||||
if (_c_type.is(ctype_base::digit, *__first)) {
|
||||
++__current_group_size;
|
||||
*__out_ite++ = *__first++;
|
||||
}
|
||||
else if (__group_sizes_end) {
|
||||
if (*__first == __sep) {
|
||||
*__group_sizes_end++ = __current_group_size;
|
||||
__current_group_size = 0;
|
||||
++__first;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (__grouping.empty())
|
||||
__syntax_ok = true;
|
||||
else {
|
||||
if (__group_sizes_end != __group_sizes)
|
||||
*__group_sizes_end++ = __current_group_size;
|
||||
|
||||
__syntax_ok = __valid_grouping(__group_sizes, __group_sizes_end,
|
||||
__grouping.data(), __grouping.data()+ __grouping.size());
|
||||
|
||||
if (__first == __last || *__first != __point) {
|
||||
for (int __digits = 0; __digits != __frac_digits; ++__digits)
|
||||
*__out_ite++ = _CharT('0');
|
||||
return true; // OK not to have decimal point
|
||||
}
|
||||
}
|
||||
|
||||
++__first;
|
||||
|
||||
int __digits = 0;
|
||||
|
||||
while (__first != __last && _c_type.is(ctype_base::digit, *__first)) {
|
||||
*__out_ite++ = *__first++;
|
||||
++__digits;
|
||||
}
|
||||
|
||||
__syntax_ok = __syntax_ok && (__digits == __frac_digits);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template <class _CharT, class _InputIter, class _StrType>
|
||||
_InputIter __money_do_get(_InputIter __s, _InputIter __end, bool __intl,
|
||||
ios_base& __str, ios_base::iostate& __err,
|
||||
_StrType& __digits, bool &__is_positive, _CharT* /*__dummy*/) {
|
||||
if (__s == __end) {
|
||||
__err |= ios_base::eofbit;
|
||||
return __s;
|
||||
}
|
||||
|
||||
typedef _CharT char_type;
|
||||
typedef _StrType string_type;
|
||||
typedef _InputIter iter_type;
|
||||
typedef moneypunct<char_type, false> _Punct;
|
||||
typedef moneypunct<char_type, true> _Punct_intl;
|
||||
typedef ctype<char_type> _Ctype;
|
||||
|
||||
locale __loc = __str.getloc();
|
||||
const _Punct& __punct = use_facet<_Punct>(__loc) ;
|
||||
const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ;
|
||||
const _Ctype& __c_type = use_facet<_Ctype>(__loc) ;
|
||||
|
||||
money_base::pattern __format = __intl ? __punct_intl.neg_format()
|
||||
: __punct.neg_format();
|
||||
string_type __ns = __intl ? __punct_intl.negative_sign()
|
||||
: __punct.negative_sign();
|
||||
string_type __ps = __intl ? __punct_intl.positive_sign()
|
||||
: __punct.positive_sign();
|
||||
int __i;
|
||||
bool __symbol_required = (__str.flags() & ios_base::showbase) != 0;
|
||||
string_type __buf;
|
||||
back_insert_iterator<string_type> __out_ite(__buf);
|
||||
|
||||
for (__i = 0; __i < 4; ++__i) {
|
||||
switch (__format.field[__i]) {
|
||||
case money_base::space:
|
||||
if (!__c_type.is(ctype_base::space, *__s)) {
|
||||
__err = ios_base::failbit;
|
||||
return __s;
|
||||
}
|
||||
++__s;
|
||||
case money_base::none:
|
||||
while (__s != __end && __c_type.is(ctype_base::space, *__s))
|
||||
++__s;
|
||||
break;
|
||||
case money_base::symbol: {
|
||||
string_type __curs = __intl ? __punct_intl.curr_symbol()
|
||||
: __punct.curr_symbol();
|
||||
pair<iter_type, bool>
|
||||
__result = __get_string(__s, __end, __curs.begin(), __curs.end());
|
||||
if (!__result.second && __symbol_required)
|
||||
__err = ios_base::failbit;
|
||||
__s = __result.first;
|
||||
break;
|
||||
}
|
||||
case money_base::sign: {
|
||||
if (__s == __end) {
|
||||
if (__ps.empty())
|
||||
break;
|
||||
if (__ns.empty()) {
|
||||
__is_positive = false;
|
||||
break;
|
||||
}
|
||||
__err = ios_base::failbit;
|
||||
return __s;
|
||||
}
|
||||
else {
|
||||
if (__ps.empty()) {
|
||||
if (__ns.empty())
|
||||
break;
|
||||
if (*__s == __ns[0]) {
|
||||
++__s;
|
||||
__is_positive = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if (*__s == __ps[0]) {
|
||||
++__s;
|
||||
break;
|
||||
}
|
||||
if (__ns.empty())
|
||||
break;
|
||||
if (*__s == __ns[0]) {
|
||||
++__s;
|
||||
__is_positive = false;
|
||||
break;
|
||||
}
|
||||
__err = ios_base::failbit;
|
||||
}
|
||||
}
|
||||
return __s;
|
||||
}
|
||||
case money_base::value: {
|
||||
char_type __point = __intl ? __punct_intl.decimal_point()
|
||||
: __punct.decimal_point();
|
||||
int __frac_digits = __intl ? __punct_intl.frac_digits()
|
||||
: __punct.frac_digits();
|
||||
string __grouping = __intl ? __punct_intl.grouping()
|
||||
: __punct.grouping();
|
||||
bool __syntax_ok = true;
|
||||
|
||||
bool __result;
|
||||
|
||||
char_type __sep = __grouping.empty() ? char_type() :
|
||||
__intl ? __punct_intl.thousands_sep() : __punct.thousands_sep();
|
||||
|
||||
__result = __get_monetary_value(__s, __end, __out_ite, __c_type,
|
||||
__point, __frac_digits,
|
||||
__sep,
|
||||
__grouping, __syntax_ok);
|
||||
|
||||
if (!__syntax_ok)
|
||||
__err |= ios_base::failbit;
|
||||
if (!__result) {
|
||||
__err = ios_base::failbit;
|
||||
return __s;
|
||||
}
|
||||
break;
|
||||
|
||||
} // Close money_base::value case
|
||||
} // Close switch statement
|
||||
} // Close for loop
|
||||
|
||||
if (__is_positive) {
|
||||
if (__ps.size() > 1) {
|
||||
pair<_InputIter, bool>
|
||||
__result = __get_string(__s, __end, __ps.begin() + 1, __ps.end());
|
||||
__s = __result.first;
|
||||
if (!__result.second)
|
||||
__err |= ios::failbit;
|
||||
}
|
||||
if (!(__err & ios_base::failbit))
|
||||
__digits = __buf;
|
||||
}
|
||||
else {
|
||||
if (__ns.size() > 1) {
|
||||
pair<_InputIter, bool>
|
||||
__result = __get_string(__s, __end, __ns.begin() + 1, __ns.end());
|
||||
__s = __result.first;
|
||||
if (!__result.second)
|
||||
__err |= ios::failbit;
|
||||
}
|
||||
if (!(__err & ios::failbit)) {
|
||||
__digits = __c_type.widen('-');
|
||||
__digits += __buf;
|
||||
}
|
||||
}
|
||||
if (__s == __end)
|
||||
__err |= ios::eofbit;
|
||||
|
||||
return __s;
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
//===== methods ======
|
||||
template <class _CharT, class _InputIter>
|
||||
_InputIter
|
||||
money_get<_CharT, _InputIter>::do_get(_InputIter __s, _InputIter __end, bool __intl,
|
||||
ios_base& __str, ios_base::iostate& __err,
|
||||
_STLP_LONGEST_FLOAT_TYPE& __units) const {
|
||||
string_type __buf;
|
||||
bool __is_positive = true;
|
||||
__s = _STLP_PRIV __money_do_get(__s, __end, __intl, __str, __err, __buf, __is_positive, (_CharT*)0);
|
||||
|
||||
if (__err == ios_base::goodbit || __err == ios_base::eofbit) {
|
||||
typename string_type::iterator __b = __buf.begin(), __e = __buf.end();
|
||||
|
||||
if (!__is_positive) ++__b;
|
||||
// Can't use atold, since it might be wchar_t. Don't get confused by name below :
|
||||
// it's perfectly capable of reading long double.
|
||||
_STLP_PRIV __get_decimal_integer(__b, __e, __units, (_CharT*)0);
|
||||
|
||||
if (!__is_positive) {
|
||||
__units = -__units;
|
||||
}
|
||||
}
|
||||
|
||||
return __s;
|
||||
}
|
||||
|
||||
template <class _CharT, class _InputIter>
|
||||
_InputIter
|
||||
money_get<_CharT, _InputIter>::do_get(iter_type __s, iter_type __end, bool __intl,
|
||||
ios_base& __str, ios_base::iostate& __err,
|
||||
string_type& __digits) const {
|
||||
bool __is_positive = true;
|
||||
return _STLP_PRIV __money_do_get(__s, __end, __intl, __str, __err, __digits, __is_positive, (_CharT*)0);
|
||||
}
|
||||
|
||||
// money_put facets
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _CharT, class _OutputIter, class _Str_Type, class _Str>
|
||||
_OutputIter __money_do_put(_OutputIter __s, bool __intl, ios_base& __str,
|
||||
_CharT __fill, const _Str& __digits, bool __check_digits,
|
||||
_Str_Type * /*__dummy*/) {
|
||||
typedef _CharT char_type;
|
||||
typedef _Str_Type string_type;
|
||||
typedef ctype<char_type> _Ctype;
|
||||
typedef moneypunct<char_type, false> _Punct;
|
||||
typedef moneypunct<char_type, true> _Punct_intl;
|
||||
|
||||
locale __loc = __str.getloc();
|
||||
const _Ctype& __c_type = use_facet<_Ctype>(__loc) ;
|
||||
const _Punct& __punct = use_facet<_Punct>(__loc) ;
|
||||
const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ;
|
||||
|
||||
// some special characters
|
||||
char_type __minus = __c_type.widen('-');
|
||||
char_type __plus = __c_type.widen('+');
|
||||
char_type __space = __c_type.widen(' ');
|
||||
char_type __zero = __c_type.widen('0');
|
||||
char_type __point = __intl ? __punct_intl.decimal_point()
|
||||
: __punct.decimal_point();
|
||||
|
||||
char_type __sep = __intl ? __punct_intl.thousands_sep()
|
||||
: __punct.thousands_sep();
|
||||
|
||||
string __grouping = __intl ? __punct_intl.grouping()
|
||||
: __punct.grouping();
|
||||
|
||||
int __frac_digits = __intl ? __punct_intl.frac_digits()
|
||||
: __punct.frac_digits();
|
||||
|
||||
string_type __curr_sym = __intl ? __punct_intl.curr_symbol()
|
||||
: __punct.curr_symbol();
|
||||
|
||||
// if there are no digits we are going to return __s. If there
|
||||
// are digits, but not enough to fill the frac_digits, we are
|
||||
// going to add zeros. I don't know whether this is right or
|
||||
// not.
|
||||
if (__digits.empty())
|
||||
return __s;
|
||||
|
||||
typename string_type::const_iterator __digits_first = __digits.begin();
|
||||
typename string_type::const_iterator __digits_last = __digits.end();
|
||||
|
||||
bool __is_negative = *__digits_first == __minus;
|
||||
if (__is_negative)
|
||||
++__digits_first;
|
||||
|
||||
#if !defined (__BORLANDC__)
|
||||
string_type __sign = __intl ? __is_negative ? __punct_intl.negative_sign()
|
||||
: __punct_intl.positive_sign()
|
||||
: __is_negative ? __punct.negative_sign()
|
||||
: __punct.positive_sign();
|
||||
#else
|
||||
string_type __sign;
|
||||
if (__intl) {
|
||||
if (__is_negative)
|
||||
__sign = __punct_intl.negative_sign();
|
||||
else
|
||||
__sign = __punct_intl.positive_sign();
|
||||
}
|
||||
else {
|
||||
if (__is_negative)
|
||||
__sign = __punct.negative_sign();
|
||||
else
|
||||
__sign = __punct.positive_sign();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (__check_digits) {
|
||||
typename string_type::const_iterator __cp = __digits_first;
|
||||
while (__cp != __digits_last && __c_type.is(ctype_base::digit, *__cp))
|
||||
++__cp;
|
||||
if (__cp == __digits_first)
|
||||
return __s;
|
||||
__digits_last = __cp;
|
||||
}
|
||||
|
||||
// If grouping is required, we make a copy of __digits and
|
||||
// insert the grouping.
|
||||
_STLP_BASIC_IOSTRING(char_type) __new_digits;
|
||||
if (!__grouping.empty()) {
|
||||
__new_digits.assign(__digits_first, __digits_last);
|
||||
__insert_grouping(__new_digits,
|
||||
__new_digits.size() - __frac_digits,
|
||||
__grouping,
|
||||
__sep, __plus, __minus, 0);
|
||||
__digits_first = __new_digits.begin(); // <<--
|
||||
__digits_last = __new_digits.end(); // <<--
|
||||
}
|
||||
|
||||
// Determine the amount of padding required, if any.
|
||||
streamsize __width = __str.width();
|
||||
|
||||
#if defined (_STLP_DEBUG) && (defined(__HP_aCC) && (__HP_aCC <= 1))
|
||||
size_t __value_length = operator -(__digits_last, __digits_first);
|
||||
#else
|
||||
size_t __value_length = __digits_last - __digits_first;
|
||||
#endif
|
||||
|
||||
size_t __length = __value_length + __sign.size();
|
||||
|
||||
if (__frac_digits != 0)
|
||||
++__length;
|
||||
|
||||
bool __generate_curr = (__str.flags() & ios_base::showbase) !=0;
|
||||
if (__generate_curr)
|
||||
__length += __curr_sym.size();
|
||||
money_base::pattern __format = __intl ? (__is_negative ? __punct_intl.neg_format()
|
||||
: __punct_intl.pos_format())
|
||||
: (__is_negative ? __punct.neg_format()
|
||||
: __punct.pos_format());
|
||||
{
|
||||
//For the moment the following is commented for decoding reason.
|
||||
//No reason to add a space last if the money symbol do not have to be display
|
||||
//if (__format.field[3] == (char) money_base::symbol && !__generate_curr) {
|
||||
// if (__format.field[2] == (char) money_base::space) {
|
||||
// __format.field[2] = (char) money_base::none;
|
||||
// }
|
||||
//}
|
||||
//space can only be second or third and only once (22.2.6.3-1):
|
||||
if ((__format.field[1] == (char) money_base::space) ||
|
||||
(__format.field[2] == (char) money_base::space))
|
||||
++__length;
|
||||
}
|
||||
|
||||
const bool __need_fill = (((sizeof(streamsize) > sizeof(size_t)) && (__STATIC_CAST(streamsize, __length) < __width)) ||
|
||||
((sizeof(streamsize) <= sizeof(size_t)) && (__length < __STATIC_CAST(size_t, __width))));
|
||||
streamsize __fill_amt = __need_fill ? __width - __length : 0;
|
||||
|
||||
ios_base::fmtflags __fill_pos = __str.flags() & ios_base::adjustfield;
|
||||
|
||||
if (__fill_amt != 0 &&
|
||||
!(__fill_pos & (ios_base::left | ios_base::internal)))
|
||||
__s = _STLP_PRIV __fill_n(__s, __fill_amt, __fill);
|
||||
|
||||
for (int __i = 0; __i < 4; ++__i) {
|
||||
char __ffield = __format.field[__i];
|
||||
switch (__ffield) {
|
||||
case money_base::space:
|
||||
*__s++ = __space;
|
||||
case money_base::none:
|
||||
if (__fill_amt != 0 && __fill_pos == ios_base::internal)
|
||||
__s = _STLP_PRIV __fill_n(__s, __fill_amt, __fill);
|
||||
break;
|
||||
case money_base::symbol:
|
||||
if (__generate_curr)
|
||||
__s = _STLP_STD::copy(__curr_sym.begin(), __curr_sym.end(), __s);
|
||||
break;
|
||||
case money_base::sign:
|
||||
if (!__sign.empty())
|
||||
*__s++ = __sign[0];
|
||||
break;
|
||||
case money_base::value:
|
||||
if (__frac_digits == 0) {
|
||||
__s = _STLP_STD::copy(__digits_first, __digits_last, __s);
|
||||
} else {
|
||||
if ((int)__value_length <= __frac_digits) {
|
||||
// if we see '9' here, we should out 0.09
|
||||
*__s++ = __zero; // integer part is zero
|
||||
*__s++ = __point; // decimal point
|
||||
__s = _STLP_PRIV __fill_n(__s, __frac_digits - __value_length, __zero); // zeros
|
||||
__s = _STLP_STD::copy(__digits_first, __digits_last, __s); // digits
|
||||
} else {
|
||||
__s = _STLP_STD::copy(__digits_first, __digits_last - __frac_digits, __s);
|
||||
if (__frac_digits != 0) {
|
||||
*__s++ = __point;
|
||||
__s = _STLP_STD::copy(__digits_last - __frac_digits, __digits_last, __s);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
} //Close for switch
|
||||
} // Close for loop
|
||||
|
||||
// Ouput rest of sign if necessary.
|
||||
if (__sign.size() > 1)
|
||||
__s = _STLP_STD::copy(__sign.begin() + 1, __sign.end(), __s);
|
||||
if (__fill_amt != 0 &&
|
||||
!(__fill_pos & (ios_base::right | ios_base::internal)))
|
||||
__s = _STLP_PRIV __fill_n(__s, __fill_amt, __fill);
|
||||
|
||||
return __s;
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _CharT, class _OutputIter>
|
||||
_OutputIter
|
||||
money_put<_CharT, _OutputIter>
|
||||
::do_put(_OutputIter __s, bool __intl, ios_base& __str,
|
||||
char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const {
|
||||
_STLP_BASIC_IOSTRING(char_type) __digits;
|
||||
_STLP_PRIV __get_money_digits(__digits, __str, __units);
|
||||
return _STLP_PRIV __money_do_put(__s, __intl, __str, __fill, __digits, false, __STATIC_CAST(string_type*, 0));
|
||||
}
|
||||
|
||||
template <class _CharT, class _OutputIter>
|
||||
_OutputIter
|
||||
money_put<_CharT, _OutputIter>
|
||||
::do_put(_OutputIter __s, bool __intl, ios_base& __str,
|
||||
char_type __fill, const string_type& __digits) const {
|
||||
return _STLP_PRIV __money_do_put(__s, __intl, __str, __fill, __digits, true, __STATIC_CAST(string_type*, 0));
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_MONETARY_C */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
435
extern/STLport/5.2.1/stlport/stl/_monetary.h
vendored
Normal file
435
extern/STLport/5.2.1/stlport/stl/_monetary.h
vendored
Normal file
@@ -0,0 +1,435 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
// WARNING: This is an internal header file, included by other C++
|
||||
// standard library headers. You should not attempt to use this header
|
||||
// file directly.
|
||||
|
||||
|
||||
#ifndef _STLP_INTERNAL_MONETARY_H
|
||||
#define _STLP_INTERNAL_MONETARY_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
|
||||
# include <stl/_ostreambuf_iterator.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
|
||||
# include <stl/_istreambuf_iterator.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_FACETS_FWD_H
|
||||
# include <stl/_facets_fwd.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
class money_base {
|
||||
public:
|
||||
enum part {none, space, symbol, sign, value};
|
||||
struct pattern {
|
||||
char field[4];
|
||||
};
|
||||
};
|
||||
|
||||
// moneypunct facets: forward declaration
|
||||
template <class _charT, _STLP_DFL_NON_TYPE_PARAM(bool, _International, false) > class moneypunct {};
|
||||
|
||||
// money_get facets
|
||||
|
||||
template <class _CharT, class _InputIter>
|
||||
class money_get : public locale::facet {
|
||||
public:
|
||||
typedef _CharT char_type;
|
||||
typedef _InputIter iter_type;
|
||||
typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
|
||||
|
||||
explicit money_get(size_t __refs = 0) : locale::facet(__refs) {}
|
||||
iter_type get(iter_type __s, iter_type __end, bool __intl,
|
||||
ios_base& __str, ios_base::iostate& __err,
|
||||
_STLP_LONGEST_FLOAT_TYPE& __units) const
|
||||
{ return do_get(__s, __end, __intl, __str, __err, __units); }
|
||||
iter_type get(iter_type __s, iter_type __end, bool __intl,
|
||||
ios_base& __str, ios_base::iostate& __err,
|
||||
string_type& __digits) const
|
||||
{ return do_get(__s, __end, __intl, __str, __err, __digits); }
|
||||
|
||||
static locale::id id;
|
||||
|
||||
protected:
|
||||
~money_get() {}
|
||||
virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl,
|
||||
ios_base& __str, ios_base::iostate& __err,
|
||||
_STLP_LONGEST_FLOAT_TYPE& __units) const;
|
||||
virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl,
|
||||
ios_base& __str, ios_base::iostate& __err,
|
||||
string_type& __digits) const;
|
||||
};
|
||||
|
||||
|
||||
// moneypunct facets: definition of specializations
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC moneypunct<char, true> : public locale::facet, public money_base {
|
||||
public:
|
||||
typedef char char_type;
|
||||
typedef string string_type;
|
||||
explicit moneypunct _STLP_PSPEC2(char, true) (size_t __refs = 0);
|
||||
|
||||
char decimal_point() const { return do_decimal_point(); }
|
||||
char thousands_sep() const { return do_thousands_sep(); }
|
||||
string grouping() const { return do_grouping(); }
|
||||
string_type curr_symbol() const { return do_curr_symbol(); }
|
||||
string_type positive_sign() const { return do_positive_sign(); }
|
||||
string_type negative_sign() const { return do_negative_sign(); }
|
||||
int frac_digits() const { return do_frac_digits(); }
|
||||
pattern pos_format() const { return do_pos_format(); }
|
||||
pattern neg_format() const { return do_neg_format(); }
|
||||
|
||||
static _STLP_STATIC_DECLSPEC locale::id id;
|
||||
_STLP_STATIC_CONSTANT(bool, intl = true);
|
||||
|
||||
protected:
|
||||
pattern _M_pos_format;
|
||||
pattern _M_neg_format;
|
||||
|
||||
~moneypunct _STLP_PSPEC2(char, true) ();
|
||||
|
||||
virtual char do_decimal_point() const;
|
||||
virtual char do_thousands_sep() const;
|
||||
virtual string do_grouping() const;
|
||||
|
||||
virtual string do_curr_symbol() const;
|
||||
|
||||
virtual string do_positive_sign() const;
|
||||
virtual string do_negative_sign() const;
|
||||
virtual int do_frac_digits() const;
|
||||
virtual pattern do_pos_format() const;
|
||||
virtual pattern do_neg_format() const;
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC moneypunct<char, false> : public locale::facet, public money_base {
|
||||
public:
|
||||
typedef char char_type;
|
||||
typedef string string_type;
|
||||
|
||||
explicit moneypunct _STLP_PSPEC2(char, false) (size_t __refs = 0);
|
||||
|
||||
char decimal_point() const { return do_decimal_point(); }
|
||||
char thousands_sep() const { return do_thousands_sep(); }
|
||||
string grouping() const { return do_grouping(); }
|
||||
string_type curr_symbol() const { return do_curr_symbol(); }
|
||||
string_type positive_sign() const { return do_positive_sign(); }
|
||||
string_type negative_sign() const { return do_negative_sign(); }
|
||||
int frac_digits() const { return do_frac_digits(); }
|
||||
pattern pos_format() const { return do_pos_format(); }
|
||||
pattern neg_format() const { return do_neg_format(); }
|
||||
|
||||
static _STLP_STATIC_DECLSPEC locale::id id;
|
||||
_STLP_STATIC_CONSTANT(bool, intl = false);
|
||||
|
||||
protected:
|
||||
pattern _M_pos_format;
|
||||
pattern _M_neg_format;
|
||||
|
||||
~moneypunct _STLP_PSPEC2(char, false) ();
|
||||
|
||||
virtual char do_decimal_point() const;
|
||||
virtual char do_thousands_sep() const;
|
||||
virtual string do_grouping() const;
|
||||
|
||||
virtual string do_curr_symbol() const;
|
||||
|
||||
virtual string do_positive_sign() const;
|
||||
virtual string do_negative_sign() const;
|
||||
virtual int do_frac_digits() const;
|
||||
virtual pattern do_pos_format() const;
|
||||
virtual pattern do_neg_format() const;
|
||||
};
|
||||
|
||||
|
||||
#ifndef _STLP_NO_WCHAR_T
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, true> : public locale::facet, public money_base {
|
||||
public:
|
||||
typedef wchar_t char_type;
|
||||
typedef wstring string_type;
|
||||
explicit moneypunct _STLP_PSPEC2(wchar_t, true) (size_t __refs = 0);
|
||||
wchar_t decimal_point() const { return do_decimal_point(); }
|
||||
wchar_t thousands_sep() const { return do_thousands_sep(); }
|
||||
string grouping() const { return do_grouping(); }
|
||||
string_type curr_symbol() const { return do_curr_symbol(); }
|
||||
string_type positive_sign() const { return do_positive_sign(); }
|
||||
string_type negative_sign() const { return do_negative_sign(); }
|
||||
int frac_digits() const { return do_frac_digits(); }
|
||||
pattern pos_format() const { return do_pos_format(); }
|
||||
pattern neg_format() const { return do_neg_format(); }
|
||||
|
||||
static _STLP_STATIC_DECLSPEC locale::id id;
|
||||
_STLP_STATIC_CONSTANT(bool, intl = true);
|
||||
|
||||
protected:
|
||||
pattern _M_pos_format;
|
||||
pattern _M_neg_format;
|
||||
|
||||
~moneypunct _STLP_PSPEC2(wchar_t, true) ();
|
||||
|
||||
virtual wchar_t do_decimal_point() const;
|
||||
virtual wchar_t do_thousands_sep() const;
|
||||
virtual string do_grouping() const;
|
||||
|
||||
virtual string_type do_curr_symbol() const;
|
||||
|
||||
virtual string_type do_positive_sign() const;
|
||||
virtual string_type do_negative_sign() const;
|
||||
virtual int do_frac_digits() const;
|
||||
virtual pattern do_pos_format() const;
|
||||
virtual pattern do_neg_format() const;
|
||||
};
|
||||
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC moneypunct<wchar_t, false> : public locale::facet, public money_base {
|
||||
public:
|
||||
typedef wchar_t char_type;
|
||||
typedef wstring string_type;
|
||||
explicit moneypunct _STLP_PSPEC2(wchar_t, false) (size_t __refs = 0);
|
||||
wchar_t decimal_point() const { return do_decimal_point(); }
|
||||
wchar_t thousands_sep() const { return do_thousands_sep(); }
|
||||
string grouping() const { return do_grouping(); }
|
||||
string_type curr_symbol() const { return do_curr_symbol(); }
|
||||
string_type positive_sign() const { return do_positive_sign(); }
|
||||
string_type negative_sign() const { return do_negative_sign(); }
|
||||
int frac_digits() const { return do_frac_digits(); }
|
||||
pattern pos_format() const { return do_pos_format(); }
|
||||
pattern neg_format() const { return do_neg_format(); }
|
||||
|
||||
static _STLP_STATIC_DECLSPEC locale::id id;
|
||||
_STLP_STATIC_CONSTANT(bool, intl = false);
|
||||
|
||||
protected:
|
||||
pattern _M_pos_format;
|
||||
pattern _M_neg_format;
|
||||
|
||||
~moneypunct _STLP_PSPEC2(wchar_t, false) ();
|
||||
|
||||
virtual wchar_t do_decimal_point() const;
|
||||
virtual wchar_t do_thousands_sep() const;
|
||||
virtual string do_grouping() const;
|
||||
|
||||
virtual string_type do_curr_symbol() const;
|
||||
|
||||
virtual string_type do_positive_sign() const;
|
||||
virtual string_type do_negative_sign() const;
|
||||
virtual int do_frac_digits() const;
|
||||
virtual pattern do_pos_format() const;
|
||||
virtual pattern do_neg_format() const;
|
||||
};
|
||||
|
||||
# endif
|
||||
|
||||
template <class _charT, _STLP_DFL_NON_TYPE_PARAM(bool , _International , false) > class moneypunct_byname {};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC moneypunct_byname<char, true> : public moneypunct<char, true> {
|
||||
friend class _Locale_impl;
|
||||
public:
|
||||
typedef money_base::pattern pattern;
|
||||
typedef char char_type;
|
||||
typedef string string_type;
|
||||
|
||||
explicit moneypunct_byname _STLP_PSPEC2(char, true) (const char * __name, size_t __refs = 0);
|
||||
|
||||
protected:
|
||||
~moneypunct_byname _STLP_PSPEC2(char, true) ();
|
||||
virtual char do_decimal_point() const;
|
||||
virtual char do_thousands_sep() const;
|
||||
virtual string do_grouping() const;
|
||||
|
||||
virtual string_type do_curr_symbol() const;
|
||||
|
||||
virtual string_type do_positive_sign() const;
|
||||
virtual string_type do_negative_sign() const;
|
||||
virtual int do_frac_digits() const;
|
||||
|
||||
private:
|
||||
moneypunct_byname _STLP_PSPEC2(char, true) (_Locale_monetary *__monetary);
|
||||
|
||||
typedef moneypunct_byname<char, true> _Self;
|
||||
//explicitely defined as private to avoid warnings:
|
||||
moneypunct_byname(_Self const&);
|
||||
_Self& operator = (_Self const&);
|
||||
|
||||
_Locale_monetary* _M_monetary;
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC moneypunct_byname<char, false> : public moneypunct<char, false> {
|
||||
friend class _Locale_impl;
|
||||
public:
|
||||
typedef money_base::pattern pattern;
|
||||
typedef char char_type;
|
||||
typedef string string_type;
|
||||
|
||||
explicit moneypunct_byname _STLP_PSPEC2(char, false) (const char * __name, size_t __refs = 0);
|
||||
|
||||
protected:
|
||||
~moneypunct_byname _STLP_PSPEC2(char, false) ();
|
||||
virtual char do_decimal_point() const;
|
||||
virtual char do_thousands_sep() const;
|
||||
virtual string do_grouping() const;
|
||||
|
||||
virtual string_type do_curr_symbol() const;
|
||||
|
||||
virtual string_type do_positive_sign() const;
|
||||
virtual string_type do_negative_sign() const;
|
||||
virtual int do_frac_digits() const;
|
||||
|
||||
private:
|
||||
moneypunct_byname _STLP_PSPEC2(char, false) (_Locale_monetary *__monetary);
|
||||
|
||||
typedef moneypunct_byname<char, false> _Self;
|
||||
//explicitely defined as private to avoid warnings:
|
||||
moneypunct_byname(_Self const&);
|
||||
_Self& operator = (_Self const&);
|
||||
|
||||
_Locale_monetary* _M_monetary;
|
||||
};
|
||||
|
||||
#if !defined (_STLP_NO_WCHAR_T)
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, true> : public moneypunct<wchar_t, true> {
|
||||
friend class _Locale_impl;
|
||||
public:
|
||||
typedef money_base::pattern pattern;
|
||||
typedef wchar_t char_type;
|
||||
typedef wstring string_type;
|
||||
|
||||
explicit moneypunct_byname _STLP_PSPEC2(wchar_t, true) (const char * __name, size_t __refs = 0);
|
||||
|
||||
protected:
|
||||
~moneypunct_byname _STLP_PSPEC2(wchar_t, true) ();
|
||||
virtual wchar_t do_decimal_point() const;
|
||||
virtual wchar_t do_thousands_sep() const;
|
||||
virtual string do_grouping() const;
|
||||
|
||||
virtual string_type do_curr_symbol() const;
|
||||
|
||||
virtual string_type do_positive_sign() const;
|
||||
virtual string_type do_negative_sign() const;
|
||||
virtual int do_frac_digits() const;
|
||||
|
||||
private:
|
||||
moneypunct_byname _STLP_PSPEC2(wchar_t, true) (_Locale_monetary *__monetary);
|
||||
|
||||
typedef moneypunct_byname<wchar_t, true> _Self;
|
||||
//explicitely defined as private to avoid warnings:
|
||||
moneypunct_byname(_Self const&);
|
||||
_Self& operator = (_Self const&);
|
||||
|
||||
_Locale_monetary* _M_monetary;
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC moneypunct_byname<wchar_t, false> : public moneypunct<wchar_t, false> {
|
||||
friend class _Locale_impl;
|
||||
public:
|
||||
typedef money_base::pattern pattern;
|
||||
typedef wchar_t char_type;
|
||||
typedef wstring string_type;
|
||||
|
||||
explicit moneypunct_byname _STLP_PSPEC2(wchar_t, false) (const char * __name, size_t __refs = 0);
|
||||
|
||||
protected:
|
||||
~moneypunct_byname _STLP_PSPEC2(wchar_t, false) ();
|
||||
virtual wchar_t do_decimal_point() const;
|
||||
virtual wchar_t do_thousands_sep() const;
|
||||
virtual string do_grouping() const;
|
||||
|
||||
virtual string_type do_curr_symbol() const;
|
||||
|
||||
virtual string_type do_positive_sign() const;
|
||||
virtual string_type do_negative_sign() const;
|
||||
virtual int do_frac_digits() const;
|
||||
|
||||
private:
|
||||
moneypunct_byname _STLP_PSPEC2(wchar_t, false) (_Locale_monetary *__monetary);
|
||||
|
||||
typedef moneypunct_byname<wchar_t, false> _Self;
|
||||
//explicitely defined as private to avoid warnings:
|
||||
moneypunct_byname(_Self const&);
|
||||
_Self& operator = (_Self const&);
|
||||
|
||||
_Locale_monetary* _M_monetary;
|
||||
};
|
||||
#endif
|
||||
|
||||
//===== methods ======
|
||||
|
||||
|
||||
// money_put facets
|
||||
|
||||
template <class _CharT, class _OutputIter>
|
||||
class money_put : public locale::facet {
|
||||
public:
|
||||
typedef _CharT char_type;
|
||||
typedef _OutputIter iter_type;
|
||||
typedef basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > string_type;
|
||||
|
||||
explicit money_put(size_t __refs = 0) : locale::facet(__refs) {}
|
||||
iter_type put(iter_type __s, bool __intl, ios_base& __str,
|
||||
char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const
|
||||
{ return do_put(__s, __intl, __str, __fill, __units); }
|
||||
iter_type put(iter_type __s, bool __intl, ios_base& __str,
|
||||
char_type __fill,
|
||||
const string_type& __digits) const
|
||||
{ return do_put(__s, __intl, __str, __fill, __digits); }
|
||||
|
||||
static locale::id id;
|
||||
|
||||
protected:
|
||||
~money_put() {}
|
||||
virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __str,
|
||||
char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const;
|
||||
virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __str,
|
||||
char_type __fill,
|
||||
const string_type& __digits) const;
|
||||
};
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS money_get<char, istreambuf_iterator<char, char_traits<char> > >;
|
||||
_STLP_EXPORT_TEMPLATE_CLASS money_put<char, ostreambuf_iterator<char, char_traits<char> > >;
|
||||
# if ! defined (_STLP_NO_WCHAR_T)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
|
||||
_STLP_EXPORT_TEMPLATE_CLASS money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_monetary.c>
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_MONETARY_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
|
||||
159
extern/STLport/5.2.1/stlport/stl/_move_construct_fwk.h
vendored
Normal file
159
extern/STLport/5.2.1/stlport/stl/_move_construct_fwk.h
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2003
|
||||
* Francois Dumont
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_MOVE_CONSTRUCT_FWK_H
|
||||
#define _STLP_MOVE_CONSTRUCT_FWK_H
|
||||
|
||||
#ifndef _STLP_TYPE_TRAITS_H
|
||||
# include <stl/type_traits.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
/*************************************************************
|
||||
* Move constructor framework
|
||||
*************************************************************/
|
||||
|
||||
/*************************************************************
|
||||
*Partial move:
|
||||
*The source HAS to be a valid instance after the move!
|
||||
*************************************************************/
|
||||
template <class _Tp>
|
||||
class __move_source {
|
||||
public:
|
||||
explicit __move_source (_Tp &_src) : _M_data(_src)
|
||||
{}
|
||||
|
||||
_Tp& get() const
|
||||
{ return _M_data; }
|
||||
private:
|
||||
_Tp &_M_data;
|
||||
|
||||
//We explicitely forbid assignment to avoid warning:
|
||||
typedef __move_source<_Tp> _Self;
|
||||
_Self& operator = (_Self const&);
|
||||
};
|
||||
|
||||
//Class used to signal move constructor support, implementation and type.
|
||||
template <class _Tp>
|
||||
struct __move_traits {
|
||||
/*
|
||||
* implemented tells if a the special move constructor has to be called or the classic
|
||||
* copy constructor is just fine. Most of the time the copy constructor is fine only
|
||||
* if the following info is true.
|
||||
*/
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && \
|
||||
!defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && \
|
||||
!defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
typedef typename _IsSTLportClass<_Tp>::_Ret implemented;
|
||||
#else
|
||||
typedef __false_type implemented;
|
||||
#endif
|
||||
/*
|
||||
* complete tells if the move is complete or partial, that is to say, does the source
|
||||
* needs to be destroyed once it has been moved.
|
||||
*/
|
||||
# if defined (__BORLANDC__) && (__BORLANDC__ >= 0x564)
|
||||
typedef __type_traits<_Tp>::has_trivial_destructor _TpMoveComplete;
|
||||
typedef typename __bool2type<__type2bool<_TpMoveComplete>::_Ret>::_Ret complete;
|
||||
# else
|
||||
typedef typename __type_traits<_Tp>::has_trivial_destructor complete;
|
||||
# endif
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
/*
|
||||
* This struct should never be used if the user has not explicitely stipulated
|
||||
* that its class support the full move concept. To check that the return type
|
||||
* in such a case will be __invalid_source<_Tp> to generate a compile error
|
||||
* revealing the configuration problem.
|
||||
*/
|
||||
template <class _Tp>
|
||||
struct _MoveSourceTraits {
|
||||
typedef typename __move_traits<_Tp>::implemented _MvImpRet;
|
||||
#if defined (__BORLANDC__)
|
||||
typedef typename __selectT<_MvImpRet,
|
||||
#else
|
||||
enum {_MvImp = __type2bool<_MvImpRet>::_Ret};
|
||||
typedef typename __select<_MvImp,
|
||||
#endif
|
||||
__move_source<_Tp>,
|
||||
_Tp const&>::_Ret _Type;
|
||||
};
|
||||
|
||||
//The helper function
|
||||
template <class _Tp>
|
||||
inline _STLP_TYPENAME_ON_RETURN_TYPE _MoveSourceTraits<_Tp>::_Type
|
||||
_AsMoveSource (_Tp &src) {
|
||||
typedef typename _MoveSourceTraits<_Tp>::_Type _SrcType;
|
||||
return _SrcType(src);
|
||||
}
|
||||
|
||||
//Helper structs used for many class.
|
||||
template <class _Tp>
|
||||
struct __move_traits_aux {
|
||||
typedef typename __move_traits<_Tp>::implemented implemented;
|
||||
typedef typename __move_traits<_Tp>::complete complete;
|
||||
};
|
||||
|
||||
template <class _Tp1, class _Tp2>
|
||||
struct __move_traits_aux2 {
|
||||
typedef __move_traits<_Tp1> _MoveTraits1;
|
||||
typedef __move_traits<_Tp2> _MoveTraits2;
|
||||
|
||||
typedef typename _Lor2<typename _MoveTraits1::implemented,
|
||||
typename _MoveTraits2::implemented>::_Ret implemented;
|
||||
typedef typename _Land2<typename _MoveTraits1::complete,
|
||||
typename _MoveTraits2::complete>::_Ret complete;
|
||||
};
|
||||
|
||||
/*
|
||||
* Most of the time a class implement a move constructor but its use depends
|
||||
* on a third party, this is what the following struct are for.
|
||||
*/
|
||||
template <class _Tp>
|
||||
struct __move_traits_help {
|
||||
typedef __true_type implemented;
|
||||
typedef typename __move_traits<_Tp>::complete complete;
|
||||
};
|
||||
|
||||
template <class _Tp1, class _Tp2>
|
||||
struct __move_traits_help1 {
|
||||
typedef __move_traits<_Tp1> _MoveTraits1;
|
||||
typedef __move_traits<_Tp2> _MoveTraits2;
|
||||
|
||||
typedef typename _Lor2<typename _MoveTraits1::implemented,
|
||||
typename _MoveTraits2::implemented>::_Ret implemented;
|
||||
typedef typename _Land2<typename _MoveTraits1::complete,
|
||||
typename _MoveTraits2::complete>::_Ret complete;
|
||||
};
|
||||
|
||||
template <class _Tp1, class _Tp2>
|
||||
struct __move_traits_help2 {
|
||||
typedef __move_traits<_Tp1> _MoveTraits1;
|
||||
typedef __move_traits<_Tp2> _MoveTraits2;
|
||||
|
||||
typedef __true_type implemented;
|
||||
typedef typename _Land2<typename _MoveTraits1::complete,
|
||||
typename _MoveTraits2::complete>::_Ret complete;
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_MOVE_CONSTRUCT_FWK_H */
|
||||
145
extern/STLport/5.2.1/stlport/stl/_new.h
vendored
Normal file
145
extern/STLport/5.2.1/stlport/stl/_new.h
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_NEW
|
||||
#define _STLP_INTERNAL_NEW
|
||||
|
||||
#ifndef _STLP_INTERNAL_CSTDDEF
|
||||
// size_t
|
||||
# include <stl/_cstddef.h>
|
||||
#endif
|
||||
|
||||
#if defined (__BORLANDC__) && (__BORLANDC__ < 0x570)
|
||||
// new.h uses ::malloc ;(
|
||||
# include _STLP_NATIVE_CPP_C_HEADER(cstdlib)
|
||||
using _STLP_VENDOR_CSTD::malloc;
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_NO_NEW_NEW_HEADER)
|
||||
// eMbedded Visual C++ .NET unfortunately uses _INC_NEW for both <new.h> and <new>
|
||||
// we undefine the symbol to get the stuff in the SDK's <new>
|
||||
# if defined (_STLP_WCE_NET) && defined (_INC_NEW)
|
||||
# undef _INC_NEW
|
||||
# endif
|
||||
|
||||
# if defined (new)
|
||||
/* STLport cannot replace native Std library new header if new is a macro,
|
||||
* please define new macro after <new> header inclusion.
|
||||
*/
|
||||
# error Cannot include native new header as new is a macro.
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_HAS_INCLUDE_NEXT)
|
||||
# include_next <new>
|
||||
# else
|
||||
# include _STLP_NATIVE_CPP_RUNTIME_HEADER(new)
|
||||
# endif
|
||||
#else
|
||||
# include <new.h>
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_NO_BAD_ALLOC) && !defined (_STLP_NEW_DONT_THROW_BAD_ALLOC)
|
||||
# define _STLP_NEW_DONT_THROW_BAD_ALLOC 1
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_USE_EXCEPTIONS) && defined (_STLP_NEW_DONT_THROW_BAD_ALLOC)
|
||||
|
||||
# ifndef _STLP_INTERNAL_EXCEPTION
|
||||
# include <stl/_exception.h>
|
||||
# endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
# if defined (_STLP_NO_BAD_ALLOC)
|
||||
struct nothrow_t {};
|
||||
# define nothrow nothrow_t()
|
||||
# endif
|
||||
|
||||
/*
|
||||
* STLport own bad_alloc exception to be used if the native C++ library
|
||||
* do not define it or when the new operator do not throw it to avoid
|
||||
* a useless library dependency.
|
||||
*/
|
||||
class bad_alloc : public exception {
|
||||
public:
|
||||
bad_alloc () _STLP_NOTHROW_INHERENTLY { }
|
||||
bad_alloc(const bad_alloc&) _STLP_NOTHROW_INHERENTLY { }
|
||||
bad_alloc& operator=(const bad_alloc&) _STLP_NOTHROW_INHERENTLY {return *this;}
|
||||
~bad_alloc () _STLP_NOTHROW_INHERENTLY { }
|
||||
const char* what() const _STLP_NOTHROW_INHERENTLY { return "bad alloc"; }
|
||||
};
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_USE_EXCEPTIONS && (_STLP_NO_BAD_ALLOC || _STLP_NEW_DONT_THROW_BAD_ALLOC) */
|
||||
|
||||
#if defined (_STLP_USE_OWN_NAMESPACE)
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
# if !defined (_STLP_NEW_DONT_THROW_BAD_ALLOC)
|
||||
using _STLP_VENDOR_EXCEPT_STD::bad_alloc;
|
||||
# endif
|
||||
|
||||
# if !defined (_STLP_NO_BAD_ALLOC)
|
||||
using _STLP_VENDOR_EXCEPT_STD::nothrow_t;
|
||||
using _STLP_VENDOR_EXCEPT_STD::nothrow;
|
||||
# if defined (_STLP_GLOBAL_NEW_HANDLER)
|
||||
using ::new_handler;
|
||||
using ::set_new_handler;
|
||||
# else
|
||||
using _STLP_VENDOR_EXCEPT_STD::new_handler;
|
||||
using _STLP_VENDOR_EXCEPT_STD::set_new_handler;
|
||||
# endif
|
||||
# endif /* !_STLP_NO_BAD_ALLOC */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
#endif /* _STLP_USE_OWN_NAMESPACE */
|
||||
|
||||
#ifndef _STLP_THROW_BAD_ALLOC
|
||||
# if !defined (_STLP_USE_EXCEPTIONS)
|
||||
# ifndef _STLP_INTERNAL_CSTDIO
|
||||
# include <stl/_cstdio.h>
|
||||
# endif
|
||||
# define _STLP_THROW_BAD_ALLOC puts("out of memory\n"); exit(1)
|
||||
# else
|
||||
# define _STLP_THROW_BAD_ALLOC _STLP_THROW(_STLP_STD::bad_alloc())
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_NO_NEW_NEW_HEADER) || defined (_STLP_NEW_DONT_THROW_BAD_ALLOC)
|
||||
# define _STLP_CHECK_NULL_ALLOC(__x) void* __y = __x; if (__y == 0) { _STLP_THROW_BAD_ALLOC; } return __y
|
||||
#else
|
||||
# define _STLP_CHECK_NULL_ALLOC(__x) return __x
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#if ((defined (__IBMCPP__) || defined (__OS400__) || defined (__xlC__) || defined (qTidyHeap)) && defined (_STLP_DEBUG_ALLOC))
|
||||
inline void* _STLP_CALL __stl_new(size_t __n) { _STLP_CHECK_NULL_ALLOC(::operator new(__n, __FILE__, __LINE__)); }
|
||||
inline void _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p, __FILE__, __LINE__); }
|
||||
#else
|
||||
inline void* _STLP_CALL __stl_new(size_t __n) { _STLP_CHECK_NULL_ALLOC(::operator new(__n)); }
|
||||
inline void _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p); }
|
||||
#endif
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_NEW */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode:C++
|
||||
* End:
|
||||
*/
|
||||
623
extern/STLport/5.2.1/stlport/stl/_num_get.c
vendored
Normal file
623
extern/STLport/5.2.1/stlport/stl/_num_get.c
vendored
Normal file
@@ -0,0 +1,623 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_NUM_GET_C
|
||||
#define _STLP_NUM_GET_C
|
||||
|
||||
#ifndef _STLP_INTERNAL_NUM_GET_H
|
||||
# include <stl/_num_get.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_LIMITS
|
||||
# include <stl/_limits.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
_STLP_DECLSPEC unsigned char _STLP_CALL __digit_val_table(unsigned);
|
||||
_STLP_DECLSPEC const char* _STLP_CALL __narrow_atoms();
|
||||
|
||||
// __do_get_integer, __do_get_float and its helper functions.
|
||||
|
||||
inline bool _STLP_CALL __get_fdigit(char __c, const char*)
|
||||
{ return __c >= '0' && __c <= '9'; }
|
||||
|
||||
inline bool _STLP_CALL __get_fdigit_or_sep(char& __c, char __sep, const char *__digits) {
|
||||
if (__c == __sep) {
|
||||
__c = ',' ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return __get_fdigit(__c, __digits);
|
||||
}
|
||||
|
||||
inline int _STLP_CALL
|
||||
__get_digit_from_table(unsigned __index)
|
||||
{ return (__index > 127 ? 0xFF : __digit_val_table(__index)); }
|
||||
|
||||
template <class _InputIter, class _CharT>
|
||||
int
|
||||
__get_base_or_zero(_InputIter& __in_ite, _InputIter& __end,
|
||||
ios_base::fmtflags __flags, const ctype<_CharT>& __c_type) {
|
||||
_CharT __atoms[5];
|
||||
__c_type.widen(__narrow_atoms(), __narrow_atoms() + 5, __atoms);
|
||||
|
||||
bool __negative = false;
|
||||
_CharT __c = *__in_ite;
|
||||
|
||||
if (__c == __atoms[1] /* __xminus_char */ ) {
|
||||
__negative = true;
|
||||
++__in_ite;
|
||||
}
|
||||
else if (__c == __atoms[0] /* __xplus_char */ )
|
||||
++__in_ite;
|
||||
|
||||
int __base;
|
||||
int __valid_zero = 0;
|
||||
|
||||
ios_base::fmtflags __basefield = __flags & ios_base::basefield;
|
||||
|
||||
switch (__basefield) {
|
||||
case ios_base::oct:
|
||||
__base = 8;
|
||||
break;
|
||||
case ios_base::dec:
|
||||
__base = 10;
|
||||
break;
|
||||
case ios_base::hex:
|
||||
__base = 16;
|
||||
if (__in_ite != __end && *__in_ite == __atoms[2] /* __zero_char */ ) {
|
||||
++__in_ite;
|
||||
if (__in_ite != __end &&
|
||||
(*__in_ite == __atoms[3] /* __x_char */ || *__in_ite == __atoms[4] /* __X_char */ ))
|
||||
++__in_ite;
|
||||
else
|
||||
__valid_zero = 1; // That zero is valid by itself.
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (__in_ite != __end && *__in_ite == __atoms[2] /* __zero_char */ ) {
|
||||
++__in_ite;
|
||||
if (__in_ite != __end &&
|
||||
(*__in_ite == __atoms[3] /* __x_char */ || *__in_ite == __atoms[4] /* __X_char */ )) {
|
||||
++__in_ite;
|
||||
__base = 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
__base = 8;
|
||||
__valid_zero = 1; // That zero is still valid by itself.
|
||||
}
|
||||
}
|
||||
else
|
||||
__base = 10;
|
||||
break;
|
||||
}
|
||||
return (__base << 2) | ((int)__negative << 1) | __valid_zero;
|
||||
}
|
||||
|
||||
|
||||
template <class _InputIter, class _Integer, class _CharT>
|
||||
bool _STLP_CALL
|
||||
__get_integer(_InputIter& __first, _InputIter& __last,
|
||||
int __base, _Integer& __val,
|
||||
int __got, bool __is_negative, _CharT __separator, const string& __grouping, const __true_type& /*_IsSigned*/) {
|
||||
bool __ovflow = false;
|
||||
_Integer __result = 0;
|
||||
bool __is_group = !__grouping.empty();
|
||||
char __group_sizes[64];
|
||||
char __current_group_size = 0;
|
||||
char* __group_sizes_end = __group_sizes;
|
||||
|
||||
_Integer __over_base = (numeric_limits<_Integer>::min)() / __STATIC_CAST(_Integer, __base);
|
||||
|
||||
for ( ; __first != __last ; ++__first) {
|
||||
|
||||
const _CharT __c = *__first;
|
||||
|
||||
if (__is_group && __c == __separator) {
|
||||
*__group_sizes_end++ = __current_group_size;
|
||||
__current_group_size = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
int __n = __get_digit_from_table(__c);
|
||||
|
||||
if (__n >= __base)
|
||||
break;
|
||||
|
||||
++__got;
|
||||
++__current_group_size;
|
||||
|
||||
if (__result < __over_base)
|
||||
__ovflow = true; // don't need to keep accumulating
|
||||
else {
|
||||
_Integer __next = __STATIC_CAST(_Integer, __base * __result - __n);
|
||||
if (__result != 0)
|
||||
__ovflow = __ovflow || __next >= __result;
|
||||
__result = __next;
|
||||
}
|
||||
}
|
||||
|
||||
if (__is_group && __group_sizes_end != __group_sizes) {
|
||||
*__group_sizes_end++ = __current_group_size;
|
||||
}
|
||||
|
||||
// fbp : added to not modify value if nothing was read
|
||||
if (__got > 0) {
|
||||
__val = __ovflow ? __is_negative ? (numeric_limits<_Integer>::min)()
|
||||
: (numeric_limits<_Integer>::max)()
|
||||
: __is_negative ? __result
|
||||
: __STATIC_CAST(_Integer, -__result);
|
||||
}
|
||||
// overflow is being treated as failure
|
||||
return ((__got > 0) && !__ovflow) &&
|
||||
(__is_group == 0 ||
|
||||
__valid_grouping(__group_sizes, __group_sizes_end,
|
||||
__grouping.data(), __grouping.data()+ __grouping.size()));
|
||||
}
|
||||
|
||||
template <class _InputIter, class _Integer, class _CharT>
|
||||
bool _STLP_CALL
|
||||
__get_integer(_InputIter& __first, _InputIter& __last,
|
||||
int __base, _Integer& __val,
|
||||
int __got, bool __is_negative, _CharT __separator, const string& __grouping, const __false_type& /*_IsSigned*/) {
|
||||
bool __ovflow = false;
|
||||
_Integer __result = 0;
|
||||
bool __is_group = !__grouping.empty();
|
||||
char __group_sizes[64];
|
||||
char __current_group_size = 0;
|
||||
char* __group_sizes_end = __group_sizes;
|
||||
|
||||
_Integer __over_base = (numeric_limits<_Integer>::max)() / __STATIC_CAST(_Integer, __base);
|
||||
|
||||
for ( ; __first != __last ; ++__first) {
|
||||
|
||||
const _CharT __c = *__first;
|
||||
|
||||
if (__is_group && __c == __separator) {
|
||||
*__group_sizes_end++ = __current_group_size;
|
||||
__current_group_size = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
int __n = __get_digit_from_table(__c);
|
||||
|
||||
if (__n >= __base)
|
||||
break;
|
||||
|
||||
++__got;
|
||||
++__current_group_size;
|
||||
|
||||
if (__result > __over_base)
|
||||
__ovflow = true; //don't need to keep accumulating
|
||||
else {
|
||||
_Integer __next = __STATIC_CAST(_Integer, __base * __result + __n);
|
||||
if (__result != 0)
|
||||
__ovflow = __ovflow || __next <= __result;
|
||||
__result = __next;
|
||||
}
|
||||
}
|
||||
|
||||
if (__is_group && __group_sizes_end != __group_sizes) {
|
||||
*__group_sizes_end++ = __current_group_size;
|
||||
}
|
||||
|
||||
// fbp : added to not modify value if nothing was read
|
||||
if (__got > 0) {
|
||||
__val = __ovflow ? (numeric_limits<_Integer>::max)()
|
||||
: (__is_negative ? __STATIC_CAST(_Integer, -__result)
|
||||
: __result);
|
||||
}
|
||||
|
||||
// overflow is being treated as failure
|
||||
return ((__got > 0) && !__ovflow) &&
|
||||
(__is_group == 0 ||
|
||||
__valid_grouping(__group_sizes, __group_sizes_end,
|
||||
__grouping.data(), __grouping.data()+ __grouping.size()));
|
||||
}
|
||||
|
||||
|
||||
template <class _InputIter, class _Integer, class _CharT>
|
||||
bool _STLP_CALL
|
||||
__get_decimal_integer(_InputIter& __first, _InputIter& __last, _Integer& __val, _CharT* /*dummy*/) {
|
||||
string __grp;
|
||||
//Here there is no grouping so separator is not important, we just pass the default character.
|
||||
return __get_integer(__first, __last, 10, __val, 0, false, _CharT() /*separator*/, __grp, __false_type());
|
||||
}
|
||||
|
||||
template <class _InputIter, class _Integer, class _CharT>
|
||||
_InputIter _STLP_CALL
|
||||
__do_get_integer(_InputIter& __in_ite, _InputIter& __end, ios_base& __str,
|
||||
ios_base::iostate& __err, _Integer& __val, _CharT* /*__pc*/) {
|
||||
locale __loc = __str.getloc();
|
||||
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
|
||||
|
||||
#if defined (__HP_aCC) && (__HP_aCC == 1)
|
||||
bool _IsSigned = !((_Integer)(-1) > 0);
|
||||
#else
|
||||
typedef typename __bool2type<numeric_limits<_Integer>::is_signed>::_Ret _IsSigned;
|
||||
#endif
|
||||
|
||||
const int __base_or_zero = __get_base_or_zero(__in_ite, __end, __str.flags(), __ctype);
|
||||
int __got = __base_or_zero & 1;
|
||||
|
||||
bool __result;
|
||||
|
||||
if (__in_ite == __end) { // We may have already read a 0. If so,
|
||||
|
||||
if (__got > 0) { // the result is 0 even if we're at eof.
|
||||
__val = 0;
|
||||
__result = true;
|
||||
}
|
||||
else
|
||||
__result = false;
|
||||
}
|
||||
else {
|
||||
const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
|
||||
const bool __negative = (__base_or_zero & 2) != 0;
|
||||
const int __base = __base_or_zero >> 2;
|
||||
|
||||
#if defined (__HP_aCC) && (__HP_aCC == 1)
|
||||
if (_IsSigned)
|
||||
__result = __get_integer(__in_ite, __end, __base, __val, __got, __negative, __np.thousands_sep(), __np.grouping(), __true_type() );
|
||||
else
|
||||
__result = __get_integer(__in_ite, __end, __base, __val, __got, __negative, __np.thousands_sep(), __np.grouping(), __false_type() );
|
||||
#else
|
||||
__result = __get_integer(__in_ite, __end, __base, __val, __got, __negative, __np.thousands_sep(), __np.grouping(), _IsSigned());
|
||||
# endif
|
||||
}
|
||||
|
||||
__err = __STATIC_CAST(ios_base::iostate, __result ? ios_base::goodbit : ios_base::failbit);
|
||||
|
||||
if (__in_ite == __end)
|
||||
__err |= ios_base::eofbit;
|
||||
return __in_ite;
|
||||
}
|
||||
|
||||
// __read_float and its helper functions.
|
||||
template <class _InputIter, class _CharT>
|
||||
_InputIter _STLP_CALL
|
||||
__copy_sign(_InputIter __first, _InputIter __last, __iostring& __v,
|
||||
_CharT __xplus, _CharT __xminus) {
|
||||
if (__first != __last) {
|
||||
_CharT __c = *__first;
|
||||
if (__c == __xplus)
|
||||
++__first;
|
||||
else if (__c == __xminus) {
|
||||
__v.push_back('-');
|
||||
++__first;
|
||||
}
|
||||
}
|
||||
return __first;
|
||||
}
|
||||
|
||||
|
||||
template <class _InputIter, class _CharT>
|
||||
bool _STLP_CALL
|
||||
__copy_digits(_InputIter& __first, _InputIter __last,
|
||||
__iostring& __v, const _CharT* __digits) {
|
||||
bool __ok = false;
|
||||
|
||||
for ( ; __first != __last; ++__first) {
|
||||
_CharT __c = *__first;
|
||||
if (__get_fdigit(__c, __digits)) {
|
||||
__v.push_back((char)__c);
|
||||
__ok = true;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return __ok;
|
||||
}
|
||||
|
||||
template <class _InputIter, class _CharT>
|
||||
bool _STLP_CALL
|
||||
__copy_grouped_digits(_InputIter& __first, _InputIter __last,
|
||||
__iostring& __v, const _CharT * __digits,
|
||||
_CharT __sep, const string& __grouping,
|
||||
bool& __grouping_ok) {
|
||||
bool __ok = false;
|
||||
char __group_sizes[64];
|
||||
char*__group_sizes_end = __group_sizes;
|
||||
char __current_group_size = 0;
|
||||
|
||||
for ( ; __first != __last; ++__first) {
|
||||
_CharT __c = *__first;
|
||||
bool __tmp = __get_fdigit_or_sep(__c, __sep, __digits);
|
||||
if (__tmp) {
|
||||
if (__c == ',') {
|
||||
*__group_sizes_end++ = __current_group_size;
|
||||
__current_group_size = 0;
|
||||
}
|
||||
else {
|
||||
__ok = true;
|
||||
__v.push_back((char)__c);
|
||||
++__current_group_size;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (__group_sizes_end != __group_sizes)
|
||||
*__group_sizes_end++ = __current_group_size;
|
||||
__grouping_ok = __valid_grouping(__group_sizes, __group_sizes_end, __grouping.data(), __grouping.data() + __grouping.size());
|
||||
return __ok;
|
||||
}
|
||||
|
||||
|
||||
template <class _InputIter, class _CharT>
|
||||
bool _STLP_CALL
|
||||
__read_float(__iostring& __buf, _InputIter& __in_ite, _InputIter& __end,
|
||||
const ctype<_CharT> &__ct, const numpunct<_CharT> &__numpunct) {
|
||||
// Create a string, copying characters of the form
|
||||
// [+-]? [0-9]* .? [0-9]* ([eE] [+-]? [0-9]+)?
|
||||
|
||||
string __grouping = __numpunct.grouping();
|
||||
bool __digits_before_dot /* = false */;
|
||||
bool __digits_after_dot = false;
|
||||
bool __ok;
|
||||
|
||||
bool __grouping_ok = true;
|
||||
|
||||
_CharT __dot = __numpunct.decimal_point();
|
||||
_CharT __sep = __numpunct.thousands_sep();
|
||||
|
||||
_CharT __digits[10];
|
||||
_CharT __xplus;
|
||||
_CharT __xminus;
|
||||
|
||||
_CharT __pow_e;
|
||||
_CharT __pow_E;
|
||||
|
||||
_Initialize_get_float(__ct, __xplus, __xminus, __pow_e, __pow_E, __digits);
|
||||
|
||||
// Get an optional sign
|
||||
__in_ite = __copy_sign(__in_ite, __end, __buf, __xplus, __xminus);
|
||||
|
||||
// Get an optional string of digits.
|
||||
if (!__grouping.empty())
|
||||
__digits_before_dot = __copy_grouped_digits(__in_ite, __end, __buf, __digits,
|
||||
__sep, __grouping, __grouping_ok);
|
||||
else
|
||||
__digits_before_dot = __copy_digits(__in_ite, __end, __buf, __digits);
|
||||
|
||||
// Get an optional decimal point, and an optional string of digits.
|
||||
if (__in_ite != __end && *__in_ite == __dot) {
|
||||
__buf.push_back('.');
|
||||
++__in_ite;
|
||||
__digits_after_dot = __copy_digits(__in_ite, __end, __buf, __digits);
|
||||
}
|
||||
|
||||
// There have to be some digits, somewhere.
|
||||
__ok = __digits_before_dot || __digits_after_dot;
|
||||
|
||||
// Get an optional exponent.
|
||||
if (__ok && __in_ite != __end && (*__in_ite == __pow_e || *__in_ite == __pow_E)) {
|
||||
__buf.push_back('e');
|
||||
++__in_ite;
|
||||
__in_ite = __copy_sign(__in_ite, __end, __buf, __xplus, __xminus);
|
||||
__ok = __copy_digits(__in_ite, __end, __buf, __digits);
|
||||
// If we have an exponent then the sign
|
||||
// is optional but the digits aren't.
|
||||
}
|
||||
|
||||
return __ok;
|
||||
}
|
||||
|
||||
template <class _InputIter, class _Float, class _CharT>
|
||||
_InputIter _STLP_CALL
|
||||
__do_get_float(_InputIter& __in_ite, _InputIter& __end, ios_base& __str,
|
||||
ios_base::iostate& __err, _Float& __val, _CharT* /*__pc*/) {
|
||||
locale __loc = __str.getloc();
|
||||
const ctype<_CharT> &__ctype = use_facet<ctype<_CharT> >(__loc);
|
||||
const numpunct<_CharT> &__numpunct = use_facet<numpunct<_CharT> >(__loc);
|
||||
|
||||
__iostring __buf ;
|
||||
bool __ok = __read_float(__buf, __in_ite, __end, __ctype, __numpunct);
|
||||
if (__ok) {
|
||||
__string_to_float(__buf, __val);
|
||||
__err = ios_base::goodbit;
|
||||
}
|
||||
else {
|
||||
__err = ios_base::failbit;
|
||||
}
|
||||
if (__in_ite == __end)
|
||||
__err |= ios_base::eofbit;
|
||||
return __in_ite;
|
||||
}
|
||||
|
||||
template <class _InputIter, class _CharT>
|
||||
_InputIter _STLP_CALL
|
||||
__do_get_alphabool(_InputIter& __in_ite, _InputIter& __end, ios_base& __str,
|
||||
ios_base::iostate& __err, bool& __x, _CharT* /*__pc*/) {
|
||||
const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__str.getloc());
|
||||
const basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > __truename = __np.truename();
|
||||
const basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > __falsename = __np.falsename();
|
||||
bool __true_ok = true;
|
||||
bool __false_ok = true;
|
||||
|
||||
size_t __n = 0;
|
||||
for ( ; __in_ite != __end; ++__in_ite) {
|
||||
_CharT __c = *__in_ite;
|
||||
__true_ok = __true_ok && (__c == __truename[__n]);
|
||||
__false_ok = __false_ok && (__c == __falsename[__n]);
|
||||
++__n;
|
||||
|
||||
if ((!__true_ok && !__false_ok) ||
|
||||
(__true_ok && __n >= __truename.size()) ||
|
||||
(__false_ok && __n >= __falsename.size())) {
|
||||
++__in_ite;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (__true_ok && __n < __truename.size()) __true_ok = false;
|
||||
if (__false_ok && __n < __falsename.size()) __false_ok = false;
|
||||
|
||||
if (__true_ok || __false_ok) {
|
||||
__err = ios_base::goodbit;
|
||||
__x = __true_ok;
|
||||
}
|
||||
else
|
||||
__err = ios_base::failbit;
|
||||
|
||||
if (__in_ite == __end)
|
||||
__err |= ios_base::eofbit;
|
||||
|
||||
return __in_ite;
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
//
|
||||
// num_get<>, num_put<>
|
||||
//
|
||||
|
||||
template <class _CharT, class _InputIterator>
|
||||
locale::id num_get<_CharT, _InputIterator>::id;
|
||||
|
||||
#if !defined (_STLP_NO_BOOL)
|
||||
template <class _CharT, class _InputIter>
|
||||
_InputIter
|
||||
num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end,
|
||||
ios_base& __s, ios_base::iostate& __err, bool& __x) const {
|
||||
if (__s.flags() & ios_base::boolalpha) {
|
||||
return _STLP_PRIV __do_get_alphabool(__in_ite, __end, __s, __err, __x, (_CharT*)0);
|
||||
}
|
||||
else {
|
||||
long __lx;
|
||||
_InputIter __tmp = _STLP_PRIV __do_get_integer(__in_ite, __end, __s, __err, __lx, (_CharT*)0 );
|
||||
if (!(__err & ios_base::failbit)) {
|
||||
if (__lx == 0)
|
||||
__x = false;
|
||||
else if (__lx == 1)
|
||||
__x = true;
|
||||
else
|
||||
__err |= ios_base::failbit;
|
||||
}
|
||||
return __tmp;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_FIX_LIBRARY_ISSUES)
|
||||
template <class _CharT, class _InputIter>
|
||||
_InputIter
|
||||
num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, short& __val) const
|
||||
{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
|
||||
|
||||
template <class _CharT, class _InputIter>
|
||||
_InputIter
|
||||
num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, int& __val) const
|
||||
{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
|
||||
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _InputIter>
|
||||
_InputIter
|
||||
num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, long& __val) const
|
||||
{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
|
||||
|
||||
template <class _CharT, class _InputIter>
|
||||
_InputIter
|
||||
num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err,
|
||||
unsigned short& __val) const
|
||||
{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
|
||||
|
||||
template <class _CharT, class _InputIter>
|
||||
_InputIter
|
||||
num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err,
|
||||
unsigned int& __val) const
|
||||
{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
|
||||
|
||||
template <class _CharT, class _InputIter>
|
||||
_InputIter
|
||||
num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err,
|
||||
unsigned long& __val) const
|
||||
{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
|
||||
|
||||
template <class _CharT, class _InputIter>
|
||||
_InputIter
|
||||
num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err,
|
||||
float& __val) const
|
||||
{ return _STLP_PRIV __do_get_float(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
|
||||
|
||||
template <class _CharT, class _InputIter>
|
||||
_InputIter
|
||||
num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err,
|
||||
double& __val) const
|
||||
{ return _STLP_PRIV __do_get_float(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
|
||||
|
||||
#if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
template <class _CharT, class _InputIter>
|
||||
_InputIter
|
||||
num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err,
|
||||
long double& __val) const
|
||||
{ return _STLP_PRIV __do_get_float(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _InputIter>
|
||||
_InputIter
|
||||
num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err,
|
||||
void*& __p) const {
|
||||
#if defined (_STLP_LONG_LONG) && !defined (__MRC__) //*ty 12/07/2001 - MrCpp can not cast from long long to void*
|
||||
unsigned _STLP_LONG_LONG __val;
|
||||
#else
|
||||
unsigned long __val;
|
||||
#endif
|
||||
iter_type __tmp = _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 );
|
||||
if (!(__err & ios_base::failbit))
|
||||
__p = __REINTERPRET_CAST(void*, __val);
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
#if defined (_STLP_LONG_LONG)
|
||||
template <class _CharT, class _InputIter>
|
||||
_InputIter
|
||||
num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err,
|
||||
_STLP_LONG_LONG& __val) const
|
||||
{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
|
||||
|
||||
template <class _CharT, class _InputIter>
|
||||
_InputIter
|
||||
num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err,
|
||||
unsigned _STLP_LONG_LONG& __val) const
|
||||
{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_NUMERIC_FACETS_C */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
237
extern/STLport/5.2.1/stlport/stl/_num_get.h
vendored
Normal file
237
extern/STLport/5.2.1/stlport/stl/_num_get.h
vendored
Normal file
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
// WARNING: This is an internal header file, included by other C++
|
||||
// standard library headers. You should not attempt to use this header
|
||||
// file directly.
|
||||
|
||||
|
||||
#ifndef _STLP_INTERNAL_NUM_GET_H
|
||||
#define _STLP_INTERNAL_NUM_GET_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
|
||||
# include <stl/_istreambuf_iterator.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_C_LOCALE_H
|
||||
# include <stl/c_locale.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_NUMPUNCT_H
|
||||
# include <stl/_numpunct.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_CTYPE_H
|
||||
# include <stl/_ctype.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_IOSTREAM_STRING_H
|
||||
# include <stl/_iostream_string.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_FACETS_FWD_H
|
||||
# include <stl/_facets_fwd.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// num_get facets
|
||||
|
||||
template <class _CharT, class _InputIter>
|
||||
class num_get: public locale::facet {
|
||||
public:
|
||||
typedef _CharT char_type;
|
||||
typedef _InputIter iter_type;
|
||||
|
||||
explicit num_get(size_t __refs = 0): locale::facet(__refs) {}
|
||||
|
||||
#if !defined (_STLP_NO_BOOL)
|
||||
_InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, bool& __val) const
|
||||
{ return do_get(__ii, __end, __str, __err, __val); }
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_FIX_LIBRARY_ISSUES)
|
||||
_InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, short& __val) const
|
||||
{ return do_get(__ii, __end, __str, __err, __val); }
|
||||
|
||||
_InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, int& __val) const
|
||||
{ return do_get(__ii, __end, __str, __err, __val); }
|
||||
#endif
|
||||
|
||||
_InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, long& __val) const
|
||||
{ return do_get(__ii, __end, __str, __err, __val); }
|
||||
|
||||
_InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, unsigned short& __val) const
|
||||
{ return do_get(__ii, __end, __str, __err, __val); }
|
||||
|
||||
_InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, unsigned int& __val) const
|
||||
{ return do_get(__ii, __end, __str, __err, __val); }
|
||||
|
||||
_InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, unsigned long& __val) const
|
||||
{ return do_get(__ii, __end, __str, __err, __val); }
|
||||
|
||||
#if defined (_STLP_LONG_LONG)
|
||||
_InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, _STLP_LONG_LONG& __val) const
|
||||
{ return do_get(__ii, __end, __str, __err, __val); }
|
||||
|
||||
_InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, unsigned _STLP_LONG_LONG& __val) const
|
||||
{ return do_get(__ii, __end, __str, __err, __val); }
|
||||
#endif /* _STLP_LONG_LONG */
|
||||
|
||||
_InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, float& __val) const
|
||||
{ return do_get(__ii, __end, __str, __err, __val); }
|
||||
|
||||
_InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, double& __val) const
|
||||
{ return do_get(__ii, __end, __str, __err, __val); }
|
||||
|
||||
#if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
_InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, long double& __val) const
|
||||
{ return do_get(__ii, __end, __str, __err, __val); }
|
||||
# endif
|
||||
|
||||
_InputIter get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, void*& __val) const
|
||||
{ return do_get(__ii, __end, __str, __err, __val); }
|
||||
|
||||
static locale::id id;
|
||||
|
||||
protected:
|
||||
~num_get() {}
|
||||
|
||||
typedef string string_type;
|
||||
typedef ctype<_CharT> _Ctype;
|
||||
typedef numpunct<_CharT> _Numpunct;
|
||||
|
||||
#if !defined (_STLP_NO_BOOL)
|
||||
virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, bool& __val) const;
|
||||
#endif
|
||||
|
||||
virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, long& __val) const;
|
||||
virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, unsigned short& __val) const;
|
||||
virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, unsigned int& __val) const;
|
||||
virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, unsigned long& __val) const;
|
||||
|
||||
#if defined (_STLP_FIX_LIBRARY_ISSUES)
|
||||
// issue 118 : those are actually not supposed to be here
|
||||
virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, short& __val) const;
|
||||
virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, int& __val) const;
|
||||
#endif
|
||||
|
||||
virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, float& __val) const;
|
||||
virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, double& __val) const;
|
||||
virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, void*& __p) const;
|
||||
|
||||
#if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, long double& __val) const;
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_LONG_LONG)
|
||||
virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, _STLP_LONG_LONG& __val) const;
|
||||
virtual _InputIter do_get(_InputIter __ii, _InputIter __end, ios_base& __str,
|
||||
ios_base::iostate& __err, unsigned _STLP_LONG_LONG& __val) const;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS num_get<char, istreambuf_iterator<char, char_traits<char> > >;
|
||||
// _STLP_EXPORT_TEMPLATE_CLASS num_get<char, const char*>;
|
||||
# if !defined (_STLP_NO_WCHAR_T)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
|
||||
// _STLP_EXPORT_TEMPLATE_CLASS num_get<wchar_t, const wchar_t*>;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
_STLP_DECLSPEC bool _STLP_CALL __valid_grouping(const char*, const char*, const char*, const char*);
|
||||
|
||||
template <class _InputIter, class _Integer, class _CharT>
|
||||
bool _STLP_CALL
|
||||
__get_decimal_integer(_InputIter& __first, _InputIter& __last, _Integer& __val, _CharT*);
|
||||
|
||||
# if !defined (_STLP_NO_WCHAR_T)
|
||||
bool _STLP_DECLSPEC _STLP_CALL __get_fdigit(wchar_t&, const wchar_t*);
|
||||
bool _STLP_DECLSPEC _STLP_CALL __get_fdigit_or_sep(wchar_t&, wchar_t, const wchar_t*);
|
||||
# endif
|
||||
|
||||
inline void _STLP_CALL
|
||||
_Initialize_get_float(const ctype<char>&,
|
||||
char& Plus, char& Minus,
|
||||
char& pow_e, char& pow_E,
|
||||
char*) {
|
||||
Plus = '+';
|
||||
Minus = '-';
|
||||
pow_e = 'e';
|
||||
pow_E = 'E';
|
||||
}
|
||||
|
||||
# if !defined (_STLP_NO_WCHAR_T)
|
||||
void _STLP_DECLSPEC _STLP_CALL _Initialize_get_float(const ctype<wchar_t>&,
|
||||
wchar_t&, wchar_t&, wchar_t&, wchar_t&, wchar_t*);
|
||||
# endif
|
||||
void _STLP_DECLSPEC _STLP_CALL __string_to_float(const __iostring&, float&);
|
||||
void _STLP_DECLSPEC _STLP_CALL __string_to_float(const __iostring&, double&);
|
||||
# if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
void _STLP_DECLSPEC _STLP_CALL __string_to_float(const __iostring&, long double&);
|
||||
# endif
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
#endif /* _STLP_EXPOSE_STREAM_IMPLEMENTATION */
|
||||
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_num_get.c>
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_NUM_GET_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
522
extern/STLport/5.2.1/stlport/stl/_num_put.c
vendored
Normal file
522
extern/STLport/5.2.1/stlport/stl/_num_put.c
vendored
Normal file
@@ -0,0 +1,522 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_NUM_PUT_C
|
||||
#define _STLP_NUM_PUT_C
|
||||
|
||||
#ifndef _STLP_INTERNAL_NUM_PUT_H
|
||||
# include <stl/_num_put.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_LIMITS
|
||||
# include <stl/_limits.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
// __do_put_float and its helper functions. Strategy: write the output
|
||||
// to a buffer of char, transform the buffer to _CharT, and then copy
|
||||
// it to the output.
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// num_put facet
|
||||
|
||||
template <class _CharT, class _OutputIter>
|
||||
_OutputIter _STLP_CALL
|
||||
__copy_float_and_fill(const _CharT* __first, const _CharT* __last,
|
||||
_OutputIter __oi,
|
||||
ios_base::fmtflags __flags,
|
||||
streamsize __width, _CharT __fill,
|
||||
_CharT __xplus, _CharT __xminus) {
|
||||
if (__width <= __last - __first)
|
||||
return _STLP_STD::copy(__first, __last, __oi);
|
||||
else {
|
||||
streamsize __pad = __width - (__last - __first);
|
||||
ios_base::fmtflags __dir = __flags & ios_base::adjustfield;
|
||||
|
||||
if (__dir == ios_base::left) {
|
||||
__oi = _STLP_STD::copy(__first, __last, __oi);
|
||||
return _STLP_PRIV __fill_n(__oi, __pad, __fill);
|
||||
}
|
||||
else if (__dir == ios_base::internal && __first != __last &&
|
||||
(*__first == __xplus || *__first == __xminus)) {
|
||||
*__oi++ = *__first++;
|
||||
__oi = _STLP_PRIV __fill_n(__oi, __pad, __fill);
|
||||
return _STLP_STD::copy(__first, __last, __oi);
|
||||
}
|
||||
else {
|
||||
__oi = _STLP_PRIV __fill_n(__oi, __pad, __fill);
|
||||
return _STLP_STD::copy(__first, __last, __oi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined (_STLP_NO_WCHAR_T)
|
||||
// Helper routine for wchar_t
|
||||
template <class _OutputIter>
|
||||
_OutputIter _STLP_CALL
|
||||
__put_float(__iostring &__str, _OutputIter __oi,
|
||||
ios_base& __f, wchar_t __fill,
|
||||
wchar_t __decimal_point, wchar_t __sep,
|
||||
size_t __group_pos, const string& __grouping) {
|
||||
const ctype<wchar_t>& __ct = use_facet<ctype<wchar_t> >(__f.getloc());
|
||||
|
||||
__iowstring __wbuf;
|
||||
__convert_float_buffer(__str, __wbuf, __ct, __decimal_point);
|
||||
|
||||
if (!__grouping.empty()) {
|
||||
__insert_grouping(__wbuf, __group_pos, __grouping,
|
||||
__sep, __ct.widen('+'), __ct.widen('-'), 0);
|
||||
}
|
||||
|
||||
return __copy_float_and_fill(__wbuf.data(), __wbuf.data() + __wbuf.size(), __oi,
|
||||
__f.flags(), __f.width(0), __fill, __ct.widen('+'), __ct.widen('-'));
|
||||
}
|
||||
#endif /* WCHAR_T */
|
||||
|
||||
// Helper routine for char
|
||||
template <class _OutputIter>
|
||||
_OutputIter _STLP_CALL
|
||||
__put_float(__iostring &__str, _OutputIter __oi,
|
||||
ios_base& __f, char __fill,
|
||||
char __decimal_point, char __sep,
|
||||
size_t __group_pos, const string& __grouping) {
|
||||
if ((__group_pos < __str.size()) && (__str[__group_pos] == '.')) {
|
||||
__str[__group_pos] = __decimal_point;
|
||||
}
|
||||
|
||||
if (!__grouping.empty()) {
|
||||
__insert_grouping(__str, __group_pos,
|
||||
__grouping, __sep, '+', '-', 0);
|
||||
}
|
||||
|
||||
return __copy_float_and_fill(__str.data(), __str.data() + __str.size(), __oi,
|
||||
__f.flags(), __f.width(0), __fill, '+', '-');
|
||||
}
|
||||
|
||||
template <class _CharT, class _OutputIter, class _Float>
|
||||
_OutputIter _STLP_CALL
|
||||
__do_put_float(_OutputIter __s, ios_base& __f,
|
||||
_CharT __fill, _Float __x) {
|
||||
__iostring __buf;
|
||||
|
||||
size_t __group_pos = __write_float(__buf, __f.flags(), (int)__f.precision(), __x);
|
||||
|
||||
const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__f.getloc());
|
||||
return __put_float(__buf, __s, __f, __fill,
|
||||
__np.decimal_point(), __np.thousands_sep(),
|
||||
__group_pos, __np.grouping());
|
||||
}
|
||||
|
||||
inline void __get_money_digits_aux (__iostring &__buf, ios_base &, _STLP_LONGEST_FLOAT_TYPE __x)
|
||||
{ __get_floor_digits(__buf, __x); }
|
||||
|
||||
#if !defined (_STLP_NO_WCHAR_T)
|
||||
inline void __get_money_digits_aux (__iowstring &__wbuf, ios_base &__f, _STLP_LONGEST_FLOAT_TYPE __x) {
|
||||
__iostring __buf;
|
||||
__get_floor_digits(__buf, __x);
|
||||
|
||||
const ctype<wchar_t>& __ct = use_facet<ctype<wchar_t> >(__f.getloc());
|
||||
__convert_float_buffer(__buf, __wbuf, __ct, wchar_t(0), false);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT>
|
||||
void _STLP_CALL __get_money_digits(_STLP_BASIC_IOSTRING(_CharT) &__buf, ios_base& __f, _STLP_LONGEST_FLOAT_TYPE __x)
|
||||
{ __get_money_digits_aux(__buf, __f, __x); }
|
||||
|
||||
// _M_do_put_integer and its helper functions.
|
||||
|
||||
template <class _CharT, class _OutputIter>
|
||||
_OutputIter _STLP_CALL
|
||||
__copy_integer_and_fill(const _CharT* __buf, ptrdiff_t __len,
|
||||
_OutputIter __oi,
|
||||
ios_base::fmtflags __flg, streamsize __wid, _CharT __fill,
|
||||
_CharT __xplus, _CharT __xminus) {
|
||||
if (__len >= __wid)
|
||||
return _STLP_STD::copy(__buf, __buf + __len, __oi);
|
||||
else {
|
||||
//casting numeric_limits<ptrdiff_t>::max to streamsize only works is ptrdiff_t is signed or streamsize representation
|
||||
//is larger than ptrdiff_t one.
|
||||
_STLP_STATIC_ASSERT((sizeof(streamsize) > sizeof(ptrdiff_t)) ||
|
||||
((sizeof(streamsize) == sizeof(ptrdiff_t)) && numeric_limits<ptrdiff_t>::is_signed))
|
||||
ptrdiff_t __pad = __STATIC_CAST(ptrdiff_t, (min) (__STATIC_CAST(streamsize, (numeric_limits<ptrdiff_t>::max)()),
|
||||
__STATIC_CAST(streamsize, __wid - __len)));
|
||||
ios_base::fmtflags __dir = __flg & ios_base::adjustfield;
|
||||
|
||||
if (__dir == ios_base::left) {
|
||||
__oi = _STLP_STD::copy(__buf, __buf + __len, __oi);
|
||||
return _STLP_PRIV __fill_n(__oi, __pad, __fill);
|
||||
}
|
||||
else if (__dir == ios_base::internal && __len != 0 &&
|
||||
(__buf[0] == __xplus || __buf[0] == __xminus)) {
|
||||
*__oi++ = __buf[0];
|
||||
__oi = __fill_n(__oi, __pad, __fill);
|
||||
return _STLP_STD::copy(__buf + 1, __buf + __len, __oi);
|
||||
}
|
||||
else if (__dir == ios_base::internal && __len >= 2 &&
|
||||
(__flg & ios_base::showbase) &&
|
||||
(__flg & ios_base::basefield) == ios_base::hex) {
|
||||
*__oi++ = __buf[0];
|
||||
*__oi++ = __buf[1];
|
||||
__oi = __fill_n(__oi, __pad, __fill);
|
||||
return _STLP_STD::copy(__buf + 2, __buf + __len, __oi);
|
||||
}
|
||||
else {
|
||||
__oi = __fill_n(__oi, __pad, __fill);
|
||||
return _STLP_STD::copy(__buf, __buf + __len, __oi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined (_STLP_NO_WCHAR_T)
|
||||
// Helper function for wchar_t
|
||||
template <class _OutputIter>
|
||||
_OutputIter _STLP_CALL
|
||||
__put_integer(char* __buf, char* __iend, _OutputIter __s,
|
||||
ios_base& __f,
|
||||
ios_base::fmtflags __flags, wchar_t __fill) {
|
||||
locale __loc = __f.getloc();
|
||||
const ctype<wchar_t>& __ct = use_facet<ctype<wchar_t> >(__loc);
|
||||
|
||||
wchar_t __xplus = __ct.widen('+');
|
||||
wchar_t __xminus = __ct.widen('-');
|
||||
|
||||
wchar_t __wbuf[64];
|
||||
__ct.widen(__buf, __iend, __wbuf);
|
||||
ptrdiff_t __len = __iend - __buf;
|
||||
wchar_t* __eend = __wbuf + __len;
|
||||
|
||||
const numpunct<wchar_t>& __np = use_facet<numpunct<wchar_t> >(__loc);
|
||||
const string& __grouping = __np.grouping();
|
||||
|
||||
if (!__grouping.empty()) {
|
||||
int __basechars;
|
||||
if (__flags & ios_base::showbase)
|
||||
switch (__flags & ios_base::basefield) {
|
||||
case ios_base::hex: __basechars = 2; break;
|
||||
case ios_base::oct: __basechars = 1; break;
|
||||
default: __basechars = 0;
|
||||
}
|
||||
else
|
||||
__basechars = 0;
|
||||
|
||||
__len = __insert_grouping(__wbuf, __eend, __grouping, __np.thousands_sep(),
|
||||
__xplus, __xminus, __basechars);
|
||||
}
|
||||
|
||||
return __copy_integer_and_fill((wchar_t*)__wbuf, __len, __s,
|
||||
__flags, __f.width(0), __fill, __xplus, __xminus);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Helper function for char
|
||||
template <class _OutputIter>
|
||||
_OutputIter _STLP_CALL
|
||||
__put_integer(char* __buf, char* __iend, _OutputIter __s,
|
||||
ios_base& __f, ios_base::fmtflags __flags, char __fill) {
|
||||
char __grpbuf[64];
|
||||
ptrdiff_t __len = __iend - __buf;
|
||||
|
||||
const numpunct<char>& __np = use_facet<numpunct<char> >(__f.getloc());
|
||||
const string& __grouping = __np.grouping();
|
||||
|
||||
if (!__grouping.empty()) {
|
||||
int __basechars;
|
||||
if (__flags & ios_base::showbase)
|
||||
switch (__flags & ios_base::basefield) {
|
||||
case ios_base::hex: __basechars = 2; break;
|
||||
case ios_base::oct: __basechars = 1; break;
|
||||
default: __basechars = 0;
|
||||
}
|
||||
else
|
||||
__basechars = 0;
|
||||
|
||||
// make sure there is room at the end of the buffer
|
||||
// we pass to __insert_grouping
|
||||
_STLP_STD::copy(__buf, __iend, (char *) __grpbuf);
|
||||
__buf = __grpbuf;
|
||||
__iend = __grpbuf + __len;
|
||||
__len = __insert_grouping(__buf, __iend, __grouping, __np.thousands_sep(),
|
||||
'+', '-', __basechars);
|
||||
}
|
||||
|
||||
return __copy_integer_and_fill(__buf, __len, __s, __flags, __f.width(0), __fill, '+', '-');
|
||||
}
|
||||
|
||||
#if defined (_STLP_LONG_LONG)
|
||||
typedef _STLP_LONG_LONG __max_int_t;
|
||||
typedef unsigned _STLP_LONG_LONG __umax_int_t;
|
||||
#else
|
||||
typedef long __max_int_t;
|
||||
typedef unsigned long __umax_int_t;
|
||||
#endif
|
||||
|
||||
_STLP_DECLSPEC const char* _STLP_CALL __hex_char_table_lo();
|
||||
_STLP_DECLSPEC const char* _STLP_CALL __hex_char_table_hi();
|
||||
|
||||
template <class _Integer>
|
||||
inline char* _STLP_CALL
|
||||
__write_decimal_backward(char* __ptr, _Integer __x, ios_base::fmtflags __flags, const __true_type& /* is_signed */) {
|
||||
const bool __negative = __x < 0 ;
|
||||
__max_int_t __temp = __x;
|
||||
__umax_int_t __utemp = __negative?-__temp:__temp;
|
||||
|
||||
for (; __utemp != 0; __utemp /= 10)
|
||||
*--__ptr = (char)((int)(__utemp % 10) + '0');
|
||||
// put sign if needed or requested
|
||||
if (__negative)
|
||||
*--__ptr = '-';
|
||||
else if (__flags & ios_base::showpos)
|
||||
*--__ptr = '+';
|
||||
return __ptr;
|
||||
}
|
||||
|
||||
template <class _Integer>
|
||||
inline char* _STLP_CALL
|
||||
__write_decimal_backward(char* __ptr, _Integer __x, ios_base::fmtflags __flags, const __false_type& /* is_signed */) {
|
||||
for (; __x != 0; __x /= 10)
|
||||
*--__ptr = (char)((int)(__x % 10) + '0');
|
||||
// put sign if requested
|
||||
if (__flags & ios_base::showpos)
|
||||
*--__ptr = '+';
|
||||
return __ptr;
|
||||
}
|
||||
|
||||
template <class _Integer>
|
||||
char* _STLP_CALL
|
||||
__write_integer_backward(char* __buf, ios_base::fmtflags __flags, _Integer __x) {
|
||||
char* __ptr = __buf;
|
||||
|
||||
if (__x == 0) {
|
||||
*--__ptr = '0';
|
||||
if ((__flags & ios_base::showpos) && ((__flags & (ios_base::oct | ios_base::hex)) == 0))
|
||||
*--__ptr = '+';
|
||||
// oct or hex base shall not be added to the 0 value (see '#' flag in C formating strings)
|
||||
}
|
||||
else {
|
||||
switch (__flags & ios_base::basefield) {
|
||||
case ios_base::oct:
|
||||
{
|
||||
__umax_int_t __temp = __x;
|
||||
// if the size of integer is less than 8, clear upper part
|
||||
if ( sizeof(__x) < 8 && sizeof(__umax_int_t) >= 8 )
|
||||
__temp &= 0xFFFFFFFF;
|
||||
|
||||
for (; __temp != 0; __temp >>=3)
|
||||
*--__ptr = (char)((((unsigned)__temp)& 0x7) + '0');
|
||||
|
||||
// put leading '0' if showbase is set
|
||||
if (__flags & ios_base::showbase)
|
||||
*--__ptr = '0';
|
||||
}
|
||||
break;
|
||||
case ios_base::hex:
|
||||
{
|
||||
const char* __table_ptr = (__flags & ios_base::uppercase) ?
|
||||
__hex_char_table_hi() : __hex_char_table_lo();
|
||||
__umax_int_t __temp = __x;
|
||||
// if the size of integer is less than 8, clear upper part
|
||||
if ( sizeof(__x) < 8 && sizeof(__umax_int_t) >= 8 )
|
||||
__temp &= 0xFFFFFFFF;
|
||||
|
||||
for (; __temp != 0; __temp >>=4)
|
||||
*--__ptr = __table_ptr[((unsigned)__temp & 0xF)];
|
||||
|
||||
if (__flags & ios_base::showbase) {
|
||||
*--__ptr = __table_ptr[16];
|
||||
*--__ptr = '0';
|
||||
}
|
||||
}
|
||||
break;
|
||||
//case ios_base::dec:
|
||||
default:
|
||||
{
|
||||
#if defined(__HP_aCC) && (__HP_aCC == 1)
|
||||
bool _IsSigned = !((_Integer)-1 > 0);
|
||||
if (_IsSigned)
|
||||
__ptr = __write_decimal_backward(__ptr, __x, __flags, __true_type() );
|
||||
else
|
||||
__ptr = __write_decimal_backward(__ptr, __x, __flags, __false_type() );
|
||||
#else
|
||||
typedef typename __bool2type<numeric_limits<_Integer>::is_signed>::_Ret _IsSigned;
|
||||
__ptr = __write_decimal_backward(__ptr, __x, __flags, _IsSigned());
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// return pointer to beginning of the string
|
||||
return __ptr;
|
||||
}
|
||||
|
||||
template <class _CharT, class _OutputIter, class _Integer>
|
||||
_OutputIter _STLP_CALL
|
||||
__do_put_integer(_OutputIter __s, ios_base& __f, _CharT __fill, _Integer __x) {
|
||||
// buffer size = number of bytes * number of digit necessary in the smallest Standard base (base 8, 3 digits/byte)
|
||||
// plus the longest base representation '0x'
|
||||
// Do not use __buf_size to define __buf static buffer, some compilers (HP aCC) do not accept const variable as
|
||||
// the specification of a static buffer size.
|
||||
char __buf[sizeof(_Integer) * 3 + 2];
|
||||
const ptrdiff_t __buf_size = sizeof(__buf) / sizeof(char);
|
||||
ios_base::fmtflags __flags = __f.flags();
|
||||
char* __ibeg = __write_integer_backward((char*)__buf + __buf_size, __flags, __x);
|
||||
return __put_integer(__ibeg, (char*)__buf + __buf_size, __s, __f, __flags, __fill);
|
||||
}
|
||||
|
||||
template <class _CharT, class _OutputIter>
|
||||
_OutputIter _STLP_CALL
|
||||
__do_put_bool(_OutputIter __s, ios_base& __f, _CharT __fill, bool __x) {
|
||||
const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__f.getloc());
|
||||
|
||||
basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > __str = __x ? __np.truename() : __np.falsename();
|
||||
|
||||
streamsize __wid = __f.width(0);
|
||||
if (__str.size() >= __STATIC_CAST(size_t, __wid))
|
||||
return _STLP_STD::copy(__str.begin(), __str.end(), __s);
|
||||
else {
|
||||
streamsize __pad = __wid - __str.size();
|
||||
ios_base::fmtflags __dir = __f.flags() & ios_base::adjustfield;
|
||||
|
||||
if (__dir == ios_base::left) {
|
||||
__s = _STLP_STD::copy(__str.begin(), __str.end(), __s);
|
||||
return __fill_n(__s, __pad, __fill);
|
||||
}
|
||||
else /* covers right and internal padding */ {
|
||||
__s = __fill_n(__s, __pad, __fill);
|
||||
return _STLP_STD::copy(__str.begin(), __str.end(), __s);
|
||||
}
|
||||
}
|
||||
}
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
//
|
||||
// num_put<>
|
||||
//
|
||||
|
||||
template <class _CharT, class _OutputIterator>
|
||||
locale::id num_put<_CharT, _OutputIterator>::id;
|
||||
|
||||
#if !defined (_STLP_NO_BOOL)
|
||||
template <class _CharT, class _OutputIter>
|
||||
_OutputIter
|
||||
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
|
||||
bool __val) const {
|
||||
if (!(__f.flags() & ios_base::boolalpha))
|
||||
// 22.2.2.2.2.23: shall return do_put for int and not directly __do_put_integer.
|
||||
return do_put(__s, __f, __fill, __STATIC_CAST(long, __val));
|
||||
|
||||
return _STLP_PRIV __do_put_bool(__s, __f, __fill, __val);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _OutputIter>
|
||||
_OutputIter
|
||||
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
|
||||
long __val) const
|
||||
{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); }
|
||||
|
||||
template <class _CharT, class _OutputIter>
|
||||
_OutputIter
|
||||
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
|
||||
unsigned long __val) const
|
||||
{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); }
|
||||
|
||||
template <class _CharT, class _OutputIter>
|
||||
_OutputIter
|
||||
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
|
||||
double __val) const
|
||||
{ return _STLP_PRIV __do_put_float(__s, __f, __fill, __val); }
|
||||
|
||||
#if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
template <class _CharT, class _OutputIter>
|
||||
_OutputIter
|
||||
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
|
||||
long double __val) const
|
||||
{ return _STLP_PRIV __do_put_float(__s, __f, __fill, __val); }
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_LONG_LONG)
|
||||
template <class _CharT, class _OutputIter>
|
||||
_OutputIter
|
||||
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
|
||||
_STLP_LONG_LONG __val) const
|
||||
{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); }
|
||||
|
||||
template <class _CharT, class _OutputIter>
|
||||
_OutputIter
|
||||
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
|
||||
unsigned _STLP_LONG_LONG __val) const
|
||||
{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); }
|
||||
#endif /* _STLP_LONG_LONG */
|
||||
|
||||
|
||||
// 22.2.2.2.2 Stage 1: "For conversion from void* the specifier is %p."
|
||||
// This is not clear and I'm really don't follow this (below).
|
||||
template <class _CharT, class _OutputIter>
|
||||
_OutputIter
|
||||
num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT /*__fill*/,
|
||||
const void* __val) const {
|
||||
const ctype<_CharT>& __c_type = use_facet<ctype<_CharT> >(__f.getloc());
|
||||
ios_base::fmtflags __save_flags = __f.flags();
|
||||
|
||||
__f.setf(ios_base::hex, ios_base::basefield);
|
||||
__f.setf(ios_base::showbase);
|
||||
__f.setf(ios_base::internal, ios_base::adjustfield);
|
||||
__f.width((sizeof(void*) * 2) + 2); // digits in pointer type plus '0x' prefix
|
||||
if ( __val == 0 ) {
|
||||
// base ('0x') not shown for null, but I really want to type it
|
||||
// for pointer. Print it first in this case.
|
||||
const char* __table_ptr = (__save_flags & ios_base::uppercase) ?
|
||||
_STLP_PRIV __hex_char_table_hi() : _STLP_PRIV __hex_char_table_lo();
|
||||
__s++ = __c_type.widen( '0' );
|
||||
__s++ = __c_type.widen( __table_ptr[16] );
|
||||
__f.width((sizeof(void*) * 2)); // digits in pointer type
|
||||
} else {
|
||||
__f.width((sizeof(void*) * 2) + 2); // digits in pointer type plus '0x' prefix
|
||||
}
|
||||
#if defined (_STLP_MSVC)
|
||||
# pragma warning (push)
|
||||
# pragma warning (disable : 4311) //pointer truncation from 'const void*' to 'unsigned long'
|
||||
#endif
|
||||
_OutputIter result =
|
||||
#ifdef _STLP_LONG_LONG
|
||||
( sizeof(void*) == sizeof(unsigned long) ) ?
|
||||
#endif
|
||||
_STLP_PRIV __do_put_integer(__s, __f, __c_type.widen('0'), __REINTERPRET_CAST(unsigned long,__val))
|
||||
#ifdef _STLP_LONG_LONG
|
||||
: /* ( sizeof(void*) == sizeof(unsigned _STLP_LONG_LONG) ) ? */
|
||||
_STLP_PRIV __do_put_integer(__s, __f, __c_type.widen('0'), __REINTERPRET_CAST(unsigned _STLP_LONG_LONG,__val))
|
||||
#endif
|
||||
;
|
||||
#if defined (_STLP_MSVC)
|
||||
# pragma warning (pop)
|
||||
#endif
|
||||
__f.flags(__save_flags);
|
||||
return result;
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_NUM_PUT_C */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
187
extern/STLport/5.2.1/stlport/stl/_num_put.h
vendored
Normal file
187
extern/STLport/5.2.1/stlport/stl/_num_put.h
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
// WARNING: This is an internal header file, included by other C++
|
||||
// standard library headers. You should not attempt to use this header
|
||||
// file directly.
|
||||
|
||||
|
||||
#ifndef _STLP_INTERNAL_NUM_PUT_H
|
||||
#define _STLP_INTERNAL_NUM_PUT_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_NUMPUNCT_H
|
||||
# include <stl/_numpunct.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_CTYPE_H
|
||||
# include <stl/_ctype.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
|
||||
# include <stl/_ostreambuf_iterator.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_IOSTREAM_STRING_H
|
||||
# include <stl/_iostream_string.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_FACETS_FWD_H
|
||||
# include <stl/_facets_fwd.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// num_put facet
|
||||
|
||||
template <class _CharT, class _OutputIter>
|
||||
class num_put: public locale::facet {
|
||||
public:
|
||||
typedef _CharT char_type;
|
||||
typedef _OutputIter iter_type;
|
||||
|
||||
explicit num_put(size_t __refs = 0) : locale::facet(__refs) {}
|
||||
|
||||
#if !defined (_STLP_NO_BOOL)
|
||||
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
|
||||
bool __val) const {
|
||||
return do_put(__s, __f, __fill, __val);
|
||||
}
|
||||
#endif
|
||||
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
|
||||
long __val) const {
|
||||
return do_put(__s, __f, __fill, __val);
|
||||
}
|
||||
|
||||
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
|
||||
unsigned long __val) const {
|
||||
return do_put(__s, __f, __fill, __val);
|
||||
}
|
||||
|
||||
#if defined (_STLP_LONG_LONG)
|
||||
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
|
||||
_STLP_LONG_LONG __val) const {
|
||||
return do_put(__s, __f, __fill, __val);
|
||||
}
|
||||
|
||||
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
|
||||
unsigned _STLP_LONG_LONG __val) const {
|
||||
return do_put(__s, __f, __fill, __val);
|
||||
}
|
||||
#endif
|
||||
|
||||
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
|
||||
double __val) const {
|
||||
return do_put(__s, __f, __fill, (double)__val);
|
||||
}
|
||||
|
||||
#if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
|
||||
long double __val) const {
|
||||
return do_put(__s, __f, __fill, __val);
|
||||
}
|
||||
#endif
|
||||
|
||||
iter_type put(iter_type __s, ios_base& __f, char_type __fill,
|
||||
const void * __val) const {
|
||||
return do_put(__s, __f, __fill, __val);
|
||||
}
|
||||
|
||||
static locale::id id;
|
||||
|
||||
protected:
|
||||
~num_put() {}
|
||||
#if !defined (_STLP_NO_BOOL)
|
||||
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, bool __val) const;
|
||||
#endif
|
||||
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, long __val) const;
|
||||
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, unsigned long __val) const;
|
||||
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, double __val) const;
|
||||
#if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, long double __val) const;
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_LONG_LONG)
|
||||
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, _STLP_LONG_LONG __val) const;
|
||||
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
|
||||
unsigned _STLP_LONG_LONG __val) const ;
|
||||
#endif
|
||||
virtual _OutputIter do_put(_OutputIter __s, ios_base& __f, _CharT __fill, const void* __val) const;
|
||||
};
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS num_put<char, ostreambuf_iterator<char, char_traits<char> > >;
|
||||
# if !defined (_STLP_NO_WCHAR_T)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Integer>
|
||||
char* _STLP_CALL
|
||||
__write_integer_backward(char* __buf, ios_base::fmtflags __flags, _Integer __x);
|
||||
|
||||
/*
|
||||
* Returns the position on the right of the digits that has to be considered
|
||||
* for the application of the grouping policy.
|
||||
*/
|
||||
extern size_t _STLP_CALL __write_float(__iostring&, ios_base::fmtflags, int, double);
|
||||
# if !defined (_STLP_NO_LONG_DOUBLE)
|
||||
extern size_t _STLP_CALL __write_float(__iostring&, ios_base::fmtflags, int, long double);
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Gets the digits of the integer part.
|
||||
*/
|
||||
void _STLP_CALL __get_floor_digits(__iostring&, _STLP_LONGEST_FLOAT_TYPE);
|
||||
|
||||
template <class _CharT>
|
||||
void _STLP_CALL __get_money_digits(_STLP_BASIC_IOSTRING(_CharT)&, ios_base&, _STLP_LONGEST_FLOAT_TYPE);
|
||||
|
||||
# if !defined (_STLP_NO_WCHAR_T)
|
||||
extern void _STLP_CALL __convert_float_buffer(__iostring const&, __iowstring&, const ctype<wchar_t>&, wchar_t, bool = true);
|
||||
# endif
|
||||
extern void _STLP_CALL __adjust_float_buffer(__iostring&, char);
|
||||
|
||||
extern char* _STLP_CALL
|
||||
__write_integer(char* buf, ios_base::fmtflags flags, long x);
|
||||
|
||||
extern ptrdiff_t _STLP_CALL __insert_grouping(char* first, char* last, const string&, char, char, char, int);
|
||||
extern void _STLP_CALL __insert_grouping(__iostring&, size_t, const string&, char, char, char, int);
|
||||
# if !defined (_STLP_NO_WCHAR_T)
|
||||
extern ptrdiff_t _STLP_CALL __insert_grouping(wchar_t*, wchar_t*, const string&, wchar_t, wchar_t, wchar_t, int);
|
||||
extern void _STLP_CALL __insert_grouping(__iowstring&, size_t, const string&, wchar_t, wchar_t, wchar_t, int);
|
||||
# endif
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
#endif /* _STLP_EXPOSE_STREAM_IMPLEMENTATION */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_num_put.c>
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_NUMERIC_FACETS_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
106
extern/STLport/5.2.1/stlport/stl/_numeric.c
vendored
Normal file
106
extern/STLport/5.2.1/stlport/stl/_numeric.c
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_NUMERIC_C
|
||||
#define _STLP_NUMERIC_C
|
||||
|
||||
#ifndef _STLP_INTERNAL_NUMERIC_H
|
||||
# include <stl/_numeric.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp,
|
||||
class _BinaryOperation>
|
||||
_OutputIterator
|
||||
__partial_sum(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp*, _BinaryOperation __binary_op) {
|
||||
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
||||
if (__first == __last) return __result;
|
||||
*__result = *__first;
|
||||
|
||||
_Tp __val = *__first;
|
||||
while (++__first != __last) {
|
||||
__val = __binary_op(__val, *__first);
|
||||
*++__result = __val;
|
||||
}
|
||||
return ++__result;
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp,
|
||||
class _BinaryOperation>
|
||||
_OutputIterator
|
||||
__adjacent_difference(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp*,
|
||||
_BinaryOperation __binary_op) {
|
||||
_STLP_DEBUG_CHECK(__check_range(__first, __last))
|
||||
if (__first == __last) return __result;
|
||||
*__result = *__first;
|
||||
_Tp __val = *__first;
|
||||
while (++__first != __last) {
|
||||
_Tp __tmp = *__first;
|
||||
*++__result = __binary_op(__tmp, __val);
|
||||
__val = __tmp;
|
||||
}
|
||||
return ++__result;
|
||||
}
|
||||
|
||||
|
||||
template <class _Tp, class _Integer, class _MonoidOperation>
|
||||
_Tp __power(_Tp __x, _Integer __n, _MonoidOperation __opr) {
|
||||
_STLP_MPWFIX_TRY
|
||||
if (__n == 0)
|
||||
return __identity_element(__opr);
|
||||
else {
|
||||
while ((__n & 1) == 0) {
|
||||
__n >>= 1;
|
||||
__x = __opr(__x, __x);
|
||||
}
|
||||
_Tp __result = __x;
|
||||
_STLP_MPWFIX_TRY
|
||||
__n >>= 1;
|
||||
while (__n != 0) {
|
||||
__x = __opr(__x, __x);
|
||||
if ((__n & 1) != 0)
|
||||
__result = __opr(__result, __x);
|
||||
__n >>= 1;
|
||||
}
|
||||
return __result;
|
||||
_STLP_MPWFIX_CATCH
|
||||
}
|
||||
_STLP_MPWFIX_CATCH_ACTION(__x = _Tp())
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_NUMERIC_C */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
191
extern/STLport/5.2.1/stlport/stl/_numeric.h
vendored
Normal file
191
extern/STLport/5.2.1/stlport/stl/_numeric.h
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_NUMERIC_H
|
||||
#define _STLP_INTERNAL_NUMERIC_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
|
||||
# include <stl/_function_base.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
|
||||
# include <stl/_iterator_base.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _InputIterator, class _Tp>
|
||||
_STLP_INLINE_LOOP
|
||||
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp _Init) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
for ( ; __first != __last; ++__first)
|
||||
_Init = _Init + *__first;
|
||||
return _Init;
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _Tp, class _BinaryOperation>
|
||||
_STLP_INLINE_LOOP
|
||||
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp _Init,
|
||||
_BinaryOperation __binary_op) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
for ( ; __first != __last; ++__first)
|
||||
_Init = __binary_op(_Init, *__first);
|
||||
return _Init;
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _Tp>
|
||||
_STLP_INLINE_LOOP
|
||||
_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _Tp _Init) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
for ( ; __first1 != __last1; ++__first1, ++__first2)
|
||||
_Init = _Init + (*__first1 * *__first2);
|
||||
return _Init;
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _Tp,
|
||||
class _BinaryOperation1, class _BinaryOperation2>
|
||||
_STLP_INLINE_LOOP
|
||||
_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _Tp _Init,
|
||||
_BinaryOperation1 __binary_op1,
|
||||
_BinaryOperation2 __binary_op2) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1))
|
||||
for ( ; __first1 != __last1; ++__first1, ++__first2)
|
||||
_Init = __binary_op1(_Init, __binary_op2(*__first1, *__first2));
|
||||
return _Init;
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp,
|
||||
class _BinaryOperation>
|
||||
_OutputIterator
|
||||
__partial_sum(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp*, _BinaryOperation __binary_op);
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
inline _OutputIterator
|
||||
partial_sum(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result) {
|
||||
return _STLP_PRIV __partial_sum(__first, __last, __result, _STLP_VALUE_TYPE(__first, _InputIterator),
|
||||
_STLP_PRIV __plus(_STLP_VALUE_TYPE(__first, _InputIterator)));
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
|
||||
inline _OutputIterator
|
||||
partial_sum(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOperation __binary_op) {
|
||||
return _STLP_PRIV __partial_sum(__first, __last, __result, _STLP_VALUE_TYPE(__first, _InputIterator),
|
||||
__binary_op);
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp,
|
||||
class _BinaryOperation>
|
||||
_OutputIterator
|
||||
__adjacent_difference(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp*,
|
||||
_BinaryOperation __binary_op);
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
inline _OutputIterator
|
||||
adjacent_difference(_InputIterator __first,
|
||||
_InputIterator __last, _OutputIterator __result) {
|
||||
return _STLP_PRIV __adjacent_difference(__first, __last, __result,
|
||||
_STLP_VALUE_TYPE(__first, _InputIterator),
|
||||
_STLP_PRIV __minus(_STLP_VALUE_TYPE(__first, _InputIterator)));
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
|
||||
_OutputIterator
|
||||
adjacent_difference(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOperation __binary_op) {
|
||||
return _STLP_PRIV __adjacent_difference(__first, __last, __result,
|
||||
_STLP_VALUE_TYPE(__first, _InputIterator),
|
||||
__binary_op);
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Tp, class _Integer, class _MonoidOperation>
|
||||
_Tp __power(_Tp __x, _Integer __n, _MonoidOperation __opr);
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
|
||||
// Returns __x ** __n, where __n >= 0. _Note that "multiplication"
|
||||
// is required to be associative, but not necessarily commutative.
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Tp, class _Integer>
|
||||
inline _Tp __power(_Tp __x, _Integer __n) {
|
||||
return __power(__x, __n, multiplies<_Tp>());
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
// Alias for the internal name __power. Note that power is an extension,
|
||||
// not part of the C++ standard.
|
||||
template <class _Tp, class _Integer, class _MonoidOperation>
|
||||
inline _Tp power(_Tp __x, _Integer __n, _MonoidOperation __opr) {
|
||||
return _STLP_PRIV __power(__x, __n, __opr);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Integer>
|
||||
inline _Tp power(_Tp __x, _Integer __n) {
|
||||
return _STLP_PRIV __power(__x, __n, multiplies<_Tp>());
|
||||
}
|
||||
|
||||
// iota is not part of the C++ standard. It is an extension.
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
_STLP_INLINE_LOOP
|
||||
void iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __val) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
while (__first != __last)
|
||||
*__first++ = __val++;
|
||||
}
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_numeric.c>
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_NUMERIC_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
176
extern/STLport/5.2.1/stlport/stl/_numpunct.h
vendored
Normal file
176
extern/STLport/5.2.1/stlport/stl/_numpunct.h
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
// WARNING: This is an internal header file, included by other C++
|
||||
// standard library headers. You should not attempt to use this header
|
||||
// file directly.
|
||||
|
||||
|
||||
#ifndef _STLP_INTERNAL_NUMPUNCT_H
|
||||
#define _STLP_INTERNAL_NUMPUNCT_H
|
||||
|
||||
#ifndef _STLP_IOS_BASE_H
|
||||
# include <stl/_ios_base.h>
|
||||
#endif
|
||||
|
||||
# ifndef _STLP_C_LOCALE_H
|
||||
# include <stl/c_locale.h>
|
||||
# endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_STRING_H
|
||||
# include <stl/_string.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// numpunct facets
|
||||
|
||||
template <class _CharT> class numpunct {};
|
||||
template <class _CharT> class numpunct_byname {};
|
||||
template <class _Ch, class _InIt> class num_get;
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC numpunct<char> : public locale::facet {
|
||||
public:
|
||||
typedef char char_type;
|
||||
typedef string string_type;
|
||||
|
||||
explicit numpunct(size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
char decimal_point() const { return do_decimal_point(); }
|
||||
char thousands_sep() const { return do_thousands_sep(); }
|
||||
string grouping() const { return do_grouping(); }
|
||||
string truename() const { return do_truename(); }
|
||||
string falsename() const { return do_falsename(); }
|
||||
|
||||
static _STLP_STATIC_DECLSPEC locale::id id;
|
||||
|
||||
protected:
|
||||
~numpunct();
|
||||
|
||||
virtual char do_decimal_point() const;
|
||||
virtual char do_thousands_sep() const;
|
||||
virtual string do_grouping() const;
|
||||
virtual string do_truename() const;
|
||||
virtual string do_falsename() const;
|
||||
};
|
||||
|
||||
# if ! defined (_STLP_NO_WCHAR_T)
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC numpunct<wchar_t> : public locale::facet {
|
||||
public:
|
||||
typedef wchar_t char_type;
|
||||
typedef wstring string_type;
|
||||
|
||||
explicit numpunct(size_t __refs = 0)
|
||||
: locale::facet(__refs) {}
|
||||
|
||||
wchar_t decimal_point() const { return do_decimal_point(); }
|
||||
wchar_t thousands_sep() const { return do_thousands_sep(); }
|
||||
string grouping() const { return do_grouping(); }
|
||||
wstring truename() const { return do_truename(); }
|
||||
wstring falsename() const { return do_falsename(); }
|
||||
|
||||
static _STLP_STATIC_DECLSPEC locale::id id;
|
||||
|
||||
protected:
|
||||
~numpunct();
|
||||
|
||||
virtual wchar_t do_decimal_point() const;
|
||||
virtual wchar_t do_thousands_sep() const;
|
||||
virtual string do_grouping() const;
|
||||
virtual wstring do_truename() const;
|
||||
virtual wstring do_falsename() const;
|
||||
};
|
||||
|
||||
# endif /* WCHAR_T */
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC numpunct_byname<char> : public numpunct<char> {
|
||||
friend class _Locale_impl;
|
||||
public:
|
||||
typedef char char_type;
|
||||
typedef string string_type;
|
||||
|
||||
explicit numpunct_byname(const char* __name, size_t __refs = 0);
|
||||
|
||||
protected:
|
||||
|
||||
~numpunct_byname();
|
||||
|
||||
virtual char do_decimal_point() const;
|
||||
virtual char do_thousands_sep() const;
|
||||
virtual string do_grouping() const;
|
||||
virtual string do_truename() const;
|
||||
virtual string do_falsename() const;
|
||||
|
||||
private:
|
||||
numpunct_byname(_Locale_numeric *__numeric)
|
||||
: _M_numeric(__numeric) {}
|
||||
|
||||
//explicitely defined as private to avoid warnings:
|
||||
typedef numpunct_byname<char> _Self;
|
||||
numpunct_byname(_Self const&);
|
||||
_Self& operator = (_Self const&);
|
||||
|
||||
_Locale_numeric* _M_numeric;
|
||||
};
|
||||
|
||||
# ifndef _STLP_NO_WCHAR_T
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC numpunct_byname<wchar_t>: public numpunct<wchar_t> {
|
||||
friend class _Locale_impl;
|
||||
public:
|
||||
typedef wchar_t char_type;
|
||||
typedef wstring string_type;
|
||||
|
||||
explicit numpunct_byname(const char* __name, size_t __refs = 0);
|
||||
|
||||
protected:
|
||||
~numpunct_byname();
|
||||
|
||||
virtual wchar_t do_decimal_point() const;
|
||||
virtual wchar_t do_thousands_sep() const;
|
||||
virtual string do_grouping() const;
|
||||
virtual wstring do_truename() const;
|
||||
virtual wstring do_falsename() const;
|
||||
|
||||
private:
|
||||
numpunct_byname(_Locale_numeric *__numeric)
|
||||
: _M_numeric(__numeric) {}
|
||||
|
||||
//explicitely defined as private to avoid warnings:
|
||||
typedef numpunct_byname<wchar_t> _Self;
|
||||
numpunct_byname(_Self const&);
|
||||
_Self& operator = (_Self const&);
|
||||
|
||||
_Locale_numeric* _M_numeric;
|
||||
};
|
||||
|
||||
# endif /* WCHAR_T */
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_NUMPUNCT_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
455
extern/STLport/5.2.1/stlport/stl/_ostream.c
vendored
Normal file
455
extern/STLport/5.2.1/stlport/stl/_ostream.c
vendored
Normal file
@@ -0,0 +1,455 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_OSTREAM_C
|
||||
#define _STLP_OSTREAM_C
|
||||
|
||||
#ifndef _STLP_INTERNAL_OSTREAM_H
|
||||
# include <stl/_ostream.h>
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_INTERNAL_NUM_PUT_H)
|
||||
# include <stl/_num_put.h> // For basic_streambuf and iterators
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Definitions of non-inline member functions.
|
||||
|
||||
// Constructor, destructor
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>::basic_ostream(basic_streambuf<_CharT, _Traits>* __buf)
|
||||
: basic_ios<_CharT, _Traits>() {
|
||||
this->init(__buf);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>::~basic_ostream()
|
||||
{}
|
||||
|
||||
// Output directly from a streambuf.
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<_CharT, _Traits>* __from) {
|
||||
sentry __sentry(*this);
|
||||
if (__sentry) {
|
||||
if (__from) {
|
||||
bool __any_inserted = __from->gptr() != __from->egptr()
|
||||
? this->_M_copy_buffered(__from, this->rdbuf())
|
||||
: this->_M_copy_unbuffered(__from, this->rdbuf());
|
||||
if (!__any_inserted)
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
else
|
||||
this->setstate(ios_base::badbit);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Helper functions for the streambuf version of operator<<. The
|
||||
// exception-handling code is complicated because exceptions thrown
|
||||
// while extracting characters are treated differently than exceptions
|
||||
// thrown while inserting characters.
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
bool basic_ostream<_CharT, _Traits>
|
||||
::_M_copy_buffered(basic_streambuf<_CharT, _Traits>* __from,
|
||||
basic_streambuf<_CharT, _Traits>* __to) {
|
||||
bool __any_inserted = false;
|
||||
|
||||
while (__from->egptr() != __from->gptr()) {
|
||||
const ptrdiff_t __avail = __from->egptr() - __from->gptr();
|
||||
|
||||
streamsize __nwritten;
|
||||
_STLP_TRY {
|
||||
__nwritten = __to->sputn(__from->gptr(), __avail);
|
||||
__from->gbump((int)__nwritten);
|
||||
}
|
||||
_STLP_CATCH_ALL {
|
||||
this->_M_handle_exception(ios_base::badbit);
|
||||
return __any_inserted;
|
||||
}
|
||||
|
||||
if (__nwritten == __avail) {
|
||||
_STLP_TRY {
|
||||
if (this->_S_eof(__from->sgetc()))
|
||||
return true;
|
||||
else
|
||||
__any_inserted = true;
|
||||
}
|
||||
_STLP_CATCH_ALL {
|
||||
this->_M_handle_exception(ios_base::failbit);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (__nwritten != 0)
|
||||
return true;
|
||||
else
|
||||
return __any_inserted;
|
||||
}
|
||||
|
||||
// No characters are in the buffer, but we aren't at EOF. Switch to
|
||||
// unbuffered mode.
|
||||
return __any_inserted || this->_M_copy_unbuffered(__from, __to);
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper struct (guard) to put back a character in a streambuf
|
||||
* whenever an exception or an eof occur.
|
||||
*/
|
||||
template <class _CharT, class _Traits>
|
||||
struct _SPutBackC {
|
||||
typedef basic_streambuf<_CharT, _Traits> _StreamBuf;
|
||||
typedef typename _StreamBuf::int_type int_type;
|
||||
_SPutBackC(_StreamBuf *pfrom)
|
||||
: __pfrom(pfrom), __c(0), __do_guard(false) {}
|
||||
~_SPutBackC() {
|
||||
if (__do_guard) {
|
||||
__pfrom->sputbackc(_Traits::to_char_type(__c));
|
||||
}
|
||||
}
|
||||
|
||||
void guard(int_type c) {
|
||||
__c = c;
|
||||
__do_guard = true;
|
||||
}
|
||||
void release() {
|
||||
__do_guard = false;
|
||||
}
|
||||
|
||||
private:
|
||||
_StreamBuf *__pfrom;
|
||||
int_type __c;
|
||||
bool __do_guard;
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
bool basic_ostream<_CharT, _Traits>
|
||||
::_M_copy_unbuffered(basic_streambuf<_CharT, _Traits>* __from,
|
||||
basic_streambuf<_CharT, _Traits>* __to) {
|
||||
typedef _SPutBackC<_CharT, _Traits> _SPutBackCGuard;
|
||||
bool __any_inserted = false;
|
||||
int_type __c;
|
||||
|
||||
_STLP_TRY {
|
||||
_SPutBackCGuard __cguard(__from);
|
||||
for (;;) {
|
||||
_STLP_TRY {
|
||||
__c = __from->sbumpc();
|
||||
}
|
||||
_STLP_CATCH_ALL {
|
||||
this->_M_handle_exception(ios_base::failbit);
|
||||
break;
|
||||
}
|
||||
|
||||
if (this->_S_eof(__c))
|
||||
break;
|
||||
|
||||
__cguard.guard(__c);
|
||||
#if defined (__DMC__)
|
||||
_STLP_TRY {
|
||||
#endif
|
||||
if (this->_S_eof(__to->sputc(_Traits::to_char_type(__c))))
|
||||
break;
|
||||
|
||||
#if defined (__DMC__)
|
||||
}
|
||||
_STLP_CATCH_ALL {
|
||||
this->_M_handle_exception(ios_base::badbit);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
__cguard.release();
|
||||
__any_inserted = true;
|
||||
}
|
||||
}
|
||||
_STLP_CATCH_ALL {
|
||||
this->_M_handle_exception(ios_base::badbit);
|
||||
}
|
||||
return __any_inserted;
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
// Helper function for numeric output.
|
||||
template <class _CharT, class _Traits, class _Number>
|
||||
basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
__put_num(basic_ostream<_CharT, _Traits>& __os, _Number __x) {
|
||||
typedef typename basic_ostream<_CharT, _Traits>::sentry _Sentry;
|
||||
_Sentry __sentry(__os);
|
||||
bool __failed = true;
|
||||
|
||||
if (__sentry) {
|
||||
_STLP_TRY {
|
||||
typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> > _NumPut;
|
||||
__failed = (use_facet<_NumPut>(__os.getloc())).put(ostreambuf_iterator<_CharT, _Traits>(__os.rdbuf()),
|
||||
__os, __os.fill(),
|
||||
__x).failed();
|
||||
}
|
||||
_STLP_CATCH_ALL {
|
||||
__os._M_handle_exception(ios_base::badbit);
|
||||
}
|
||||
}
|
||||
if (__failed)
|
||||
__os.setstate(ios_base::badbit);
|
||||
return __os;
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
/*
|
||||
* In the following operators we try to limit code bloat by limiting the
|
||||
* number of __put_num instanciations.
|
||||
*/
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(short __x) {
|
||||
_STLP_STATIC_ASSERT( sizeof(short) <= sizeof(long) )
|
||||
long __tmp = ((this->flags() & _Basic_ios::basefield) != ios_base::dec) ?
|
||||
__STATIC_CAST(long, __STATIC_CAST(unsigned short, __x)): __x;
|
||||
return _STLP_PRIV __put_num(*this, __tmp);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned short __x) {
|
||||
_STLP_STATIC_ASSERT( sizeof(unsigned short) <= sizeof(unsigned long) )
|
||||
return _STLP_PRIV __put_num(*this, __STATIC_CAST(unsigned long,__x));
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(int __x) {
|
||||
_STLP_STATIC_ASSERT( sizeof(int) <= sizeof(long) )
|
||||
long __tmp = ((this->flags() & _Basic_ios::basefield) != ios_base::dec) ?
|
||||
__STATIC_CAST(long, __STATIC_CAST(unsigned int, __x)): __x;
|
||||
return _STLP_PRIV __put_num(*this, __tmp);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
#if defined (_WIN64) || !defined (_STLP_MSVC) || (_STLP_MSVC < 1300)
|
||||
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned int __x) {
|
||||
_STLP_STATIC_ASSERT( sizeof(unsigned int) <= sizeof(unsigned long) )
|
||||
#else
|
||||
/* We define this operator with size_t rather than unsigned int to avoid
|
||||
* 64 bits warning.
|
||||
*/
|
||||
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(size_t __x) {
|
||||
_STLP_STATIC_ASSERT( sizeof(size_t) <= sizeof(unsigned long) )
|
||||
#endif
|
||||
return _STLP_PRIV __put_num(*this, __STATIC_CAST(unsigned long,__x));
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __x)
|
||||
{ return _STLP_PRIV __put_num(*this, __x); }
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long __x)
|
||||
{ return _STLP_PRIV __put_num(*this, __x); }
|
||||
|
||||
#ifdef _STLP_LONG_LONG
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<< (_STLP_LONG_LONG __x)
|
||||
{ return _STLP_PRIV __put_num(*this, __x); }
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<< (unsigned _STLP_LONG_LONG __x)
|
||||
{ return _STLP_PRIV __put_num(*this, __x); }
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float __x)
|
||||
{ return _STLP_PRIV __put_num(*this, __STATIC_CAST(double,__x)); }
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(double __x)
|
||||
{ return _STLP_PRIV __put_num(*this, __x); }
|
||||
|
||||
#ifndef _STLP_NO_LONG_DOUBLE
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long double __x)
|
||||
{ return _STLP_PRIV __put_num(*this, __x); }
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const void* __x)
|
||||
{ return _STLP_PRIV __put_num(*this, __x); }
|
||||
|
||||
#ifndef _STLP_NO_BOOL
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(bool __x)
|
||||
{ return _STLP_PRIV __put_num(*this, __x); }
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
void basic_ostream<_CharT, _Traits>::_M_put_char(_CharT __c) {
|
||||
sentry __sentry(*this);
|
||||
if (__sentry) {
|
||||
bool __failed = true;
|
||||
_STLP_TRY {
|
||||
streamsize __npad = this->width() > 0 ? this->width() - 1 : 0;
|
||||
// if (__npad <= 1)
|
||||
if (__npad == 0)
|
||||
__failed = this->_S_eof(this->rdbuf()->sputc(__c));
|
||||
else if ((this->flags() & ios_base::adjustfield) == ios_base::left) {
|
||||
__failed = this->_S_eof(this->rdbuf()->sputc(__c));
|
||||
__failed = __failed ||
|
||||
this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad;
|
||||
}
|
||||
else {
|
||||
__failed = this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad;
|
||||
__failed = __failed || this->_S_eof(this->rdbuf()->sputc(__c));
|
||||
}
|
||||
|
||||
this->width(0);
|
||||
}
|
||||
_STLP_CATCH_ALL {
|
||||
this->_M_handle_exception(ios_base::badbit);
|
||||
}
|
||||
|
||||
if (__failed)
|
||||
this->setstate(ios_base::badbit);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
void basic_ostream<_CharT, _Traits>::_M_put_nowiden(const _CharT* __s) {
|
||||
sentry __sentry(*this);
|
||||
if (__sentry) {
|
||||
bool __failed = true;
|
||||
streamsize __n = _Traits::length(__s);
|
||||
streamsize __npad = this->width() > __n ? this->width() - __n : 0;
|
||||
|
||||
_STLP_TRY {
|
||||
if (__npad == 0)
|
||||
__failed = this->rdbuf()->sputn(__s, __n) != __n;
|
||||
else if ((this->flags() & ios_base::adjustfield) == ios_base::left) {
|
||||
__failed = this->rdbuf()->sputn(__s, __n) != __n;
|
||||
__failed = __failed ||
|
||||
this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad;
|
||||
}
|
||||
else {
|
||||
__failed = this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad;
|
||||
__failed = __failed || this->rdbuf()->sputn(__s, __n) != __n;
|
||||
}
|
||||
|
||||
this->width(0);
|
||||
}
|
||||
_STLP_CATCH_ALL {
|
||||
this->_M_handle_exception(ios_base::badbit);
|
||||
}
|
||||
|
||||
if (__failed)
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
void basic_ostream<_CharT, _Traits>::_M_put_widen(const char* __s) {
|
||||
sentry __sentry(*this);
|
||||
if (__sentry) {
|
||||
bool __failed = true;
|
||||
streamsize __n = char_traits<char>::length(__s);
|
||||
streamsize __npad = this->width() > __n ? this->width() - __n : 0;
|
||||
|
||||
_STLP_TRY {
|
||||
if (__npad == 0)
|
||||
__failed = !this->_M_put_widen_aux(__s, __n);
|
||||
else if ((this->flags() & ios_base::adjustfield) == ios_base::left) {
|
||||
__failed = !this->_M_put_widen_aux(__s, __n);
|
||||
__failed = __failed ||
|
||||
this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad;
|
||||
}
|
||||
else {
|
||||
__failed = this->rdbuf()->_M_sputnc(this->fill(), __npad) != __npad;
|
||||
__failed = __failed || !this->_M_put_widen_aux(__s, __n);
|
||||
}
|
||||
|
||||
this->width(0);
|
||||
}
|
||||
_STLP_CATCH_ALL {
|
||||
this->_M_handle_exception(ios_base::badbit);
|
||||
}
|
||||
|
||||
if (__failed)
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
bool basic_ostream<_CharT, _Traits>::_M_put_widen_aux(const char* __s,
|
||||
streamsize __n) {
|
||||
basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
|
||||
|
||||
for ( ; __n > 0 ; --__n)
|
||||
if (this->_S_eof(__buf->sputc(this->widen(*__s++))))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Unformatted output of a single character.
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
basic_ostream<_CharT, _Traits>::put(char_type __c) {
|
||||
sentry __sentry(*this);
|
||||
bool __failed = true;
|
||||
|
||||
if (__sentry) {
|
||||
_STLP_TRY {
|
||||
__failed = this->_S_eof(this->rdbuf()->sputc(__c));
|
||||
}
|
||||
_STLP_CATCH_ALL {
|
||||
this->_M_handle_exception(ios_base::badbit);
|
||||
}
|
||||
}
|
||||
|
||||
if (__failed)
|
||||
this->setstate(ios_base::badbit);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Unformatted output of a single character.
|
||||
template <class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n) {
|
||||
sentry __sentry(*this);
|
||||
bool __failed = true;
|
||||
|
||||
if (__sentry) {
|
||||
_STLP_TRY {
|
||||
__failed = this->rdbuf()->sputn(__s, __n) != __n;
|
||||
}
|
||||
_STLP_CATCH_ALL {
|
||||
this->_M_handle_exception(ios_base::badbit);
|
||||
}
|
||||
}
|
||||
|
||||
if (__failed)
|
||||
this->setstate(ios_base::badbit);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_OSTREAM_C */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
387
extern/STLport/5.2.1/stlport/stl/_ostream.h
vendored
Normal file
387
extern/STLport/5.2.1/stlport/stl/_ostream.h
vendored
Normal file
@@ -0,0 +1,387 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _STLP_INTERNAL_OSTREAM_H
|
||||
#define _STLP_INTERNAL_OSTREAM_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_IOS_H
|
||||
# include <stl/_ios.h> // For basic_ios<>. Includes <iosfwd>.
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
|
||||
# include <stl/_ostreambuf_iterator.h>
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT) && !defined (_STLP_INTERNAL_EXCEPTION)
|
||||
# include <stl/_exception.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
template <class _CharT, class _Traits>
|
||||
class _Osentry;
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
bool __init_bostr(basic_ostream<_CharT, _Traits>& __str);
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class basic_ostream<>
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
class basic_ostream : virtual public basic_ios<_CharT, _Traits> {
|
||||
typedef basic_ostream<_CharT, _Traits> _Self;
|
||||
|
||||
#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1300 && _STLP_MSVC <= 1310)
|
||||
//explicitely defined as private to avoid warnings:
|
||||
basic_ostream(_Self const&);
|
||||
_Self& operator = (_Self const&);
|
||||
#endif
|
||||
|
||||
public: // Types
|
||||
typedef _CharT char_type;
|
||||
typedef typename _Traits::int_type int_type;
|
||||
typedef typename _Traits::pos_type pos_type;
|
||||
typedef typename _Traits::off_type off_type;
|
||||
typedef _Traits traits_type;
|
||||
typedef basic_ios<_CharT, _Traits> _Basic_ios;
|
||||
|
||||
public: // Constructor and destructor.
|
||||
explicit basic_ostream(basic_streambuf<_CharT, _Traits>* __buf);
|
||||
~basic_ostream();
|
||||
|
||||
public: // Hooks for manipulators.
|
||||
typedef basic_ios<_CharT, _Traits>& (_STLP_CALL *__ios_fn)(basic_ios<_CharT, _Traits>&);
|
||||
typedef ios_base& (_STLP_CALL *__ios_base_fn)(ios_base&);
|
||||
typedef _Self& (_STLP_CALL *__ostream_fn)(_Self&);
|
||||
_Self& operator<< (__ostream_fn __f) { return __f(*this); }
|
||||
_Self & operator<< (__ios_base_fn __f) { __f(*this); return *this; }
|
||||
_Self& operator<< (__ios_fn __ff) { __ff(*this); return *this; }
|
||||
|
||||
private:
|
||||
bool _M_copy_buffered(basic_streambuf<_CharT, _Traits>* __from,
|
||||
basic_streambuf<_CharT, _Traits>* __to);
|
||||
bool _M_copy_unbuffered(basic_streambuf<_CharT, _Traits>* __from,
|
||||
basic_streambuf<_CharT, _Traits>* __to);
|
||||
|
||||
public:
|
||||
void _M_put_char(_CharT __c);
|
||||
|
||||
void _M_put_nowiden(const _CharT* __s);
|
||||
void _M_put_widen(const char* __s);
|
||||
bool _M_put_widen_aux(const char* __s, streamsize __n);
|
||||
|
||||
public: // Unformatted output.
|
||||
_Self& put(char_type __c);
|
||||
_Self& write(const char_type* __s, streamsize __n);
|
||||
|
||||
public: // Formatted output.
|
||||
// Formatted output from a streambuf.
|
||||
_Self& operator<<(basic_streambuf<_CharT, _Traits>* __buf);
|
||||
# ifndef _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
// this is needed for compiling with option char = unsigned
|
||||
_Self& operator<<(unsigned char __x) { _M_put_char(__x); return *this; }
|
||||
# endif
|
||||
_Self& operator<<(short __x);
|
||||
_Self& operator<<(unsigned short __x);
|
||||
_Self& operator<<(int __x);
|
||||
#if defined (_WIN64) || !defined (_STLP_MSVC) || (_STLP_MSVC < 1300)
|
||||
_Self& operator<<(unsigned int __x);
|
||||
#else
|
||||
/* We define this operator with size_t rather than unsigned int to avoid
|
||||
* 64 bits warning.
|
||||
*/
|
||||
_Self& operator<<(size_t __x);
|
||||
#endif
|
||||
_Self& operator<<(long __x);
|
||||
_Self& operator<<(unsigned long __x);
|
||||
#ifdef _STLP_LONG_LONG
|
||||
_Self& operator<< (_STLP_LONG_LONG __x);
|
||||
_Self& operator<< (unsigned _STLP_LONG_LONG __x);
|
||||
#endif
|
||||
_Self& operator<<(float __x);
|
||||
_Self& operator<<(double __x);
|
||||
# ifndef _STLP_NO_LONG_DOUBLE
|
||||
_Self& operator<<(long double __x);
|
||||
# endif
|
||||
_Self& operator<<(const void* __x);
|
||||
# ifndef _STLP_NO_BOOL
|
||||
_Self& operator<<(bool __x);
|
||||
# endif
|
||||
|
||||
public: // Buffer positioning and manipulation.
|
||||
_Self& flush() {
|
||||
if (this->rdbuf())
|
||||
if (this->rdbuf()->pubsync() == -1)
|
||||
this->setstate(ios_base::badbit);
|
||||
return *this;
|
||||
}
|
||||
|
||||
pos_type tellp() {
|
||||
return this->rdbuf() && !this->fail()
|
||||
? this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out)
|
||||
: pos_type(-1);
|
||||
}
|
||||
|
||||
_Self& seekp(pos_type __pos) {
|
||||
if (this->rdbuf() && !this->fail()) {
|
||||
if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1)) {
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& seekp(off_type __off, ios_base::seekdir __dir) {
|
||||
if (this->rdbuf() && !this->fail())
|
||||
this->rdbuf()->pubseekoff(__off, __dir, ios_base::out);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
// If we are using DLL specs, we have not to use inner classes
|
||||
// end class declaration here
|
||||
typedef _Osentry<_CharT, _Traits> sentry;
|
||||
};
|
||||
# define sentry _Osentry
|
||||
template <class _CharT, class _Traits>
|
||||
class _Osentry {
|
||||
typedef _Osentry<_CharT, _Traits> _Self;
|
||||
#else
|
||||
class sentry {
|
||||
typedef sentry _Self;
|
||||
#endif
|
||||
private:
|
||||
basic_ostream<_CharT, _Traits>& _M_str;
|
||||
// basic_streambuf<_CharT, _Traits>* _M_buf;
|
||||
bool _M_ok;
|
||||
public:
|
||||
explicit sentry(basic_ostream<_CharT, _Traits>& __str)
|
||||
: _M_str(__str), /* _M_buf(__str.rdbuf()), */ _M_ok(_STLP_PRIV __init_bostr(__str))
|
||||
{}
|
||||
|
||||
~sentry() {
|
||||
if (_M_str.flags() & ios_base::unitbuf)
|
||||
#if !defined (_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT)
|
||||
if (!uncaught_exception())
|
||||
#endif
|
||||
_M_str.flush();
|
||||
}
|
||||
|
||||
operator bool() const { return _M_ok; }
|
||||
private: // Disable assignment and copy constructor.
|
||||
//Implementation is here only to avoid warning with some compilers.
|
||||
sentry(const _Self& __s) : _M_str(__s._M_str) {}
|
||||
_Self& operator=(const _Self&) { return *this; }
|
||||
};
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
# undef sentry
|
||||
#else
|
||||
// close basic_ostream class definition here
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_ostream<char, char_traits<char> >;
|
||||
_STLP_EXPORT_TEMPLATE_CLASS _Osentry<char, char_traits<char> >;
|
||||
# if !defined (_STLP_NO_WCHAR_T)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_ostream<wchar_t, char_traits<wchar_t> >;
|
||||
_STLP_EXPORT_TEMPLATE_CLASS _Osentry<wchar_t, char_traits<wchar_t> >;
|
||||
# endif
|
||||
#endif /* _STLP_USE_TEMPLATE_EXPORT */
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
// Helper functions for istream<>::sentry constructor.
|
||||
template <class _CharT, class _Traits>
|
||||
bool __init_bostr(basic_ostream<_CharT, _Traits>& __str) {
|
||||
if (__str.good()) {
|
||||
// boris : check if this is needed !
|
||||
if (!__str.rdbuf())
|
||||
__str.setstate(ios_base::badbit);
|
||||
if (__str.tie())
|
||||
__str.tie()->flush();
|
||||
return __str.good();
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline basic_streambuf<_CharT, _Traits>* _STLP_CALL
|
||||
__get_ostreambuf(basic_ostream<_CharT, _Traits>& __St)
|
||||
{ return __St.rdbuf(); }
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
// Non-member functions.
|
||||
template <class _CharT, class _Traits>
|
||||
inline basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c){
|
||||
__os._M_put_char(__c);
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __s) {
|
||||
__os._M_put_nowiden(__s);
|
||||
return __os;
|
||||
}
|
||||
|
||||
#if defined (_STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
// some specializations
|
||||
|
||||
inline basic_ostream<char, char_traits<char> >& _STLP_CALL
|
||||
operator<<(basic_ostream<char, char_traits<char> >& __os, char __c) {
|
||||
__os._M_put_char(__c);
|
||||
return __os;
|
||||
}
|
||||
|
||||
inline basic_ostream<char, char_traits<char> >& _STLP_CALL
|
||||
operator<<(basic_ostream<char, char_traits<char> >& __os, signed char __c) {
|
||||
__os._M_put_char(__c);
|
||||
return __os;
|
||||
}
|
||||
|
||||
inline basic_ostream<char, char_traits<char> >& _STLP_CALL
|
||||
operator<<(basic_ostream<char, char_traits<char> >& __os, unsigned char __c) {
|
||||
__os._M_put_char(__c);
|
||||
return __os;
|
||||
}
|
||||
|
||||
inline basic_ostream<char, char_traits<char> >& _STLP_CALL
|
||||
operator<<(basic_ostream<char, char_traits<char> >& __os, const char* __s) {
|
||||
__os._M_put_nowiden(__s);
|
||||
return __os;
|
||||
}
|
||||
|
||||
inline basic_ostream<char, char_traits<char> >& _STLP_CALL
|
||||
operator<<(basic_ostream<char, char_traits<char> >& __os, const signed char* __s) {
|
||||
__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
|
||||
return __os;
|
||||
}
|
||||
|
||||
inline basic_ostream<char, char_traits<char> >&
|
||||
operator<<(basic_ostream<char, char_traits<char> >& __os, const unsigned char* __s) {
|
||||
__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
|
||||
return __os;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// also for compilers who might use that
|
||||
template <class _CharT, class _Traits>
|
||||
inline basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, char __c) {
|
||||
__os._M_put_char(__os.widen(__c));
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _Traits>
|
||||
inline basic_ostream<char, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<char, _Traits>& __os, char __c) {
|
||||
__os._M_put_char(__c);
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _Traits>
|
||||
inline basic_ostream<char, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<char, _Traits>& __os, signed char __c) {
|
||||
__os._M_put_char(__c);
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _Traits>
|
||||
inline basic_ostream<char, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c) {
|
||||
__os._M_put_char(__c);
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __s) {
|
||||
__os._M_put_widen(__s);
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _Traits>
|
||||
inline basic_ostream<char, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<char, _Traits>& __os, const char* __s) {
|
||||
__os._M_put_nowiden(__s);
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _Traits>
|
||||
inline basic_ostream<char, _Traits>& _STLP_CALL
|
||||
operator<<(basic_ostream<char, _Traits>& __os, const signed char* __s) {
|
||||
__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _Traits>
|
||||
inline basic_ostream<char, _Traits>&
|
||||
operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __s) {
|
||||
__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
|
||||
return __os;
|
||||
}
|
||||
#endif /* _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// basic_ostream manipulators.
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
endl(basic_ostream<_CharT, _Traits>& __os) {
|
||||
__os.put(__os.widen('\n'));
|
||||
__os.flush();
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
ends(basic_ostream<_CharT, _Traits>& __os) {
|
||||
__os.put(_STLP_DEFAULT_CONSTRUCTED(_CharT));
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline basic_ostream<_CharT, _Traits>& _STLP_CALL
|
||||
flush(basic_ostream<_CharT, _Traits>& __os) {
|
||||
__os.flush();
|
||||
return __os;
|
||||
}
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/_ostream.c>
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_OSTREAM_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
102
extern/STLport/5.2.1/stlport/stl/_ostreambuf_iterator.h
vendored
Normal file
102
extern/STLport/5.2.1/stlport/stl/_ostreambuf_iterator.h
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
// WARNING: This is an internal header file, included by other C++
|
||||
// standard library headers. You should not attempt to use this header
|
||||
// file directly.
|
||||
|
||||
|
||||
#ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
|
||||
#define _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_STREAMBUF
|
||||
# include <stl/_streambuf.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
extern basic_streambuf<_CharT, _Traits>* _STLP_CALL __get_ostreambuf(basic_ostream<_CharT, _Traits>&);
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
// The default template argument is declared in iosfwd
|
||||
template <class _CharT, class _Traits>
|
||||
class ostreambuf_iterator :
|
||||
public iterator<output_iterator_tag, void, void, void, void> {
|
||||
public:
|
||||
typedef _CharT char_type;
|
||||
typedef _Traits traits_type;
|
||||
typedef typename _Traits::int_type int_type;
|
||||
typedef basic_streambuf<_CharT, _Traits> streambuf_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:
|
||||
ostreambuf_iterator(streambuf_type* __buf) _STLP_NOTHROW : _M_buf(__buf), _M_ok(__buf!=0) {}
|
||||
// ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW : _M_buf(__get_ostreambuf(__o)), _M_ok(_M_buf != 0) {}
|
||||
inline ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW;
|
||||
|
||||
ostreambuf_iterator<_CharT, _Traits>& operator=(char_type __c) {
|
||||
_M_ok = _M_ok && !traits_type::eq_int_type(_M_buf->sputc(__c),
|
||||
traits_type::eof());
|
||||
return *this;
|
||||
}
|
||||
|
||||
ostreambuf_iterator<_CharT, _Traits>& operator*() { return *this; }
|
||||
ostreambuf_iterator<_CharT, _Traits>& operator++() { return *this; }
|
||||
ostreambuf_iterator<_CharT, _Traits>& operator++(int) { return *this; }
|
||||
|
||||
bool failed() const { return !_M_ok; }
|
||||
|
||||
private:
|
||||
streambuf_type* _M_buf;
|
||||
bool _M_ok;
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline ostreambuf_iterator<_CharT, _Traits>::ostreambuf_iterator(basic_ostream<_CharT, _Traits>& __o) _STLP_NOTHROW
|
||||
: _M_buf(_STLP_PRIV __get_ostreambuf(__o)), _M_ok(_M_buf != 0) {}
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS ostreambuf_iterator<char, char_traits<char> >;
|
||||
# if defined (INSTANTIATE_WIDE_STREAMS)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS ostreambuf_iterator<wchar_t, char_traits<wchar_t> >;
|
||||
# endif
|
||||
#endif /* _STLP_USE_TEMPLATE_EXPORT */
|
||||
|
||||
#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
|
||||
template <class _CharT, class _Traits>
|
||||
inline output_iterator_tag _STLP_CALL
|
||||
iterator_category(const ostreambuf_iterator<_CharT, _Traits>&) { return output_iterator_tag(); }
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
182
extern/STLport/5.2.1/stlport/stl/_pair.h
vendored
Normal file
182
extern/STLport/5.2.1/stlport/stl/_pair.h
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_PAIR_H
|
||||
#define _STLP_INTERNAL_PAIR_H
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
# ifndef _STLP_TYPE_TRAITS_H
|
||||
# include <stl/type_traits.h>
|
||||
# endif
|
||||
|
||||
# if !defined (_STLP_MOVE_CONSTRUCT_FWK_H) && !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
# include <stl/_move_construct_fwk.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _T1, class _T2>
|
||||
struct pair {
|
||||
typedef _T1 first_type;
|
||||
typedef _T2 second_type;
|
||||
|
||||
_T1 first;
|
||||
_T2 second;
|
||||
#if defined (_STLP_CONST_CONSTRUCTOR_BUG)
|
||||
pair() {}
|
||||
#else
|
||||
pair() : first(_T1()), second(_T2()) {}
|
||||
#endif
|
||||
pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _U1, class _U2>
|
||||
pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
|
||||
|
||||
pair(const pair<_T1,_T2>& __o) : first(__o.first), second(__o.second) {}
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
pair(__move_source<pair<_T1, _T2> > src) : first(_STLP_PRIV _AsMoveSource(src.get().first)),
|
||||
second(_STLP_PRIV _AsMoveSource(src.get().second))
|
||||
{}
|
||||
#endif
|
||||
|
||||
__TRIVIAL_DESTRUCTOR(pair)
|
||||
};
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline bool _STLP_CALL operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
|
||||
{ return __x.first == __y.first && __x.second == __y.second; }
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline bool _STLP_CALL operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
|
||||
return __x.first < __y.first ||
|
||||
(!(__y.first < __x.first) && __x.second < __y.second);
|
||||
}
|
||||
|
||||
#if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
|
||||
template <class _T1, class _T2>
|
||||
inline bool _STLP_CALL operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
|
||||
{ return !(__x == __y); }
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline bool _STLP_CALL operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
|
||||
{ return __y < __x; }
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline bool _STLP_CALL operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
|
||||
{ return !(__y < __x); }
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline bool _STLP_CALL operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
|
||||
{ return !(__x < __y); }
|
||||
#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
|
||||
|
||||
#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) && !defined (_STLP_NO_EXTENSIONS)
|
||||
template <class _T1, class _T2, int _Sz>
|
||||
inline pair<_T1, _T2 const*> make_pair(_T1 const& __x,
|
||||
_T2 const (&__y)[_Sz])
|
||||
{ return pair<_T1, _T2 const*>(__x, static_cast<_T2 const*>(__y)); }
|
||||
|
||||
template <class _T1, class _T2, int _Sz>
|
||||
inline pair<_T1 const*, _T2> make_pair(_T1 const (&__x)[_Sz],
|
||||
_T2 const& __y)
|
||||
{ return pair<_T1 const*, _T2>(static_cast<_T1 const*>(__x), __y); }
|
||||
|
||||
template <class _T1, class _T2, int _Sz1, int _Sz2>
|
||||
inline pair<_T1 const*, _T2 const*> make_pair(_T1 const (&__x)[_Sz1],
|
||||
_T2 const (&__y)[_Sz2]) {
|
||||
return pair<_T1 const*, _T2 const*>(static_cast<_T1 const*>(__x),
|
||||
static_cast<_T2 const*>(__y));
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline pair<_T1, _T2> _STLP_CALL make_pair(_T1 __x, _T2 __y)
|
||||
{ return pair<_T1, _T2>(__x, __y); }
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if defined (_STLP_USE_NAMESPACES) || !defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
|
||||
_STLP_BEGIN_RELOPS_NAMESPACE
|
||||
|
||||
template <class _Tp>
|
||||
inline bool _STLP_CALL operator!=(const _Tp& __x, const _Tp& __y)
|
||||
{ return !(__x == __y); }
|
||||
|
||||
template <class _Tp>
|
||||
inline bool _STLP_CALL operator>(const _Tp& __x, const _Tp& __y)
|
||||
{ return __y < __x; }
|
||||
|
||||
template <class _Tp>
|
||||
inline bool _STLP_CALL operator<=(const _Tp& __x, const _Tp& __y)
|
||||
{ return !(__y < __x); }
|
||||
|
||||
template <class _Tp>
|
||||
inline bool _STLP_CALL operator>=(const _Tp& __x, const _Tp& __y)
|
||||
{ return !(__x < __y); }
|
||||
|
||||
_STLP_END_RELOPS_NAMESPACE
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _T1, class _T2>
|
||||
struct __type_traits<pair<_T1, _T2> > {
|
||||
typedef __type_traits<_T1> _T1Traits;
|
||||
typedef __type_traits<_T2> _T2Traits;
|
||||
typedef typename _Land2<typename _T1Traits::has_trivial_default_constructor,
|
||||
typename _T2Traits::has_trivial_default_constructor>::_Ret has_trivial_default_constructor;
|
||||
typedef typename _Land2<typename _T1Traits::has_trivial_copy_constructor,
|
||||
typename _T2Traits::has_trivial_copy_constructor>::_Ret has_trivial_copy_constructor;
|
||||
typedef typename _Land2<typename _T1Traits::has_trivial_assignment_operator,
|
||||
typename _T2Traits::has_trivial_assignment_operator>::_Ret has_trivial_assignment_operator;
|
||||
typedef typename _Land2<typename _T1Traits::has_trivial_destructor,
|
||||
typename _T2Traits::has_trivial_destructor>::_Ret has_trivial_destructor;
|
||||
typedef __false_type is_POD_type;
|
||||
};
|
||||
|
||||
# if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
template <class _T1, class _T2>
|
||||
struct __move_traits<pair<_T1, _T2> >
|
||||
: _STLP_PRIV __move_traits_help1<_T1, _T2> {};
|
||||
# endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_INTERNAL_PAIR_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
18
extern/STLport/5.2.1/stlport/stl/_prolog.h
vendored
Normal file
18
extern/STLport/5.2.1/stlport/stl/_prolog.h
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/* NOTE : this header has no guards and is MEANT for multiple inclusion!
|
||||
* If you are using "header protection" option with your compiler,
|
||||
* please also find #pragma which disables it and put it here, to
|
||||
* allow reentrancy of this header.
|
||||
*/
|
||||
|
||||
#include <stl/_cprolog.h>
|
||||
|
||||
/* Get all debug things, potentially only empty macros if none of
|
||||
* the debug features available in user config file is activated. */
|
||||
/* Thanks to _STLP_OUTERMOST_HEADER_ID we hide _debug.h when C standard
|
||||
* headers are included as some platforms (Win32) include C standard headers
|
||||
* in an 'extern "C"' scope which do not accept the templates exposed
|
||||
* in _debug.h. */
|
||||
#if defined (__cplusplus) && !defined (_STLP_DEBUG_H) && \
|
||||
!((_STLP_OUTERMOST_HEADER_ID >= 0x200) && (_STLP_OUTERMOST_HEADER_ID <= 0x300))
|
||||
# include <stl/debug/_debug.h>
|
||||
#endif
|
||||
461
extern/STLport/5.2.1/stlport/stl/_pthread_alloc.h
vendored
Normal file
461
extern/STLport/5.2.1/stlport/stl/_pthread_alloc.h
vendored
Normal file
@@ -0,0 +1,461 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_PTHREAD_ALLOC_H
|
||||
#define _STLP_PTHREAD_ALLOC_H
|
||||
|
||||
/*
|
||||
* Pthread-specific node allocator.
|
||||
* This is similar to the default allocator, except that free-list
|
||||
* information is kept separately for each thread, avoiding locking.
|
||||
* This should be reasonably fast even in the presence of threads.
|
||||
* The down side is that storage may not be well-utilized.
|
||||
* It is not an error to allocate memory in thread A and deallocate
|
||||
* it in thread B. But this effectively transfers ownership of the memory,
|
||||
* so that it can only be reallocated by thread B. Thus this can effectively
|
||||
* result in a storage leak if it's done on a regular basis.
|
||||
* It can also result in frequent sharing of
|
||||
* cache lines among processors, with potentially serious performance
|
||||
* consequences.
|
||||
*/
|
||||
|
||||
#if !defined (_STLP_PTHREADS)
|
||||
# error POSIX specific allocator implementation. Your system do not seems to \
|
||||
have this interface so please comment the _STLP_USE_PERTHREAD_ALLOC macro \
|
||||
or report to the STLport forum.
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_USE_NO_IOSTREAMS)
|
||||
# error You cannot use per thread allocator implementation without building \
|
||||
STLport libraries.
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALLOC_H
|
||||
# include <stl/_alloc.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
struct _Pthread_alloc_per_thread_state;
|
||||
|
||||
// Pthread-specific allocator.
|
||||
class _STLP_CLASS_DECLSPEC _Pthread_alloc {
|
||||
public: // but only for internal use:
|
||||
typedef _Pthread_alloc_per_thread_state __state_type;
|
||||
typedef char value_type;
|
||||
|
||||
public:
|
||||
// Return a recycled or new per thread state.
|
||||
static __state_type * _STLP_CALL _S_get_per_thread_state();
|
||||
|
||||
/* n must be > 0 */
|
||||
static void * _STLP_CALL allocate(size_t& __n);
|
||||
|
||||
/* p may not be 0 */
|
||||
static void _STLP_CALL deallocate(void *__p, size_t __n);
|
||||
|
||||
// boris : versions for per_thread_allocator
|
||||
/* n must be > 0 */
|
||||
static void * _STLP_CALL allocate(size_t& __n, __state_type* __a);
|
||||
|
||||
/* p may not be 0 */
|
||||
static void _STLP_CALL deallocate(void *__p, size_t __n, __state_type* __a);
|
||||
|
||||
static void * _STLP_CALL reallocate(void *__p, size_t __old_sz, size_t& __new_sz);
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
typedef _STLP_PRIV _Pthread_alloc __pthread_alloc;
|
||||
typedef __pthread_alloc pthread_alloc;
|
||||
|
||||
template <class _Tp>
|
||||
class pthread_allocator : public __stlport_class<pthread_allocator<_Tp> > {
|
||||
typedef pthread_alloc _S_Alloc; // The underlying allocator.
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Tp value_type;
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATE_CLASSES
|
||||
template <class _NewType> struct rebind {
|
||||
typedef pthread_allocator<_NewType> other;
|
||||
};
|
||||
#endif
|
||||
|
||||
pthread_allocator() _STLP_NOTHROW {}
|
||||
pthread_allocator(const pthread_allocator<_Tp>& a) _STLP_NOTHROW {}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES) /* && defined (_STLP_FUNCTION_PARTIAL_ORDER) */
|
||||
template <class _OtherType> pthread_allocator(const pthread_allocator<_OtherType>&)
|
||||
_STLP_NOTHROW {}
|
||||
#endif
|
||||
|
||||
~pthread_allocator() _STLP_NOTHROW {}
|
||||
|
||||
pointer address(reference __x) const { return &__x; }
|
||||
const_pointer address(const_reference __x) const { return &__x; }
|
||||
|
||||
// __n is permitted to be 0. The C++ standard says nothing about what
|
||||
// the return value is when __n == 0.
|
||||
_Tp* allocate(size_type __n, const void* = 0) {
|
||||
if (__n > max_size()) {
|
||||
_STLP_THROW_BAD_ALLOC;
|
||||
}
|
||||
if (__n != 0) {
|
||||
size_type __buf_size = __n * sizeof(value_type);
|
||||
_Tp* __ret = __REINTERPRET_CAST(value_type*, _S_Alloc::allocate(__buf_size));
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC)
|
||||
memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size);
|
||||
#endif
|
||||
return __ret;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void deallocate(pointer __p, size_type __n) {
|
||||
_STLP_ASSERT( (__p == 0) == (__n == 0) )
|
||||
if (__p != 0) {
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC)
|
||||
memset((char*)__p, _STLP_SHRED_BYTE, __n * sizeof(value_type));
|
||||
#endif
|
||||
_S_Alloc::deallocate(__p, __n * sizeof(value_type));
|
||||
}
|
||||
}
|
||||
|
||||
size_type max_size() const _STLP_NOTHROW
|
||||
{ return size_t(-1) / sizeof(_Tp); }
|
||||
|
||||
void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); }
|
||||
void destroy(pointer _p) { _p->~_Tp(); }
|
||||
|
||||
#if defined (_STLP_NO_EXTENSIONS)
|
||||
/* STLport extension giving rounded size of an allocated memory buffer
|
||||
* This method do not have to be part of a user defined allocator implementation
|
||||
* and won't even be called if such a function was granted.
|
||||
*/
|
||||
protected:
|
||||
#endif
|
||||
_Tp* allocate(size_type __n, size_type& __allocated_n) {
|
||||
if (__n > max_size()) {
|
||||
_STLP_THROW_BAD_ALLOC;
|
||||
}
|
||||
if (__n != 0) {
|
||||
size_type __buf_size = __n * sizeof(value_type);
|
||||
_Tp* __ret = __REINTERPRET_CAST(value_type*, _S_Alloc::allocate(__buf_size));
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC)
|
||||
memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size);
|
||||
#endif
|
||||
__allocated_n = __buf_size / sizeof(value_type);
|
||||
return __ret;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(pthread_allocator<_Tp>& __x) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC pthread_allocator<void> {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef void* pointer;
|
||||
typedef const void* const_pointer;
|
||||
typedef void value_type;
|
||||
#ifdef _STLP_MEMBER_TEMPLATE_CLASSES
|
||||
template <class _NewType> struct rebind {
|
||||
typedef pthread_allocator<_NewType> other;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline bool operator==(const pthread_allocator<_T1>&,
|
||||
const pthread_allocator<_T2>& a2)
|
||||
{ return true; }
|
||||
|
||||
#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
template <class _T1, class _T2>
|
||||
inline bool operator!=(const pthread_allocator<_T1>&,
|
||||
const pthread_allocator<_T2>&)
|
||||
{ return false; }
|
||||
#endif
|
||||
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
|
||||
template <class _Tp, class _Atype>
|
||||
struct _Alloc_traits<_Tp, pthread_allocator<_Atype> >
|
||||
{ typedef pthread_allocator<_Tp> allocator_type; };
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE)
|
||||
|
||||
template <class _Tp1, class _Tp2>
|
||||
inline pthread_allocator<_Tp2>&
|
||||
__stl_alloc_rebind(pthread_allocator<_Tp1>& __x, const _Tp2*)
|
||||
{ return (pthread_allocator<_Tp2>&)__x; }
|
||||
|
||||
template <class _Tp1, class _Tp2>
|
||||
inline pthread_allocator<_Tp2>
|
||||
__stl_alloc_create(pthread_allocator<_Tp1>&, const _Tp2*)
|
||||
{ return pthread_allocator<_Tp2>(); }
|
||||
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Tp>
|
||||
struct __pthread_alloc_type_traits {
|
||||
typedef typename _IsSTLportClass<pthread_allocator<_Tp> >::_Ret _STLportAlloc;
|
||||
//The default allocator implementation which is recognize thanks to the
|
||||
//__stlport_class inheritance is a stateless object so:
|
||||
typedef _STLportAlloc has_trivial_default_constructor;
|
||||
typedef _STLportAlloc has_trivial_copy_constructor;
|
||||
typedef _STLportAlloc has_trivial_assignment_operator;
|
||||
typedef _STLportAlloc has_trivial_destructor;
|
||||
typedef _STLportAlloc is_POD_type;
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
template <class _Tp>
|
||||
struct __type_traits<pthread_allocator<_Tp> > : _STLP_PRIV __pthread_alloc_type_traits<_Tp> {};
|
||||
#else
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct __type_traits<pthread_allocator<char> > : _STLP_PRIV __pthread_alloc_type_traits<char> {};
|
||||
# if defined (_STLP_HAS_WCHAR_T)
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct __type_traits<pthread_allocator<wchar_t> > : _STLP_PRIV __pthread_alloc_type_traits<wchar_t> {};
|
||||
# endif
|
||||
# if defined (_STLP_USE_PTR_SPECIALIZATIONS)
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct __type_traits<pthread_allocator<void*> > : _STLP_PRIV __pthread_alloc_type_traits<void*> {};
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// per_thread_allocator<> : this allocator always return memory to the same thread
|
||||
// it was allocated from.
|
||||
//
|
||||
|
||||
template <class _Tp>
|
||||
class per_thread_allocator {
|
||||
typedef pthread_alloc _S_Alloc; // The underlying allocator.
|
||||
typedef pthread_alloc::__state_type __state_type;
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Tp value_type;
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATE_CLASSES
|
||||
template <class _NewType> struct rebind {
|
||||
typedef per_thread_allocator<_NewType> other;
|
||||
};
|
||||
#endif
|
||||
|
||||
per_thread_allocator() _STLP_NOTHROW {
|
||||
_M_state = _S_Alloc::_S_get_per_thread_state();
|
||||
}
|
||||
per_thread_allocator(const per_thread_allocator<_Tp>& __a) _STLP_NOTHROW : _M_state(__a._M_state){}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES) /* && defined (_STLP_FUNCTION_PARTIAL_ORDER) */
|
||||
template <class _OtherType> per_thread_allocator(const per_thread_allocator<_OtherType>& __a)
|
||||
_STLP_NOTHROW : _M_state(__a._M_state) {}
|
||||
#endif
|
||||
|
||||
~per_thread_allocator() _STLP_NOTHROW {}
|
||||
|
||||
pointer address(reference __x) const { return &__x; }
|
||||
const_pointer address(const_reference __x) const { return &__x; }
|
||||
|
||||
// __n is permitted to be 0. The C++ standard says nothing about what
|
||||
// the return value is when __n == 0.
|
||||
_Tp* allocate(size_type __n, const void* = 0) {
|
||||
if (__n > max_size()) {
|
||||
_STLP_THROW_BAD_ALLOC;
|
||||
}
|
||||
if (__n != 0) {
|
||||
size_type __buf_size = __n * sizeof(value_type);
|
||||
_Tp* __ret = __REINTERPRET_CAST(_Tp*, _S_Alloc::allocate(__buf_size, _M_state));
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC)
|
||||
memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size);
|
||||
#endif
|
||||
return __ret;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void deallocate(pointer __p, size_type __n) {
|
||||
_STLP_ASSERT( (__p == 0) == (__n == 0) )
|
||||
if (__p != 0) {
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC)
|
||||
memset((char*)__p, _STLP_SHRED_BYTE, __n * sizeof(value_type));
|
||||
#endif
|
||||
_S_Alloc::deallocate(__p, __n * sizeof(value_type), _M_state);
|
||||
}
|
||||
}
|
||||
|
||||
size_type max_size() const _STLP_NOTHROW
|
||||
{ return size_t(-1) / sizeof(_Tp); }
|
||||
|
||||
void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); }
|
||||
void destroy(pointer _p) { _p->~_Tp(); }
|
||||
|
||||
// state is being kept here
|
||||
__state_type* _M_state;
|
||||
|
||||
#if defined (_STLP_NO_EXTENSIONS)
|
||||
/* STLport extension giving rounded size of an allocated memory buffer
|
||||
* This method do not have to be part of a user defined allocator implementation
|
||||
* and won't even be called if such a function was granted.
|
||||
*/
|
||||
protected:
|
||||
#endif
|
||||
_Tp* allocate(size_type __n, size_type& __allocated_n) {
|
||||
if (__n > max_size()) {
|
||||
_STLP_THROW_BAD_ALLOC;
|
||||
}
|
||||
if (__n != 0) {
|
||||
size_type __buf_size = __n * sizeof(value_type);
|
||||
_Tp* __ret = __REINTERPRET_CAST(value_type*, _S_Alloc::allocate(__buf_size, _M_state));
|
||||
#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC)
|
||||
memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size);
|
||||
#endif
|
||||
__allocated_n = __buf_size / sizeof(value_type);
|
||||
return __ret;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
class _STLP_CLASS_DECLSPEC per_thread_allocator<void> {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef void* pointer;
|
||||
typedef const void* const_pointer;
|
||||
typedef void value_type;
|
||||
#ifdef _STLP_MEMBER_TEMPLATE_CLASSES
|
||||
template <class _NewType> struct rebind {
|
||||
typedef per_thread_allocator<_NewType> other;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline bool operator==(const per_thread_allocator<_T1>& __a1,
|
||||
const per_thread_allocator<_T2>& __a2)
|
||||
{ return __a1._M_state == __a2._M_state; }
|
||||
|
||||
#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
template <class _T1, class _T2>
|
||||
inline bool operator!=(const per_thread_allocator<_T1>& __a1,
|
||||
const per_thread_allocator<_T2>& __a2)
|
||||
{ return __a1._M_state != __a2._M_state; }
|
||||
#endif
|
||||
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
|
||||
template <class _Tp, class _Atype>
|
||||
struct _Alloc_traits<_Tp, per_thread_allocator<_Atype> >
|
||||
{ typedef per_thread_allocator<_Tp> allocator_type; };
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE)
|
||||
|
||||
template <class _Tp1, class _Tp2>
|
||||
inline per_thread_allocator<_Tp2>&
|
||||
__stl_alloc_rebind(per_thread_allocator<_Tp1>& __x, const _Tp2*)
|
||||
{ return (per_thread_allocator<_Tp2>&)__x; }
|
||||
|
||||
template <class _Tp1, class _Tp2>
|
||||
inline per_thread_allocator<_Tp2>
|
||||
__stl_alloc_create(per_thread_allocator<_Tp1>&, const _Tp2*)
|
||||
{ return per_thread_allocator<_Tp2>(); }
|
||||
|
||||
#endif /* _STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE */
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Tp>
|
||||
struct __perthread_alloc_type_traits {
|
||||
typedef typename _IsSTLportClass<per_thread_allocator<_Tp> >::_Ret _STLportAlloc;
|
||||
//The default allocator implementation which is recognize thanks to the
|
||||
//__stlport_class inheritance is a stateless object so:
|
||||
typedef __false_type has_trivial_default_constructor;
|
||||
typedef _STLportAlloc has_trivial_copy_constructor;
|
||||
typedef _STLportAlloc has_trivial_assignment_operator;
|
||||
typedef _STLportAlloc has_trivial_destructor;
|
||||
typedef __false_type is_POD_type;
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
|
||||
template <class _Tp>
|
||||
struct __type_traits<per_thread_allocator<_Tp> > : _STLP_PRIV __perthread_alloc_type_traits<_Tp> {};
|
||||
#else
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct __type_traits<per_thread_allocator<char> > : _STLP_PRIV __perthread_alloc_type_traits<char> {};
|
||||
# if defined (_STLP_HAS_WCHAR_T)
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct __type_traits<per_thread_allocator<wchar_t> > : _STLP_PRIV __perthread_alloc_type_traits<wchar_t> {};
|
||||
# endif
|
||||
# if defined (_STLP_USE_PTR_SPECIALIZATIONS)
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct __type_traits<per_thread_allocator<void*> > : _STLP_PRIV __perthread_alloc_type_traits<void*> {};
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_PTHREAD_ALLOC */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
83
extern/STLport/5.2.1/stlport/stl/_ptrs_specialize.h
vendored
Normal file
83
extern/STLport/5.2.1/stlport/stl/_ptrs_specialize.h
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
#ifndef _STLP_PTRS_SPECIALIZE_H
|
||||
#define _STLP_PTRS_SPECIALIZE_H
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) || \
|
||||
(defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) && !defined (_STLP_NO_ARROW_OPERATOR))
|
||||
# define _STLP_POINTERS_SPECIALIZE( _TpP )
|
||||
# define _STLP_DEFINE_ARROW_OPERATOR pointer operator->() const { return &(operator*()); }
|
||||
#else
|
||||
# ifndef _STLP_TYPE_TRAITS_H
|
||||
# include <stl/type_traits.h>
|
||||
# endif
|
||||
|
||||
// the following is a workaround for arrow operator problems
|
||||
# if defined ( _STLP_NO_ARROW_OPERATOR )
|
||||
// User wants to disable proxy -> operators
|
||||
# define _STLP_DEFINE_ARROW_OPERATOR
|
||||
# else
|
||||
// Compiler can handle generic -> operator.
|
||||
# if defined (__BORLANDC__)
|
||||
# define _STLP_DEFINE_ARROW_OPERATOR pointer operator->() const { return &(*(*this)); }
|
||||
# elif defined(__WATCOMC__)
|
||||
# define _STLP_DEFINE_ARROW_OPERATOR pointer operator->() const { reference x = operator*(); return &x; }
|
||||
# else
|
||||
# define _STLP_DEFINE_ARROW_OPERATOR pointer operator->() const { return &(operator*()); }
|
||||
# endif
|
||||
# endif /* _STLP_NO_ARROW_OPERATOR */
|
||||
|
||||
// Important pointers specializations
|
||||
|
||||
# ifdef _STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS
|
||||
# define _STLP_TYPE_TRAITS_POD_SPECIALIZE_V(_Type)
|
||||
# define _STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type)
|
||||
# else
|
||||
# define _STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type) _STLP_TEMPLATE_NULL struct __type_traits<_Type> : __type_traits_aux<__true_type> {};
|
||||
# define _STLP_TYPE_TRAITS_POD_SPECIALIZE_V(_Type) \
|
||||
_STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type*) \
|
||||
_STLP_TYPE_TRAITS_POD_SPECIALIZE(const _Type*) \
|
||||
_STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type**) \
|
||||
_STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type* const *) \
|
||||
_STLP_TYPE_TRAITS_POD_SPECIALIZE(const _Type**) \
|
||||
_STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type***) \
|
||||
_STLP_TYPE_TRAITS_POD_SPECIALIZE(const _Type***)
|
||||
# endif
|
||||
|
||||
# define _STLP_POINTERS_SPECIALIZE(_Type) _STLP_TYPE_TRAITS_POD_SPECIALIZE_V(_Type)
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
# if !defined ( _STLP_NO_BOOL )
|
||||
_STLP_POINTERS_SPECIALIZE( bool )
|
||||
# endif
|
||||
_STLP_TYPE_TRAITS_POD_SPECIALIZE_V(void)
|
||||
# ifndef _STLP_NO_SIGNED_BUILTINS
|
||||
_STLP_POINTERS_SPECIALIZE( signed char )
|
||||
# endif
|
||||
_STLP_POINTERS_SPECIALIZE( char )
|
||||
_STLP_POINTERS_SPECIALIZE( unsigned char )
|
||||
_STLP_POINTERS_SPECIALIZE( short )
|
||||
_STLP_POINTERS_SPECIALIZE( unsigned short )
|
||||
_STLP_POINTERS_SPECIALIZE( int )
|
||||
_STLP_POINTERS_SPECIALIZE( unsigned int )
|
||||
_STLP_POINTERS_SPECIALIZE( long )
|
||||
_STLP_POINTERS_SPECIALIZE( unsigned long )
|
||||
_STLP_POINTERS_SPECIALIZE( float )
|
||||
_STLP_POINTERS_SPECIALIZE( double )
|
||||
# if !defined ( _STLP_NO_LONG_DOUBLE )
|
||||
_STLP_POINTERS_SPECIALIZE( long double )
|
||||
# endif
|
||||
# if defined ( _STLP_LONG_LONG)
|
||||
_STLP_POINTERS_SPECIALIZE( _STLP_LONG_LONG )
|
||||
_STLP_POINTERS_SPECIALIZE( unsigned _STLP_LONG_LONG )
|
||||
# endif
|
||||
# if defined ( _STLP_HAS_WCHAR_T ) && ! defined (_STLP_WCHAR_T_IS_USHORT)
|
||||
_STLP_POINTERS_SPECIALIZE( wchar_t )
|
||||
# endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# undef _STLP_ARROW_SPECIALIZE
|
||||
# undef _STLP_TYPE_TRAITS_POD_SPECIALIZE_V
|
||||
|
||||
#endif
|
||||
#endif
|
||||
268
extern/STLport/5.2.1/stlport/stl/_queue.h
vendored
Normal file
268
extern/STLport/5.2.1/stlport/stl/_queue.h
vendored
Normal file
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_QUEUE_H
|
||||
#define _STLP_INTERNAL_QUEUE_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_DEQUE_H
|
||||
# include <stl/_deque.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_VECTOR_H
|
||||
# include <stl/_vector.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_HEAP_H
|
||||
# include <stl/_heap.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
|
||||
# include <stl/_function_base.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
# if ! defined ( _STLP_LIMITED_DEFAULT_TEMPLATES )
|
||||
template <class _Tp, class _Sequence = deque<_Tp> >
|
||||
# elif defined ( _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS )
|
||||
# define _STLP_QUEUE_ARGS _Tp
|
||||
template <class _Tp>
|
||||
# else
|
||||
template <class _Tp, class _Sequence>
|
||||
# endif
|
||||
class queue
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
||||
# if defined (_STLP_QUEUE_ARGS)
|
||||
: public __stlport_class<queue<_Tp> >
|
||||
# else
|
||||
: public __stlport_class<queue<_Tp, _Sequence> >
|
||||
# endif
|
||||
#endif
|
||||
{
|
||||
# if defined ( _STLP_QUEUE_ARGS )
|
||||
typedef deque<_Tp> _Sequence;
|
||||
typedef queue<_Tp> _Self;
|
||||
# else
|
||||
typedef queue<_Tp, _Sequence> _Self;
|
||||
# endif
|
||||
public:
|
||||
typedef typename _Sequence::value_type value_type;
|
||||
typedef typename _Sequence::size_type size_type;
|
||||
typedef _Sequence container_type;
|
||||
|
||||
typedef typename _Sequence::reference reference;
|
||||
typedef typename _Sequence::const_reference const_reference;
|
||||
|
||||
protected:
|
||||
//c is a Standard name (23.2.3.1), do no make it STLport naming convention compliant.
|
||||
_Sequence c;
|
||||
public:
|
||||
queue() : c() {}
|
||||
explicit queue(const _Sequence& __c) : c(__c) {}
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
queue(__move_source<_Self> src)
|
||||
: c(_STLP_PRIV _AsMoveSource(src.get().c)) {}
|
||||
#endif
|
||||
|
||||
bool empty() const { return c.empty(); }
|
||||
size_type size() const { return c.size(); }
|
||||
reference front() { return c.front(); }
|
||||
const_reference front() const { return c.front(); }
|
||||
reference back() { return c.back(); }
|
||||
const_reference back() const { return c.back(); }
|
||||
void push(const value_type& __x) { c.push_back(__x); }
|
||||
void pop() { c.pop_front(); }
|
||||
const _Sequence& _Get_s() const { return c; }
|
||||
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(_Self& __x) {
|
||||
_Sequence __tmp = c;
|
||||
c = __x.c;
|
||||
__x.c = __tmp;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef _STLP_QUEUE_ARGS
|
||||
# define _STLP_QUEUE_ARGS _Tp, _Sequence
|
||||
# define _STLP_QUEUE_HEADER_ARGS class _Tp, class _Sequence
|
||||
#else
|
||||
# define _STLP_QUEUE_HEADER_ARGS class _Tp
|
||||
#endif
|
||||
|
||||
template < _STLP_QUEUE_HEADER_ARGS >
|
||||
inline bool _STLP_CALL
|
||||
operator==(const queue<_STLP_QUEUE_ARGS >& __x, const queue<_STLP_QUEUE_ARGS >& __y) {
|
||||
return __x._Get_s() == __y._Get_s();
|
||||
}
|
||||
|
||||
template < _STLP_QUEUE_HEADER_ARGS >
|
||||
inline bool _STLP_CALL
|
||||
operator<(const queue<_STLP_QUEUE_ARGS >& __x, const queue<_STLP_QUEUE_ARGS >& __y) {
|
||||
return __x._Get_s() < __y._Get_s();
|
||||
}
|
||||
|
||||
_STLP_RELOPS_OPERATORS( template < _STLP_QUEUE_HEADER_ARGS >, queue<_STLP_QUEUE_ARGS > )
|
||||
|
||||
# if !(defined ( _STLP_LIMITED_DEFAULT_TEMPLATES ) || defined ( _STLP_TEMPLATE_PARAM_SUBTYPE_BUG ))
|
||||
template <class _Tp, class _Sequence = vector<_Tp>,
|
||||
class _Compare = less<_STLP_HEADER_TYPENAME _Sequence::value_type> >
|
||||
# elif defined ( _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS )
|
||||
template <class _Tp>
|
||||
# else
|
||||
template <class _Tp, class _Sequence, class _Compare>
|
||||
# endif
|
||||
class priority_queue
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
||||
# if defined (_STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS)
|
||||
: public __stlport_class<priority_queue<_Tp> >
|
||||
# else
|
||||
: public __stlport_class<priority_queue<_Tp, _Sequence> >
|
||||
# endif
|
||||
#endif
|
||||
{
|
||||
# ifdef _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS
|
||||
typedef vector<_Tp> _Sequence;
|
||||
typedef less< typename vector<_Tp>::value_type> _Compare;
|
||||
typedef priority_queue<_Tp> _Self;
|
||||
# else
|
||||
typedef priority_queue<_Tp, _Sequence, _Compare> _Self;
|
||||
# endif
|
||||
public:
|
||||
typedef typename _Sequence::value_type value_type;
|
||||
typedef typename _Sequence::size_type size_type;
|
||||
typedef _Sequence container_type;
|
||||
|
||||
typedef typename _Sequence::reference reference;
|
||||
typedef typename _Sequence::const_reference const_reference;
|
||||
protected:
|
||||
//c is a Standard name (23.2.3.2), do no make it STLport naming convention compliant.
|
||||
_Sequence c;
|
||||
_Compare comp;
|
||||
public:
|
||||
priority_queue() : c() {}
|
||||
explicit priority_queue(const _Compare& __x) : c(), comp(__x) {}
|
||||
priority_queue(const _Compare& __x, const _Sequence& __s)
|
||||
: c(__s), comp(__x)
|
||||
{ make_heap(c.begin(), c.end(), comp); }
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
priority_queue(__move_source<_Self> src)
|
||||
: c(_STLP_PRIV _AsMoveSource(src.get().c)),
|
||||
comp(_STLP_PRIV _AsMoveSource(src.get().comp)) {}
|
||||
#endif
|
||||
|
||||
#ifdef _STLP_MEMBER_TEMPLATES
|
||||
template <class _InputIterator>
|
||||
priority_queue(_InputIterator __first, _InputIterator __last)
|
||||
: c(__first, __last) { make_heap(c.begin(), c.end(), comp); }
|
||||
|
||||
template <class _InputIterator>
|
||||
priority_queue(_InputIterator __first,
|
||||
_InputIterator __last, const _Compare& __x)
|
||||
: c(__first, __last), comp(__x)
|
||||
{ make_heap(c.begin(), c.end(), comp); }
|
||||
|
||||
template <class _InputIterator>
|
||||
priority_queue(_InputIterator __first, _InputIterator __last,
|
||||
const _Compare& __x, const _Sequence& __s)
|
||||
: c(__s), comp(__x)
|
||||
{
|
||||
c.insert(c.end(), __first, __last);
|
||||
make_heap(c.begin(), c.end(), comp);
|
||||
}
|
||||
|
||||
#else /* _STLP_MEMBER_TEMPLATES */
|
||||
priority_queue(const value_type* __first, const value_type* __last)
|
||||
: c(__first, __last) { make_heap(c.begin(), c.end(), comp); }
|
||||
|
||||
priority_queue(const value_type* __first, const value_type* __last,
|
||||
const _Compare& __x)
|
||||
: c(__first, __last), comp(__x)
|
||||
{ make_heap(c.begin(), c.end(), comp); }
|
||||
|
||||
priority_queue(const value_type* __first, const value_type* __last,
|
||||
const _Compare& __x, const _Sequence& __c)
|
||||
: c(__c), comp(__x)
|
||||
{
|
||||
c.insert(c.end(), __first, __last);
|
||||
make_heap(c.begin(), c.end(), comp);
|
||||
}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
bool empty() const { return c.empty(); }
|
||||
size_type size() const { return c.size(); }
|
||||
const_reference top() const { return c.front(); }
|
||||
void push(const value_type& __x) {
|
||||
_STLP_TRY {
|
||||
c.push_back(__x);
|
||||
push_heap(c.begin(), c.end(), comp);
|
||||
}
|
||||
_STLP_UNWIND(c.clear())
|
||||
}
|
||||
void pop() {
|
||||
_STLP_TRY {
|
||||
pop_heap(c.begin(), c.end(), comp);
|
||||
c.pop_back();
|
||||
}
|
||||
_STLP_UNWIND(c.clear())
|
||||
}
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(_Self& __x) {
|
||||
_Sequence __tmp = c;
|
||||
c = __x.c;
|
||||
__x.c = __tmp;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
template <class _Tp, class _Sequence>
|
||||
struct __move_traits<queue<_Tp, _Sequence> > :
|
||||
_STLP_PRIV __move_traits_aux<_Sequence>
|
||||
{};
|
||||
|
||||
template <class _Tp, class _Sequence, class _Compare>
|
||||
struct __move_traits<priority_queue<_Tp, _Sequence, _Compare> > :
|
||||
_STLP_PRIV __move_traits_aux2<_Sequence, _Compare>
|
||||
{};
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#undef _STLP_QUEUE_ARGS
|
||||
#undef _STLP_QUEUE_HEADER_ARGS
|
||||
#undef comp
|
||||
|
||||
#endif /* _STLP_INTERNAL_QUEUE_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
84
extern/STLport/5.2.1/stlport/stl/_range_errors.c
vendored
Normal file
84
extern/STLport/5.2.1/stlport/stl/_range_errors.c
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Silicon Graphics makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(_STLP_THROW_RANGE_ERRORS)
|
||||
# if defined (_STLP_WHOLE_NATIVE_STD) && defined (_STLP_DONT_REDEFINE_STD)
|
||||
// In this mode we are going to throw native exception so that catch of
|
||||
// exception like std::runtime_error for instance will also catch exception
|
||||
// thrown by STLport containers like stlport::vector or stlport::string.
|
||||
# include <stdexcept>
|
||||
# include <string>
|
||||
# define _STLP_THROW_MSG(ex,msg) throw std::ex(msg)
|
||||
# else
|
||||
# if defined (__BUILDING_STLPORT)
|
||||
# include <stdexcept>
|
||||
# include <string>
|
||||
# else
|
||||
# ifndef _STLP_INTERNAL_STDEXCEPT
|
||||
# include <stl/_stdexcept.h>
|
||||
# endif
|
||||
# ifndef _STLP_INTERNAL_STRING_H
|
||||
# include <stl/_string.h>
|
||||
# endif
|
||||
# endif
|
||||
# define _STLP_THROW_MSG(ex,msg) throw ex(msg)
|
||||
# endif
|
||||
#else
|
||||
# if defined (__BUILDING_STLPORT)
|
||||
# include <cstdlib>
|
||||
# include <cstdio>
|
||||
# else
|
||||
# ifndef _STLP_INTERNAL_CSTDLIB
|
||||
# include <stl/_cstdlib.h>
|
||||
# endif
|
||||
# ifndef _STLP_INTERNAL_CSTDIO
|
||||
# include <stl/_cstdio.h>
|
||||
# endif
|
||||
# endif
|
||||
# define _STLP_THROW_MSG(ex,msg) puts(msg),_STLP_ABORT()
|
||||
#endif
|
||||
|
||||
// For mode without library and throwing range errors, include the
|
||||
// stdexcept header and throw the appropriate exceptions directly.
|
||||
|
||||
#if defined (_STLP_EXTERN_RANGE_ERRORS)
|
||||
# define _STLP_THROW_FUNCT_SPEC void _STLP_DECLSPEC
|
||||
#else
|
||||
# define _STLP_THROW_FUNCT_SPEC inline void
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_runtime_error(const char* __msg)
|
||||
{ _STLP_THROW_MSG(runtime_error, __msg); }
|
||||
|
||||
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_range_error(const char* __msg)
|
||||
{ _STLP_THROW_MSG(range_error, __msg); }
|
||||
|
||||
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_out_of_range(const char* __msg)
|
||||
{ _STLP_THROW_MSG(out_of_range, __msg); }
|
||||
|
||||
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_length_error(const char* __msg)
|
||||
{ _STLP_THROW_MSG(length_error, __msg); }
|
||||
|
||||
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_invalid_argument(const char* __msg)
|
||||
{ _STLP_THROW_MSG(invalid_argument, __msg); }
|
||||
|
||||
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_overflow_error(const char* __msg)
|
||||
{ _STLP_THROW_MSG(overflow_error, __msg); }
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#undef _STLP_THROW_FUNCT_SPEC
|
||||
#undef _STLP_THROW_MSG
|
||||
60
extern/STLport/5.2.1/stlport/stl/_range_errors.h
vendored
Normal file
60
extern/STLport/5.2.1/stlport/stl/_range_errors.h
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
* Silicon Graphics
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Silicon Graphics makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_RANGE_ERRORS_H
|
||||
#define _STLP_RANGE_ERRORS_H
|
||||
|
||||
// A few places in the STL throw range errors, using standard exception
|
||||
// classes defined in <stdexcept>. This header file provides functions
|
||||
// to throw those exception objects.
|
||||
|
||||
// _STLP_DONT_THROW_RANGE_ERRORS is a hook so that users can disable
|
||||
// this exception throwing.
|
||||
#if defined (_STLP_CAN_THROW_RANGE_ERRORS) && defined (_STLP_USE_EXCEPTIONS) && \
|
||||
!defined (_STLP_DONT_THROW_RANGE_ERRORS)
|
||||
# define _STLP_THROW_RANGE_ERRORS
|
||||
#endif
|
||||
|
||||
// For the STLport iostreams, only declaration here, definition is in the lib
|
||||
#if !defined (_STLP_USE_NO_IOSTREAMS) && !defined (_STLP_EXTERN_RANGE_ERRORS)
|
||||
# define _STLP_EXTERN_RANGE_ERRORS
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_runtime_error(const char* __msg);
|
||||
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_range_error(const char* __msg);
|
||||
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_out_of_range(const char* __msg);
|
||||
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_length_error(const char* __msg);
|
||||
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_invalid_argument(const char* __msg);
|
||||
void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_overflow_error(const char* __msg);
|
||||
|
||||
#if defined (__DMC__) && !defined (_STLP_NO_EXCEPTIONS)
|
||||
# pragma noreturn(__stl_throw_runtime_error)
|
||||
# pragma noreturn(__stl_throw_range_error)
|
||||
# pragma noreturn(__stl_throw_out_of_range)
|
||||
# pragma noreturn(__stl_throw_length_error)
|
||||
# pragma noreturn(__stl_throw_invalid_argument)
|
||||
# pragma noreturn(__stl_throw_overflow_error)
|
||||
#endif
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if !defined (_STLP_EXTERN_RANGE_ERRORS)
|
||||
# include <stl/_range_errors.c>
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_RANGE_ERRORS_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
80
extern/STLport/5.2.1/stlport/stl/_raw_storage_iter.h
vendored
Normal file
80
extern/STLport/5.2.1/stlport/stl/_raw_storage_iter.h
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_RAW_STORAGE_ITERATOR_H
|
||||
#define _STLP_INTERNAL_RAW_STORAGE_ITERATOR_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
|
||||
# include <stl/_iterator_base.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
class raw_storage_iterator
|
||||
: public iterator<output_iterator_tag,void,void,void,void>
|
||||
{
|
||||
protected:
|
||||
_ForwardIterator _M_iter;
|
||||
public:
|
||||
typedef output_iterator_tag iterator_category;
|
||||
# ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
# endif
|
||||
explicit raw_storage_iterator(_ForwardIterator __x) : _M_iter(__x) {}
|
||||
raw_storage_iterator<_ForwardIterator, _Tp>& operator*() { return *this; }
|
||||
raw_storage_iterator<_ForwardIterator, _Tp>& operator=(const _Tp& __element) {
|
||||
_Param_Construct(&*_M_iter, __element);
|
||||
return *this;
|
||||
}
|
||||
raw_storage_iterator<_ForwardIterator, _Tp>& operator++() {
|
||||
++_M_iter;
|
||||
return *this;
|
||||
}
|
||||
raw_storage_iterator<_ForwardIterator, _Tp> operator++(int) {
|
||||
raw_storage_iterator<_ForwardIterator, _Tp> __tmp = *this;
|
||||
++_M_iter;
|
||||
return __tmp;
|
||||
}
|
||||
};
|
||||
|
||||
# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
inline output_iterator_tag iterator_category(const raw_storage_iterator<_ForwardIterator, _Tp>&) { return output_iterator_tag(); }
|
||||
#endif
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_RAW_STORAGE_ITERATOR_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
29
extern/STLport/5.2.1/stlport/stl/_relops_cont.h
vendored
Normal file
29
extern/STLport/5.2.1/stlport/stl/_relops_cont.h
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
// This is an implementation file which
|
||||
// is intended to be included multiple times with different _STLP_ASSOCIATIVE_CONTAINER
|
||||
// setting
|
||||
|
||||
#if !defined (_STLP_EQUAL_OPERATOR_SPECIALIZED)
|
||||
_STLP_TEMPLATE_HEADER
|
||||
inline bool _STLP_CALL operator==(const _STLP_TEMPLATE_CONTAINER& __x,
|
||||
const _STLP_TEMPLATE_CONTAINER& __y) {
|
||||
return __x.size() == __y.size() &&
|
||||
equal(__x.begin(), __x.end(), __y.begin());
|
||||
}
|
||||
#endif /* _STLP_EQUAL_OPERATOR_SPECIALIZED */
|
||||
|
||||
_STLP_TEMPLATE_HEADER
|
||||
inline bool _STLP_CALL operator<(const _STLP_TEMPLATE_CONTAINER& __x,
|
||||
const _STLP_TEMPLATE_CONTAINER& __y) {
|
||||
return lexicographical_compare(__x.begin(), __x.end(),
|
||||
__y.begin(), __y.end());
|
||||
}
|
||||
|
||||
_STLP_RELOPS_OPERATORS( _STLP_TEMPLATE_HEADER , _STLP_TEMPLATE_CONTAINER )
|
||||
|
||||
#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
_STLP_TEMPLATE_HEADER
|
||||
inline void _STLP_CALL swap(_STLP_TEMPLATE_CONTAINER& __x,
|
||||
_STLP_TEMPLATE_CONTAINER& __y) {
|
||||
__x.swap(__y);
|
||||
}
|
||||
#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
13
extern/STLport/5.2.1/stlport/stl/_relops_hash_cont.h
vendored
Normal file
13
extern/STLport/5.2.1/stlport/stl/_relops_hash_cont.h
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/* This is an implementation file which is intended to be included
|
||||
* multiple times with different _STLP_TEMPLATE_CONTAINER settings.
|
||||
*/
|
||||
|
||||
#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
|
||||
_STLP_TEMPLATE_HEADER
|
||||
inline void _STLP_CALL
|
||||
swap(_STLP_TEMPLATE_CONTAINER& __hm1, _STLP_TEMPLATE_CONTAINER& __hm2) {
|
||||
__hm1.swap(__hm2);
|
||||
}
|
||||
|
||||
#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
|
||||
1407
extern/STLport/5.2.1/stlport/stl/_rope.c
vendored
Normal file
1407
extern/STLport/5.2.1/stlport/stl/_rope.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2389
extern/STLport/5.2.1/stlport/stl/_rope.h
vendored
Normal file
2389
extern/STLport/5.2.1/stlport/stl/_rope.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
412
extern/STLport/5.2.1/stlport/stl/_set.h
vendored
Normal file
412
extern/STLport/5.2.1/stlport/stl/_set.h
vendored
Normal file
@@ -0,0 +1,412 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This is an internal header file, included by other STL headers.
|
||||
* You should not attempt to use it directly.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_INTERNAL_SET_H
|
||||
#define _STLP_INTERNAL_SET_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_TREE_H
|
||||
# include <stl/_tree.h>
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_USE_PTR_SPECIALIZATIONS)
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
//Specific iterator traits creation
|
||||
_STLP_CREATE_ITERATOR_TRAITS(SetTraitsT, Const_traits)
|
||||
|
||||
template <class _Key, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key>),
|
||||
_STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Key>) >
|
||||
class set
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
||||
: public __stlport_class<set<_Key, _Compare, _Alloc> >
|
||||
#endif
|
||||
{
|
||||
typedef set<_Key, _Compare, _Alloc> _Self;
|
||||
public:
|
||||
// typedefs:
|
||||
typedef _Key key_type;
|
||||
typedef _Key value_type;
|
||||
typedef _Compare key_compare;
|
||||
typedef _Compare value_compare;
|
||||
|
||||
private:
|
||||
//Specific iterator traits creation
|
||||
typedef _STLP_PRIV _SetTraitsT<value_type> _SetTraits;
|
||||
|
||||
public:
|
||||
//Following typedef have to be public for __move_traits specialization.
|
||||
typedef _STLP_PRIV _Rb_tree<key_type, key_compare,
|
||||
value_type, _STLP_PRIV _Identity<value_type>,
|
||||
_SetTraits, _Alloc> _Rep_type;
|
||||
|
||||
typedef typename _Rep_type::pointer pointer;
|
||||
typedef typename _Rep_type::const_pointer const_pointer;
|
||||
typedef typename _Rep_type::reference reference;
|
||||
typedef typename _Rep_type::const_reference const_reference;
|
||||
typedef typename _Rep_type::iterator iterator;
|
||||
typedef typename _Rep_type::const_iterator const_iterator;
|
||||
typedef typename _Rep_type::reverse_iterator reverse_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename _Rep_type::size_type size_type;
|
||||
typedef typename _Rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::allocator_type allocator_type;
|
||||
|
||||
private:
|
||||
_Rep_type _M_t; // red-black tree representing set
|
||||
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
||||
|
||||
public:
|
||||
|
||||
// allocation/deallocation
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
explicit set(const _Compare& __comp = _Compare(),
|
||||
const allocator_type& __a = allocator_type())
|
||||
#else
|
||||
set()
|
||||
: _M_t(_Compare(), allocator_type()) {}
|
||||
explicit set(const _Compare& __comp)
|
||||
: _M_t(__comp, allocator_type()) {}
|
||||
set(const _Compare& __comp, const allocator_type& __a)
|
||||
#endif
|
||||
: _M_t(__comp, __a) {}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
set(_InputIterator __first, _InputIterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
|
||||
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
|
||||
template <class _InputIterator>
|
||||
set(_InputIterator __first, _InputIterator __last, const _Compare& __comp)
|
||||
: _M_t(__comp, allocator_type()) { _M_t.insert_unique(__first, __last); }
|
||||
# endif
|
||||
template <class _InputIterator>
|
||||
set(_InputIterator __first, _InputIterator __last, const _Compare& __comp,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
||||
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
|
||||
#else
|
||||
set(const value_type* __first, const value_type* __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
|
||||
set(const value_type* __first,
|
||||
const value_type* __last, const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
|
||||
|
||||
set(const_iterator __first, const_iterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
|
||||
set(const_iterator __first, const_iterator __last, const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
set(const _Self& __x) : _M_t(__x._M_t) {}
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
set(__move_source<_Self> src)
|
||||
: _M_t(__move_source<_Rep_type>(src.get()._M_t)) {}
|
||||
#endif
|
||||
|
||||
_Self& operator=(const _Self& __x) {
|
||||
_M_t = __x._M_t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// accessors:
|
||||
key_compare key_comp() const { return _M_t.key_comp(); }
|
||||
value_compare value_comp() const { return _M_t.key_comp(); }
|
||||
allocator_type get_allocator() const { return _M_t.get_allocator(); }
|
||||
|
||||
iterator begin() { return _M_t.begin(); }
|
||||
iterator end() { return _M_t.end(); }
|
||||
const_iterator begin() const { return _M_t.begin(); }
|
||||
const_iterator end() const { return _M_t.end(); }
|
||||
reverse_iterator rbegin() { return _M_t.rbegin(); }
|
||||
reverse_iterator rend() { return _M_t.rend(); }
|
||||
const_reverse_iterator rbegin() const { return _M_t.rbegin(); }
|
||||
const_reverse_iterator rend() const { return _M_t.rend(); }
|
||||
bool empty() const { return _M_t.empty(); }
|
||||
size_type size() const { return _M_t.size(); }
|
||||
size_type max_size() const { return _M_t.max_size(); }
|
||||
void swap(_Self& __x) { _M_t.swap(__x._M_t); }
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(_Self& __x) { swap(__x); }
|
||||
#endif
|
||||
|
||||
// insert/erase
|
||||
pair<iterator,bool> insert(const value_type& __x)
|
||||
{ return _M_t.insert_unique(__x); }
|
||||
iterator insert(iterator __pos, const value_type& __x)
|
||||
{ return _M_t.insert_unique( __pos , __x); }
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __first, _InputIterator __last)
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
#else
|
||||
void insert(const_iterator __first, const_iterator __last)
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
void insert(const value_type* __first, const value_type* __last)
|
||||
{ _M_t.insert_unique(__first, __last); }
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
void erase(iterator __pos) { _M_t.erase( __pos ); }
|
||||
size_type erase(const key_type& __x) { return _M_t.erase_unique(__x); }
|
||||
void erase(iterator __first, iterator __last) { _M_t.erase(__first, __last ); }
|
||||
void clear() { _M_t.clear(); }
|
||||
|
||||
// set operations:
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator find(const _KT& __x) const { return _M_t.find(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator find(const _KT& __x) { return _M_t.find(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type count(const _KT& __x) const
|
||||
{ return _M_t.find(__x) == _M_t.end() ? 0 : 1 ; }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<iterator, iterator> equal_range(const _KT& __x)
|
||||
{ return _M_t.equal_range_unique(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<const_iterator, const_iterator> equal_range(const _KT& __x) const
|
||||
{ return _M_t.equal_range_unique(__x); }
|
||||
};
|
||||
|
||||
//Specific iterator traits creation
|
||||
_STLP_CREATE_ITERATOR_TRAITS(MultisetTraitsT, Const_traits)
|
||||
|
||||
template <class _Key, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key>),
|
||||
_STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Key>) >
|
||||
class multiset
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
||||
: public __stlport_class<multiset<_Key, _Compare, _Alloc> >
|
||||
#endif
|
||||
{
|
||||
typedef multiset<_Key, _Compare, _Alloc> _Self;
|
||||
public:
|
||||
// typedefs:
|
||||
|
||||
typedef _Key key_type;
|
||||
typedef _Key value_type;
|
||||
typedef _Compare key_compare;
|
||||
typedef _Compare value_compare;
|
||||
|
||||
private:
|
||||
//Specific iterator traits creation
|
||||
typedef _STLP_PRIV _MultisetTraitsT<value_type> _MultisetTraits;
|
||||
|
||||
public:
|
||||
//Following typedef have to be public for __move_traits specialization.
|
||||
typedef _STLP_PRIV _Rb_tree<key_type, key_compare,
|
||||
value_type, _STLP_PRIV _Identity<value_type>,
|
||||
_MultisetTraits, _Alloc> _Rep_type;
|
||||
|
||||
typedef typename _Rep_type::pointer pointer;
|
||||
typedef typename _Rep_type::const_pointer const_pointer;
|
||||
typedef typename _Rep_type::reference reference;
|
||||
typedef typename _Rep_type::const_reference const_reference;
|
||||
typedef typename _Rep_type::iterator iterator;
|
||||
typedef typename _Rep_type::const_iterator const_iterator;
|
||||
typedef typename _Rep_type::reverse_iterator reverse_iterator;
|
||||
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename _Rep_type::size_type size_type;
|
||||
typedef typename _Rep_type::difference_type difference_type;
|
||||
typedef typename _Rep_type::allocator_type allocator_type;
|
||||
|
||||
private:
|
||||
_Rep_type _M_t; // red-black tree representing multiset
|
||||
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
||||
|
||||
public:
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
explicit multiset(const _Compare& __comp = _Compare(),
|
||||
const allocator_type& __a = allocator_type())
|
||||
#else
|
||||
multiset()
|
||||
: _M_t(_Compare(), allocator_type()) {}
|
||||
explicit multiset(const _Compare& __comp)
|
||||
: _M_t(__comp, allocator_type()) {}
|
||||
multiset(const _Compare& __comp, const allocator_type& __a)
|
||||
#endif
|
||||
: _M_t(__comp, __a) {}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
multiset(_InputIterator __first, _InputIterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
|
||||
template <class _InputIterator>
|
||||
multiset(_InputIterator __first, _InputIterator __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
||||
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
||||
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
|
||||
template <class _InputIterator>
|
||||
multiset(_InputIterator __first, _InputIterator __last,
|
||||
const _Compare& __comp)
|
||||
: _M_t(__comp, allocator_type()) { _M_t.insert_equal(__first, __last); }
|
||||
# endif
|
||||
#else
|
||||
multiset(const value_type* __first, const value_type* __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
|
||||
multiset(const value_type* __first, const value_type* __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
||||
|
||||
multiset(const_iterator __first, const_iterator __last)
|
||||
: _M_t(_Compare(), allocator_type())
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
|
||||
multiset(const_iterator __first, const_iterator __last,
|
||||
const _Compare& __comp,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
multiset(const _Self& __x) : _M_t(__x._M_t) {}
|
||||
_Self& operator=(const _Self& __x) {
|
||||
_M_t = __x._M_t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
multiset(__move_source<_Self> src)
|
||||
: _M_t(__move_source<_Rep_type>(src.get()._M_t)) {}
|
||||
#endif
|
||||
|
||||
// accessors:
|
||||
key_compare key_comp() const { return _M_t.key_comp(); }
|
||||
value_compare value_comp() const { return _M_t.key_comp(); }
|
||||
allocator_type get_allocator() const { return _M_t.get_allocator(); }
|
||||
|
||||
iterator begin() { return _M_t.begin(); }
|
||||
iterator end() { return _M_t.end(); }
|
||||
const_iterator begin() const { return _M_t.begin(); }
|
||||
const_iterator end() const { return _M_t.end(); }
|
||||
reverse_iterator rbegin() { return _M_t.rbegin(); }
|
||||
reverse_iterator rend() { return _M_t.rend(); }
|
||||
const_reverse_iterator rbegin() const { return _M_t.rbegin(); }
|
||||
const_reverse_iterator rend() const { return _M_t.rend(); }
|
||||
bool empty() const { return _M_t.empty(); }
|
||||
size_type size() const { return _M_t.size(); }
|
||||
size_type max_size() const { return _M_t.max_size(); }
|
||||
void swap(_Self& __x) { _M_t.swap(__x._M_t); }
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(_Self& __x) { swap(__x); }
|
||||
#endif
|
||||
|
||||
// insert/erase
|
||||
iterator insert(const value_type& __x)
|
||||
{ return _M_t.insert_equal(__x); }
|
||||
iterator insert(iterator __pos, const value_type& __x)
|
||||
{ return _M_t.insert_equal(__pos, __x); }
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void insert(_InputIterator __first, _InputIterator __last)
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
#else
|
||||
void insert(const value_type* __first, const value_type* __last)
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
void insert(const_iterator __first, const_iterator __last)
|
||||
{ _M_t.insert_equal(__first, __last); }
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
void erase(iterator __pos) { _M_t.erase( __pos ); }
|
||||
size_type erase(const key_type& __x) { return _M_t.erase(__x); }
|
||||
void erase(iterator __first, iterator __last) { _M_t.erase( __first, __last ); }
|
||||
void clear() { _M_t.clear(); }
|
||||
|
||||
// multiset operations:
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator find(const _KT& __x) { return _M_t.find(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator find(const _KT& __x) const { return _M_t.find(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type count(const _KT& __x) const { return _M_t.count(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<iterator, iterator> equal_range(const _KT& __x) { return _M_t.equal_range(__x); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<const_iterator, const_iterator> equal_range(const _KT& __x) const { return _M_t.equal_range(__x); }
|
||||
};
|
||||
|
||||
#else
|
||||
# include <stl/pointers/_set.h>
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
#endif /* _STLP_USE_PTR_SPECIALIZATIONS */
|
||||
|
||||
#define _STLP_TEMPLATE_HEADER template <class _Key, class _Compare, class _Alloc>
|
||||
#define _STLP_TEMPLATE_CONTAINER set<_Key,_Compare,_Alloc>
|
||||
#include <stl/_relops_cont.h>
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#define _STLP_TEMPLATE_CONTAINER multiset<_Key,_Compare,_Alloc>
|
||||
#include <stl/_relops_cont.h>
|
||||
#undef _STLP_TEMPLATE_CONTAINER
|
||||
#undef _STLP_TEMPLATE_HEADER
|
||||
|
||||
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
struct __move_traits<set<_Key,_Compare,_Alloc> > :
|
||||
_STLP_PRIV __move_traits_aux<typename set<_Key,_Compare,_Alloc>::_Rep_type>
|
||||
{};
|
||||
|
||||
template <class _Key, class _Compare, class _Alloc>
|
||||
struct __move_traits<multiset<_Key,_Compare,_Alloc> > :
|
||||
_STLP_PRIV __move_traits_aux<typename multiset<_Key,_Compare,_Alloc>::_Rep_type>
|
||||
{};
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_INTERNAL_SET_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
231
extern/STLport/5.2.1/stlport/stl/_slist.c
vendored
Normal file
231
extern/STLport/5.2.1/stlport/stl/_slist.c
vendored
Normal file
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* This material is provided "as is", with absolutely no warranty expressed
|
||||
* or implied. Any use is at your own risk.
|
||||
*
|
||||
* Permission to use or copy this software for any purpose is hereby granted
|
||||
* without fee, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#ifndef _STLP_SLIST_C
|
||||
#define _STLP_SLIST_C
|
||||
|
||||
#ifndef _STLP_INTERNAL_SLIST_H
|
||||
# include <stl/_slist.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_CARRAY_H
|
||||
# include <stl/_carray.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_RANGE_ERRORS_H
|
||||
# include <stl/_range_errors.h>
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_NESTED_TYPE_PARAM_BUG)
|
||||
# define size_type size_t
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
_Slist_node_base*
|
||||
_Slist_base<_Tp,_Alloc>::_M_erase_after(_Slist_node_base* __before_first,
|
||||
_Slist_node_base* __last_node) {
|
||||
_Slist_node_base* __cur = __before_first->_M_next;
|
||||
while (__cur != __last_node) {
|
||||
_Node* __tmp = __STATIC_CAST(_Node*, __cur);
|
||||
__cur = __cur->_M_next;
|
||||
_STLP_STD::_Destroy(&__tmp->_M_data);
|
||||
_M_head.deallocate(__tmp,1);
|
||||
}
|
||||
__before_first->_M_next = __last_node;
|
||||
return __last_node;
|
||||
}
|
||||
|
||||
#if defined (_STLP_USE_PTR_SPECIALIZATIONS)
|
||||
# define slist _STLP_PTR_IMPL_NAME(slist)
|
||||
#elif defined (_STLP_DEBUG)
|
||||
# define slist _STLP_NON_DBG_NAME(slist)
|
||||
#else
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
#endif
|
||||
|
||||
/* When building STLport lib Digital Mars Compiler complains on the _M_data assignment
|
||||
* problem which would be perfertly right if we were using it. Hiding it during build
|
||||
* fix this issue.
|
||||
*/
|
||||
template <class _Tp, class _Alloc>
|
||||
slist<_Tp,_Alloc>& slist<_Tp,_Alloc>::operator=(const slist<_Tp,_Alloc>& __x) {
|
||||
if (&__x != this) {
|
||||
_Node_base* __p1 = &this->_M_head._M_data;
|
||||
_Node_base* __n1 = this->_M_head._M_data._M_next;
|
||||
const _Node_base* __n2 = __x._M_head._M_data._M_next;
|
||||
while (__n1 && __n2) {
|
||||
__STATIC_CAST(_Node*, __n1)->_M_data = __STATIC_CAST(const _Node*, __n2)->_M_data;
|
||||
__p1 = __n1;
|
||||
__n1 = __n1->_M_next;
|
||||
__n2 = __n2->_M_next;
|
||||
}
|
||||
if (__n2 == 0)
|
||||
this->_M_erase_after(__p1, 0);
|
||||
else
|
||||
_M_insert_after_range(__p1, const_iterator(__CONST_CAST(_Node_base*, __n2)),
|
||||
const_iterator(0));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
void slist<_Tp, _Alloc>::_M_fill_assign(size_type __n, const _Tp& __val) {
|
||||
_Node_base* __prev = &this->_M_head._M_data;
|
||||
_Node_base* __node = this->_M_head._M_data._M_next;
|
||||
for ( ; __node != 0 && __n > 0 ; --__n) {
|
||||
__STATIC_CAST(_Node*, __node)->_M_data = __val;
|
||||
__prev = __node;
|
||||
__node = __node->_M_next;
|
||||
}
|
||||
if (__n > 0)
|
||||
_M_insert_after_fill(__prev, __n, __val);
|
||||
else
|
||||
this->_M_erase_after(__prev, 0);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
void slist<_Tp,_Alloc>::resize(size_type __len, const _Tp& __x) {
|
||||
_Node_base* __cur = &this->_M_head._M_data;
|
||||
while (__cur->_M_next != 0 && __len > 0) {
|
||||
--__len;
|
||||
__cur = __cur->_M_next;
|
||||
}
|
||||
if (__cur->_M_next)
|
||||
this->_M_erase_after(__cur, 0);
|
||||
else
|
||||
_M_insert_after_fill(__cur, __len, __x);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
void slist<_Tp,_Alloc>::remove(const _Tp& __val) {
|
||||
_Node_base* __cur = &this->_M_head._M_data;
|
||||
while (__cur && __cur->_M_next) {
|
||||
if (__STATIC_CAST(_Node*, __cur->_M_next)->_M_data == __val)
|
||||
this->_M_erase_after(__cur);
|
||||
else
|
||||
__cur = __cur->_M_next;
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined (slist)
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Alloc, class _BinaryPredicate>
|
||||
void _Slist_unique(slist<_Tp, _Alloc>& __that, _BinaryPredicate __pred) {
|
||||
typedef _Slist_node<_Tp> _Node;
|
||||
typename slist<_Tp, _Alloc>::iterator __ite(__that.begin());
|
||||
if (__ite != __that.end()) {
|
||||
while (__ite._M_node->_M_next) {
|
||||
if (__pred(*__ite, __STATIC_CAST(_Node*, __ite._M_node->_M_next)->_M_data))
|
||||
__that.erase_after(__ite);
|
||||
else
|
||||
++__ite;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc, class _StrictWeakOrdering>
|
||||
void _Slist_merge(slist<_Tp, _Alloc>& __that, slist<_Tp, _Alloc>& __x,
|
||||
_StrictWeakOrdering __comp) {
|
||||
typedef _Slist_node<_Tp> _Node;
|
||||
typedef _STLP_PRIV _Slist_node_base _Node_base;
|
||||
if (__that.get_allocator() == __x.get_allocator()) {
|
||||
typename slist<_Tp, _Alloc>::iterator __ite(__that.before_begin());
|
||||
while (__ite._M_node->_M_next && !__x.empty()) {
|
||||
if (__comp(__x.front(), __STATIC_CAST(_Node*, __ite._M_node->_M_next)->_M_data)) {
|
||||
_STLP_VERBOSE_ASSERT(!__comp(__STATIC_CAST(_Node*, __ite._M_node->_M_next)->_M_data, __x.front()),
|
||||
_StlMsg_INVALID_STRICT_WEAK_PREDICATE)
|
||||
__that.splice_after(__ite, __x, __x.before_begin());
|
||||
}
|
||||
++__ite;
|
||||
}
|
||||
if (!__x.empty()) {
|
||||
__that.splice_after(__ite, __x);
|
||||
}
|
||||
}
|
||||
else {
|
||||
typename slist<_Tp, _Alloc>::iterator __i1(__that.before_begin()), __i2(__x.begin());
|
||||
while (__i1._M_node->_M_next && __i2._M_node) {
|
||||
if (__comp(__STATIC_CAST(_Node*, __i1._M_node->_M_next)->_M_data, *__i2)) {
|
||||
_STLP_VERBOSE_ASSERT(!__comp(*__i2, __STATIC_CAST(_Node*, __i1._M_node->_M_next)->_M_data),
|
||||
_StlMsg_INVALID_STRICT_WEAK_PREDICATE)
|
||||
++__i1;
|
||||
}
|
||||
else {
|
||||
__i1 = __that.insert_after(__i1, *(__i2++));
|
||||
}
|
||||
}
|
||||
__that.insert_after(__i1, __i2, __x.end());
|
||||
__x.clear();
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc, class _StrictWeakOrdering>
|
||||
void _Slist_sort(slist<_Tp, _Alloc>& __that, _StrictWeakOrdering __comp) {
|
||||
if (!__that.begin()._M_node || !__that.begin()._M_node->_M_next)
|
||||
return;
|
||||
|
||||
slist<_Tp, _Alloc> __carry(__that.get_allocator());
|
||||
const int NB = 64;
|
||||
_STLP_PRIV _CArray<slist<_Tp, _Alloc>, NB> __counter(__carry);
|
||||
int __fill = 0;
|
||||
while (!__that.empty()) {
|
||||
__carry.splice_after(__carry.before_begin(), __that, __that.before_begin());
|
||||
int __i = 0;
|
||||
while (__i < __fill && !__counter[__i].empty()) {
|
||||
_STLP_PRIV _Slist_merge(__counter[__i], __carry, __comp);
|
||||
__carry.swap(__counter[__i]);
|
||||
++__i;
|
||||
}
|
||||
__carry.swap(__counter[__i]);
|
||||
if (__i == __fill) {
|
||||
++__fill;
|
||||
if (__fill >= NB) {
|
||||
//Looks like the slist has too many elements to be sorted with this algorithm:
|
||||
__stl_throw_overflow_error("slist::sort");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int __i = 1; __i < __fill; ++__i)
|
||||
_STLP_PRIV _Slist_merge(__counter[__i], __counter[__i - 1], __comp);
|
||||
__that.swap(__counter[__fill-1]);
|
||||
}
|
||||
|
||||
#if defined (slist)
|
||||
# undef slist
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#if defined (_STLP_NESTED_TYPE_PARAM_BUG)
|
||||
# undef size_type
|
||||
#endif
|
||||
|
||||
#endif /* _STLP_SLIST_C */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user