epoc32/include/stdapis/boost/utility/value_init.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/utility/value_init.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,77 @@
     1.4 +// Copyright 2002, Fernando Luis Cacciola Carballal.
     1.5 +//
     1.6 +// Distributed under the Boost Software License, Version 1.0. (See
     1.7 +// accompanying file LICENSE_1_0.txt or copy at
     1.8 +// http://www.boost.org/LICENSE_1_0.txt)
     1.9 +//
    1.10 +// 21 Ago 2002 (Created) Fernando Cacciola
    1.11 +//
    1.12 +#ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
    1.13 +#define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
    1.14 +
    1.15 +#include "boost/detail/select_type.hpp"
    1.16 +#include "boost/type_traits/cv_traits.hpp"
    1.17 +
    1.18 +namespace boost {
    1.19 +
    1.20 +namespace vinit_detail {
    1.21 +
    1.22 +template<class T>
    1.23 +class const_T_base
    1.24 +{
    1.25 +  protected :
    1.26 +
    1.27 +   const_T_base() : x() {}
    1.28 +
    1.29 +   T x ;
    1.30 +} ;
    1.31 +
    1.32 +template<class T>
    1.33 +struct non_const_T_base
    1.34 +{
    1.35 +  protected :
    1.36 +
    1.37 +   non_const_T_base() : x() {}
    1.38 +
    1.39 +   mutable T x ;
    1.40 +} ;
    1.41 +
    1.42 +template<class T>
    1.43 +struct select_base
    1.44 +{
    1.45 +  typedef typename
    1.46 +    boost::detail::if_true< ::boost::is_const<T>::value >
    1.47 +      ::template then< const_T_base<T>, non_const_T_base<T> >::type type ;
    1.48 +} ;
    1.49 +
    1.50 +} // namespace vinit_detail
    1.51 +
    1.52 +template<class T>
    1.53 +class value_initialized : private vinit_detail::select_base<T>::type
    1.54 +{
    1.55 +  public :
    1.56 +
    1.57 +    value_initialized() {}
    1.58 +
    1.59 +    operator T&() const { return this->x ; }
    1.60 +
    1.61 +    T& data() const { return this->x ; }
    1.62 +
    1.63 +} ;
    1.64 +
    1.65 +template<class T>
    1.66 +T const& get ( value_initialized<T> const& x )
    1.67 +{
    1.68 +  return x.data() ;
    1.69 +}
    1.70 +template<class T>
    1.71 +T& get ( value_initialized<T>& x )
    1.72 +{
    1.73 +  return x.data() ;
    1.74 +}
    1.75 +
    1.76 +} // namespace boost
    1.77 +
    1.78 +
    1.79 +#endif
    1.80 +