epoc32/include/stdapis/boost/ref.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/ref.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,178 @@
     1.4 +#ifndef BOOST_REF_HPP_INCLUDED
     1.5 +#define BOOST_REF_HPP_INCLUDED
     1.6 +
     1.7 +// MS compatible compilers support #pragma once
     1.8 +
     1.9 +#if defined(_MSC_VER) && (_MSC_VER >= 1020)
    1.10 +# pragma once
    1.11 +#endif
    1.12 +
    1.13 +#include <boost/config.hpp>
    1.14 +#include <boost/utility/addressof.hpp>
    1.15 +#include <boost/mpl/bool.hpp>
    1.16 +#include <boost/detail/workaround.hpp>
    1.17 +
    1.18 +//
    1.19 +//  ref.hpp - ref/cref, useful helper functions
    1.20 +//
    1.21 +//  Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
    1.22 +//  Copyright (C) 2001, 2002 Peter Dimov
    1.23 +//  Copyright (C) 2002 David Abrahams
    1.24 +//
    1.25 +// Distributed under the Boost Software License, Version 1.0. (See
    1.26 +// accompanying file LICENSE_1_0.txt or copy at
    1.27 +// http://www.boost.org/LICENSE_1_0.txt)
    1.28 +//
    1.29 +//  See http://www.boost.org/libs/bind/ref.html for documentation.
    1.30 +//
    1.31 +
    1.32 +namespace boost
    1.33 +{
    1.34 +
    1.35 +template<class T> class reference_wrapper
    1.36 +{ 
    1.37 +public:
    1.38 +    typedef T type;
    1.39 +
    1.40 +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1300 )
    1.41 +
    1.42 +    explicit reference_wrapper(T& t): t_(&t) {}
    1.43 +
    1.44 +#else
    1.45 +
    1.46 +    explicit reference_wrapper(T& t): t_(boost::addressof(t)) {}
    1.47 +
    1.48 +#endif
    1.49 +
    1.50 +    operator T& () const { return *t_; }
    1.51 +
    1.52 +    T& get() const { return *t_; }
    1.53 +
    1.54 +    T* get_pointer() const { return t_; }
    1.55 +
    1.56 +private:
    1.57 +
    1.58 +    T* t_;
    1.59 +};
    1.60 +
    1.61 +# if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) )
    1.62 +#  define BOOST_REF_CONST
    1.63 +# else
    1.64 +#  define BOOST_REF_CONST const
    1.65 +# endif
    1.66 +
    1.67 +template<class T> inline reference_wrapper<T> BOOST_REF_CONST ref(T & t)
    1.68 +{ 
    1.69 +    return reference_wrapper<T>(t);
    1.70 +}
    1.71 +
    1.72 +template<class T> inline reference_wrapper<T const> BOOST_REF_CONST cref(T const & t)
    1.73 +{
    1.74 +    return reference_wrapper<T const>(t);
    1.75 +}
    1.76 +
    1.77 +# undef BOOST_REF_CONST
    1.78 +
    1.79 +# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
    1.80 +
    1.81 +template<typename T>
    1.82 +class is_reference_wrapper
    1.83 +    : public mpl::false_
    1.84 +{
    1.85 +};
    1.86 +
    1.87 +template<typename T>
    1.88 +class unwrap_reference
    1.89 +{
    1.90 + public:
    1.91 +    typedef T type;
    1.92 +};
    1.93 +
    1.94 +#  define AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(X) \
    1.95 +template<typename T> \
    1.96 +class is_reference_wrapper< X > \
    1.97 +    : public mpl::true_ \
    1.98 +{ \
    1.99 +}; \
   1.100 +\
   1.101 +template<typename T> \
   1.102 +class unwrap_reference< X > \
   1.103 +{ \
   1.104 + public: \
   1.105 +    typedef T type; \
   1.106 +}; \
   1.107 +/**/
   1.108 +
   1.109 +AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper<T>)
   1.110 +#if !defined(BOOST_NO_CV_SPECIALIZATIONS)
   1.111 +AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper<T> const)
   1.112 +AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper<T> volatile)
   1.113 +AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper<T> const volatile)
   1.114 +#endif
   1.115 +
   1.116 +#  undef AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF
   1.117 +
   1.118 +# else // no partial specialization
   1.119 +
   1.120 +} // namespace boost
   1.121 +
   1.122 +#include <boost/type.hpp>
   1.123 +
   1.124 +namespace boost
   1.125 +{
   1.126 +
   1.127 +namespace detail
   1.128 +{
   1.129 +  typedef char (&yes_reference_wrapper_t)[1];
   1.130 +  typedef char (&no_reference_wrapper_t)[2];
   1.131 +      
   1.132 +  no_reference_wrapper_t is_reference_wrapper_test(...);
   1.133 +
   1.134 +  template<typename T>
   1.135 +  yes_reference_wrapper_t is_reference_wrapper_test(type< reference_wrapper<T> >);
   1.136 +
   1.137 +  template<bool wrapped>
   1.138 +  struct reference_unwrapper
   1.139 +  {
   1.140 +      template <class T>
   1.141 +      struct apply
   1.142 +      {
   1.143 +          typedef T type;
   1.144 +      };
   1.145 +  };
   1.146 +
   1.147 +  template<>
   1.148 +  struct reference_unwrapper<true>
   1.149 +  {
   1.150 +      template <class T>
   1.151 +      struct apply
   1.152 +      {
   1.153 +          typedef typename T::type type;
   1.154 +      };
   1.155 +  };
   1.156 +}
   1.157 +
   1.158 +template<typename T>
   1.159 +class is_reference_wrapper
   1.160 +{
   1.161 + public:
   1.162 +    BOOST_STATIC_CONSTANT(
   1.163 +        bool, value = (
   1.164 +             sizeof(detail::is_reference_wrapper_test(type<T>()))
   1.165 +            == sizeof(detail::yes_reference_wrapper_t)));
   1.166 +    
   1.167 +    typedef ::boost::mpl::bool_<value> type;
   1.168 +};
   1.169 +
   1.170 +template <typename T>
   1.171 +class unwrap_reference
   1.172 +    : public detail::reference_unwrapper<
   1.173 +        is_reference_wrapper<T>::value
   1.174 +      >::template apply<T>
   1.175 +{};
   1.176 +
   1.177 +# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
   1.178 +
   1.179 +} // namespace boost
   1.180 +
   1.181 +#endif // #ifndef BOOST_REF_HPP_INCLUDED