epoc32/include/stdapis/stlportv5/stl/_function_base.h
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
     1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_function_base.h	Wed Mar 31 12:27:01 2010 +0100
     1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_function_base.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -9,13 +9,13 @@
     1.4   * Copyright (c) 1997
     1.5   * Moscow Center for SPARC Technology
     1.6   *
     1.7 - * Copyright (c) 1999 
     1.8 + * Copyright (c) 1999
     1.9   * Boris Fomitchev
    1.10   *
    1.11   * This material is provided "as is", with absolutely no warranty expressed
    1.12   * or implied. Any use is at your own risk.
    1.13   *
    1.14 - * Permission to use or copy this software for any purpose is hereby granted 
    1.15 + * Permission to use or copy this software for any purpose is hereby granted
    1.16   * without fee, provided the above notices are retained on all copies.
    1.17   * Permission to modify the code and to distribute modified code is granted,
    1.18   * provided the above notices are retained, and a notice that the code was
    1.19 @@ -30,8 +30,8 @@
    1.20  #ifndef _STLP_INTERNAL_FUNCTION_BASE_H
    1.21  #define _STLP_INTERNAL_FUNCTION_BASE_H
    1.22  
    1.23 -#ifndef _STLP_CONFIG_H
    1.24 -#include <stl/_config.h>
    1.25 +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_TYPE_TRAITS_H)
    1.26 +#  include <stl/type_traits.h>
    1.27  #endif
    1.28  
    1.29  _STLP_BEGIN_NAMESPACE
    1.30 @@ -47,43 +47,50 @@
    1.31    typedef _Arg1 first_argument_type;
    1.32    typedef _Arg2 second_argument_type;
    1.33    typedef _Result result_type;
    1.34 -};      
    1.35 +};
    1.36  
    1.37  template <class _Tp>
    1.38 -struct equal_to : public binary_function<_Tp,_Tp,bool> 
    1.39 -{
    1.40 +struct equal_to : public binary_function<_Tp, _Tp, bool> {
    1.41    bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; }
    1.42  };
    1.43  
    1.44  template <class _Tp>
    1.45 -struct not_equal_to : public binary_function<_Tp,_Tp,bool> 
    1.46 +struct less : public binary_function<_Tp,_Tp,bool>
    1.47 +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
    1.48 +/* less is the default template parameter for many STL containers, to fully use
    1.49 + * the move constructor feature we need to know that the default less is just a
    1.50 + * functor.
    1.51 + */
    1.52 +              , public __stlport_class<less<_Tp> >
    1.53 +#endif
    1.54  {
    1.55 -  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x != __y; }
    1.56 +  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; }
    1.57 +
    1.58 +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
    1.59 +  //This is for a very special compiler config: partial template specialization
    1.60 +  //but no template function partial ordering.
    1.61 +  void swap(less<_Tp>&) {}
    1.62 +#endif
    1.63  };
    1.64  
    1.65 +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
    1.66  template <class _Tp>
    1.67 -struct greater : public binary_function<_Tp,_Tp,bool> 
    1.68 -{
    1.69 -  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x > __y; }
    1.70 +struct __type_traits<less<_Tp> > {
    1.71 +#if !defined (__BORLANDC__)
    1.72 +  typedef typename _IsSTLportClass<less<_Tp> >::_Ret _STLportLess;
    1.73 +#else
    1.74 +  enum { _Is = _IsSTLportClass<less<_Tp> >::_Is };
    1.75 +  typedef typename __bool2type<_Is>::_Ret _STLportLess;
    1.76 +#endif
    1.77 +  typedef _STLportLess has_trivial_default_constructor;
    1.78 +  typedef _STLportLess has_trivial_copy_constructor;
    1.79 +  typedef _STLportLess has_trivial_assignment_operator;
    1.80 +  typedef _STLportLess has_trivial_destructor;
    1.81 +  typedef _STLportLess is_POD_type;
    1.82  };
    1.83 +#endif
    1.84  
    1.85 -template <class _Tp>
    1.86 -struct less : public binary_function<_Tp,_Tp,bool> 
    1.87 -{
    1.88 -  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; }
    1.89 -};
    1.90 -
    1.91 -template <class _Tp>
    1.92 -struct greater_equal : public binary_function<_Tp,_Tp,bool>
    1.93 -{
    1.94 -  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x >= __y; }
    1.95 -};
    1.96 -
    1.97 -template <class _Tp>
    1.98 -struct less_equal : public binary_function<_Tp,_Tp,bool> 
    1.99 -{
   1.100 -  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x <= __y; }
   1.101 -};
   1.102 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.103  
   1.104  template <class _Tp>
   1.105  less<_Tp> __less(_Tp* ) { return less<_Tp>(); }
   1.106 @@ -91,61 +98,34 @@
   1.107  template <class _Tp>
   1.108  equal_to<_Tp> __equal_to(_Tp* ) { return equal_to<_Tp>(); }
   1.109  
   1.110 +_STLP_MOVE_TO_STD_NAMESPACE
   1.111 +
   1.112  template <class _Tp>
   1.113 -struct plus : public binary_function<_Tp,_Tp,_Tp> {
   1.114 +struct plus : public binary_function<_Tp, _Tp, _Tp> {
   1.115    _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; }
   1.116  };
   1.117  
   1.118  template <class _Tp>
   1.119 -struct minus : public binary_function<_Tp,_Tp,_Tp> {
   1.120 +struct minus : public binary_function<_Tp, _Tp, _Tp> {
   1.121    _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x - __y; }
   1.122  };
   1.123  
   1.124 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.125 +
   1.126  template <class _Tp>
   1.127  plus<_Tp> __plus(_Tp* ) { return plus<_Tp>(); }
   1.128  
   1.129  template <class _Tp>
   1.130  minus<_Tp> __minus(_Tp* ) { return minus<_Tp>(); }
   1.131  
   1.132 +_STLP_MOVE_TO_STD_NAMESPACE
   1.133 +
   1.134  template <class _Tp>
   1.135 -struct multiplies : public binary_function<_Tp,_Tp,_Tp> {
   1.136 +struct multiplies : public binary_function<_Tp, _Tp, _Tp> {
   1.137    _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x * __y; }
   1.138  };
   1.139  
   1.140 -template <class _Tp>
   1.141 -struct divides : public binary_function<_Tp,_Tp,_Tp> {
   1.142 -  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x / __y; }
   1.143 -};
   1.144 -
   1.145 -template <class _Tp>
   1.146 -struct modulus : public binary_function<_Tp,_Tp,_Tp> 
   1.147 -{
   1.148 -  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x % __y; }
   1.149 -};
   1.150 -
   1.151 -template <class _Tp>
   1.152 -struct negate : public unary_function<_Tp,_Tp> 
   1.153 -{
   1.154 -  _Tp operator()(const _Tp& __x) const { return -__x; }
   1.155 -};
   1.156 -
   1.157 -template <class _Tp>
   1.158 -struct logical_and : public binary_function<_Tp,_Tp,bool>
   1.159 -{
   1.160 -  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x && __y; }
   1.161 -};
   1.162 -
   1.163 -template <class _Tp>
   1.164 -struct logical_or : public binary_function<_Tp,_Tp,bool>
   1.165 -{
   1.166 -  bool operator()(const _Tp& __x, const _Tp& __y) const { return __x || __y; }
   1.167 -};
   1.168 -
   1.169 -template <class _Tp>
   1.170 -struct logical_not : public unary_function<_Tp,bool>
   1.171 -{
   1.172 -  bool operator()(const _Tp& __x) const { return !__x; }
   1.173 -};
   1.174 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.175  
   1.176  template <class _Pair>
   1.177  struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> {
   1.178 @@ -155,8 +135,7 @@
   1.179  };
   1.180  
   1.181  template <class _Pair>
   1.182 -struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type>
   1.183 -{
   1.184 +struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type> {
   1.185    const typename _Pair::second_type& operator()(const _Pair& __x) const {
   1.186      return __x.second;
   1.187    }
   1.188 @@ -173,17 +152,17 @@
   1.189    _Arg2 operator()(const _Arg1&, const _Arg2& __y) const { return __y; }
   1.190  };
   1.191  
   1.192 -#ifdef _STLP_MULTI_CONST_TEMPLATE_ARG_BUG
   1.193 +#if defined (_STLP_MULTI_CONST_TEMPLATE_ARG_BUG)
   1.194  // fbp : sort of select1st just for maps
   1.195 -template <class _Pair, class _Whatever>		
   1.196 +template <class _Pair, class _Whatever>
   1.197  // JDJ (CW Pro1 doesn't like const when first_type is also const)
   1.198  struct __Select1st_hint : public unary_function<_Pair, _Whatever> {
   1.199      const _Whatever& operator () (const _Pair& __x) const { return __x.first; }
   1.200  };
   1.201 -# define  _STLP_SELECT1ST(__x,__y) __Select1st_hint< __x, __y >
   1.202 -# else
   1.203 -# define  _STLP_SELECT1ST(__x, __y) _Select1st< __x >
   1.204 -# endif
   1.205 +#  define  _STLP_SELECT1ST(__x,__y) _STLP_PRIV __Select1st_hint< __x, __y >
   1.206 +#else
   1.207 +#  define  _STLP_SELECT1ST(__x, __y) _STLP_PRIV _Select1st< __x >
   1.208 +#endif
   1.209  
   1.210  template <class _Tp>
   1.211  struct _Identity : public unary_function<_Tp,_Tp> {
   1.212 @@ -217,6 +196,8 @@
   1.213  template <class _Tp> inline _Tp __identity_element(plus<_Tp>) {  return _Tp(0); }
   1.214  template <class _Tp> inline _Tp __identity_element(multiplies<_Tp>) { return _Tp(1); }
   1.215  
   1.216 +_STLP_MOVE_TO_STD_NAMESPACE
   1.217 +
   1.218  _STLP_END_NAMESPACE
   1.219  
   1.220  #endif /* _STLP_INTERNAL_FUNCTION_BASE_H */