epoc32/include/tools/stlport/stl/_move_construct_fwk.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/tools/stlport/stl/_move_construct_fwk.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,160 @@
     1.4 +/*
     1.5 + *
     1.6 + * Copyright (c) 2003
     1.7 + * François Dumont
     1.8 + *
     1.9 + * This material is provided "as is", with absolutely no warranty expressed
    1.10 + * or implied. Any use is at your own risk.
    1.11 + *
    1.12 + * Permission to use or copy this software for any purpose is hereby granted
    1.13 + * without fee, provided the above notices are retained on all copies.
    1.14 + * Permission to modify the code and to distribute modified code is granted,
    1.15 + * provided the above notices are retained, and a notice that the code was
    1.16 + * modified is included with the above copyright notice.
    1.17 + *
    1.18 + */
    1.19 +
    1.20 +#ifndef _STLP_MOVE_CONSTRUCT_FWK_H
    1.21 +#define _STLP_MOVE_CONSTRUCT_FWK_H
    1.22 +
    1.23 +#ifndef _STLP_TYPE_TRAITS_H
    1.24 +#  include <stl/type_traits.h>
    1.25 +#endif
    1.26 +
    1.27 +_STLP_BEGIN_NAMESPACE
    1.28 +
    1.29 +/*************************************************************
    1.30 + * Move constructor framework
    1.31 + *************************************************************/
    1.32 +
    1.33 +/*************************************************************
    1.34 + *Partial move:
    1.35 + *The source HAS to be a valid instance after the move!
    1.36 + *************************************************************/
    1.37 +template <class _Tp>
    1.38 +class __move_source {
    1.39 +public:
    1.40 +  explicit __move_source (_Tp &_src) : _M_data(_src)
    1.41 +  {}
    1.42 +
    1.43 +  _Tp& get() const
    1.44 +  { return _M_data; }
    1.45 +private:
    1.46 +  _Tp &_M_data;
    1.47 +
    1.48 +  //We explicitely forbid assignment to avoid warning:
    1.49 +  typedef __move_source<_Tp> _Self;
    1.50 +  _Self& operator = (_Self const&);
    1.51 +};
    1.52 +
    1.53 +//Class used to signal move constructor support, implementation and type.
    1.54 +template <class _Tp>
    1.55 +struct __move_traits {
    1.56 +  /*
    1.57 +   * implemented tells if a the special move constructor has to be called or the classic
    1.58 +   * copy constructor is just fine. Most of the time the copy constructor is fine only
    1.59 +   * if the following info is true.
    1.60 +   */
    1.61 +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && \
    1.62 +   !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && \
    1.63 +   !defined (_STLP_NO_MOVE_SEMANTIC)
    1.64 +  typedef typename _IsSTLportClass<_Tp>::_Ret implemented;
    1.65 +#else
    1.66 +  typedef __false_type implemented;
    1.67 +#endif
    1.68 +  /*
    1.69 +   * complete tells if the move is complete or partial, that is to say, does the source
    1.70 +   * needs to be destroyed once it has been moved.
    1.71 +   */
    1.72 +  typedef typename __type_traits<_Tp>::has_trivial_destructor complete;
    1.73 +};
    1.74 +
    1.75 +#if !defined (_STLP_NO_MOVE_SEMANTIC)
    1.76 +typedef __true_type __stlp_movable;
    1.77 +#else
    1.78 +typedef __false_type __stlp_movable;
    1.79 +#endif
    1.80 +
    1.81 +_STLP_MOVE_TO_PRIV_NAMESPACE
    1.82 +
    1.83 +/*
    1.84 + * This struct should never be used if the user has not explicitely stipulated
    1.85 + * that its class support the full move concept. To check that the return type
    1.86 + * in such a case will be __invalid_source<_Tp> to generate a compile error
    1.87 + * revealing the configuration problem.
    1.88 + */
    1.89 +template <class _Tp>
    1.90 +struct _MoveSourceTraits {
    1.91 +  typedef typename __move_traits<_Tp>::implemented _MvImpRet;
    1.92 +#if defined (__BORLANDC__)
    1.93 +  typedef typename __selectT<_MvImpRet,
    1.94 +#else
    1.95 +  enum {_MvImp = __type2bool<_MvImpRet>::_Ret};
    1.96 +  typedef typename __select<_MvImp,
    1.97 +#endif
    1.98 +                            __move_source<_Tp>,
    1.99 +                            _Tp const&>::_Ret _Type;
   1.100 +};
   1.101 +
   1.102 +//The helper function
   1.103 +template <class _Tp>
   1.104 +inline _STLP_TYPENAME_ON_RETURN_TYPE _MoveSourceTraits<_Tp>::_Type
   1.105 +_AsMoveSource (_Tp &src) {
   1.106 +  typedef typename _MoveSourceTraits<_Tp>::_Type _SrcType;
   1.107 +  return _SrcType(src);
   1.108 +}
   1.109 +
   1.110 +//Helper structs used for many class.
   1.111 +template <class _Tp>
   1.112 +struct __move_traits_aux {
   1.113 +  typedef typename __move_traits<_Tp>::implemented implemented;
   1.114 +  typedef typename __move_traits<_Tp>::complete complete;
   1.115 +};
   1.116 +
   1.117 +template <class _Tp1, class _Tp2>
   1.118 +struct __move_traits_aux2 {
   1.119 +  typedef __move_traits<_Tp1> _MoveTraits1;
   1.120 +  typedef __move_traits<_Tp2> _MoveTraits2;
   1.121 +
   1.122 +  typedef typename _Lor2<typename _MoveTraits1::implemented,
   1.123 +                         typename _MoveTraits2::implemented>::_Ret implemented;
   1.124 +  typedef typename _Land2<typename _MoveTraits1::complete,
   1.125 +                          typename _MoveTraits2::complete>::_Ret complete;
   1.126 +};
   1.127 +
   1.128 +/*
   1.129 + * Most of the time a class implement a move constructor but its use depends
   1.130 + * on a third party, this is what the following struct are for.
   1.131 + */
   1.132 +template <class _Tp>
   1.133 +struct __move_traits_help {
   1.134 +  typedef __true_type implemented;
   1.135 +  typedef typename __move_traits<_Tp>::complete complete;
   1.136 +};
   1.137 +
   1.138 +template <class _Tp1, class _Tp2>
   1.139 +struct __move_traits_help1 {
   1.140 +  typedef __move_traits<_Tp1> _MoveTraits1;
   1.141 +  typedef __move_traits<_Tp2> _MoveTraits2;
   1.142 +
   1.143 +  typedef typename _Lor2<typename _MoveTraits1::implemented,
   1.144 +                         typename _MoveTraits2::implemented>::_Ret implemented;
   1.145 +  typedef typename _Land2<typename _MoveTraits1::complete,
   1.146 +                          typename _MoveTraits2::complete>::_Ret complete;
   1.147 +};
   1.148 +
   1.149 +template <class _Tp1, class _Tp2>
   1.150 +struct __move_traits_help2 {
   1.151 +  typedef __move_traits<_Tp1> _MoveTraits1;
   1.152 +  typedef __move_traits<_Tp2> _MoveTraits2;
   1.153 +
   1.154 +  typedef __stlp_movable implemented;
   1.155 +  typedef typename _Land2<typename _MoveTraits1::complete,
   1.156 +                          typename _MoveTraits2::complete>::_Ret complete;
   1.157 +};
   1.158 +
   1.159 +_STLP_MOVE_TO_STD_NAMESPACE
   1.160 +
   1.161 +_STLP_END_NAMESPACE
   1.162 +
   1.163 +#endif /* _STLP_MOVE_CONSTRUCT_FWK_H */