ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

_move_construct_fwk.h
Go to the documentation of this file.
00001 /*
00002  *
00003  * Copyright (c) 2003
00004  * Francois Dumont
00005  *
00006  * This material is provided "as is", with absolutely no warranty expressed
00007  * or implied. Any use is at your own risk.
00008  *
00009  * Permission to use or copy this software for any purpose is hereby granted
00010  * without fee, provided the above notices are retained on all copies.
00011  * Permission to modify the code and to distribute modified code is granted,
00012  * provided the above notices are retained, and a notice that the code was
00013  * modified is included with the above copyright notice.
00014  *
00015  */
00016 
00017 #ifndef _STLP_MOVE_CONSTRUCT_FWK_H
00018 #define _STLP_MOVE_CONSTRUCT_FWK_H
00019 
00020 #ifndef _STLP_TYPE_TRAITS_H
00021 #  include <stl/type_traits.h>
00022 #endif
00023 
00024 _STLP_BEGIN_NAMESPACE
00025 
00026 /*************************************************************
00027  * Move constructor framework
00028  *************************************************************/
00029 
00030 /*************************************************************
00031  *Partial move:
00032  *The source HAS to be a valid instance after the move!
00033  *************************************************************/
00034 template <class _Tp>
00035 class __move_source {
00036 public:
00037   explicit __move_source (_Tp &_src) : _M_data(_src)
00038   {}
00039 
00040   _Tp& get() const
00041   { return _M_data; }
00042 private:
00043   _Tp &_M_data;
00044 
00045   //We explicitely forbid assignment to avoid warning:
00046   typedef __move_source<_Tp> _Self;
00047   _Self& operator = (_Self const&);
00048 };
00049 
00050 //Class used to signal move constructor support, implementation and type.
00051 template <class _Tp>
00052 struct __move_traits {
00053   /*
00054    * implemented tells if a the special move constructor has to be called or the classic
00055    * copy constructor is just fine. Most of the time the copy constructor is fine only
00056    * if the following info is true.
00057    */
00058 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && \
00059    !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && \
00060    !defined (_STLP_NO_MOVE_SEMANTIC)
00061   typedef typename _IsSTLportClass<_Tp>::_Ret implemented;
00062 #else
00063   typedef __false_type implemented;
00064 #endif
00065   /*
00066    * complete tells if the move is complete or partial, that is to say, does the source
00067    * needs to be destroyed once it has been moved.
00068    */
00069 #  if defined (__BORLANDC__) && (__BORLANDC__ >= 0x564)
00070   typedef __type_traits<_Tp>::has_trivial_destructor _TpMoveComplete;
00071   typedef typename __bool2type<__type2bool<_TpMoveComplete>::_Ret>::_Ret complete;
00072 #  else
00073   typedef typename __type_traits<_Tp>::has_trivial_destructor complete;
00074 #  endif
00075 };
00076 
00077 _STLP_MOVE_TO_PRIV_NAMESPACE
00078 
00079 /*
00080  * This struct should never be used if the user has not explicitely stipulated
00081  * that its class support the full move concept. To check that the return type
00082  * in such a case will be __invalid_source<_Tp> to generate a compile error
00083  * revealing the configuration problem.
00084  */
00085 template <class _Tp>
00086 struct _MoveSourceTraits {
00087   typedef typename __move_traits<_Tp>::implemented _MvImpRet;
00088 #if defined (__BORLANDC__)
00089   typedef typename __selectT<_MvImpRet,
00090 #else
00091   enum {_MvImp = __type2bool<_MvImpRet>::_Ret};
00092   typedef typename __select<_MvImp,
00093 #endif
00094                             __move_source<_Tp>,
00095                             _Tp const&>::_Ret _Type;
00096 };
00097 
00098 //The helper function
00099 template <class _Tp>
00100 inline _STLP_TYPENAME_ON_RETURN_TYPE _MoveSourceTraits<_Tp>::_Type
00101 _AsMoveSource (_Tp &src) {
00102   typedef typename _MoveSourceTraits<_Tp>::_Type _SrcType;
00103   return _SrcType(src);
00104 }
00105 
00106 //Helper structs used for many class.
00107 template <class _Tp>
00108 struct __move_traits_aux {
00109   typedef typename __move_traits<_Tp>::implemented implemented;
00110   typedef typename __move_traits<_Tp>::complete complete;
00111 };
00112 
00113 template <class _Tp1, class _Tp2>
00114 struct __move_traits_aux2 {
00115   typedef __move_traits<_Tp1> _MoveTraits1;
00116   typedef __move_traits<_Tp2> _MoveTraits2;
00117 
00118   typedef typename _Lor2<typename _MoveTraits1::implemented,
00119                          typename _MoveTraits2::implemented>::_Ret implemented;
00120   typedef typename _Land2<typename _MoveTraits1::complete,
00121                           typename _MoveTraits2::complete>::_Ret complete;
00122 };
00123 
00124 /*
00125  * Most of the time a class implement a move constructor but its use depends
00126  * on a third party, this is what the following struct are for.
00127  */
00128 template <class _Tp>
00129 struct __move_traits_help {
00130   typedef __true_type implemented;
00131   typedef typename __move_traits<_Tp>::complete complete;
00132 };
00133 
00134 template <class _Tp1, class _Tp2>
00135 struct __move_traits_help1 {
00136   typedef __move_traits<_Tp1> _MoveTraits1;
00137   typedef __move_traits<_Tp2> _MoveTraits2;
00138 
00139   typedef typename _Lor2<typename _MoveTraits1::implemented,
00140                          typename _MoveTraits2::implemented>::_Ret implemented;
00141   typedef typename _Land2<typename _MoveTraits1::complete,
00142                           typename _MoveTraits2::complete>::_Ret complete;
00143 };
00144 
00145 template <class _Tp1, class _Tp2>
00146 struct __move_traits_help2 {
00147   typedef __move_traits<_Tp1> _MoveTraits1;
00148   typedef __move_traits<_Tp2> _MoveTraits2;
00149 
00150   typedef __true_type implemented;
00151   typedef typename _Land2<typename _MoveTraits1::complete,
00152                           typename _MoveTraits2::complete>::_Ret complete;
00153 };
00154 
00155 _STLP_MOVE_TO_STD_NAMESPACE
00156 
00157 _STLP_END_NAMESPACE
00158 
00159 #endif /* _STLP_MOVE_CONSTRUCT_FWK_H */

Generated on Sun May 27 2012 04:29:18 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.