epoc32/include/stdapis/boost/variant/recursive_wrapper.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/variant/recursive_wrapper.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,123 @@
     1.4 +//-----------------------------------------------------------------------------
     1.5 +// boost variant/recursive_wrapper.hpp header file
     1.6 +// See http://www.boost.org for updates, documentation, and revision history.
     1.7 +//-----------------------------------------------------------------------------
     1.8 +//
     1.9 +// Copyright (c) 2002-2003
    1.10 +// Eric Friedman, Itay Maman
    1.11 +//
    1.12 +// Distributed under the Boost Software License, Version 1.0. (See
    1.13 +// accompanying file LICENSE_1_0.txt or copy at
    1.14 +// http://www.boost.org/LICENSE_1_0.txt)
    1.15 +
    1.16 +#ifndef BOOST_VARIANT_RECURSIVE_WRAPPER_HPP
    1.17 +#define BOOST_VARIANT_RECURSIVE_WRAPPER_HPP
    1.18 +
    1.19 +#include "boost/variant/recursive_wrapper_fwd.hpp"
    1.20 +#include "boost/checked_delete.hpp"
    1.21 +
    1.22 +namespace boost {
    1.23 +
    1.24 +//////////////////////////////////////////////////////////////////////////
    1.25 +// class template recursive_wrapper
    1.26 +//
    1.27 +// See docs and recursive_wrapper_fwd.hpp for more information.
    1.28 +//
    1.29 +
    1.30 +template <typename T>
    1.31 +class recursive_wrapper
    1.32 +{
    1.33 +public: // typedefs
    1.34 +
    1.35 +    typedef T type;
    1.36 +
    1.37 +private: // representation
    1.38 +
    1.39 +    T* p_;
    1.40 +
    1.41 +public: // structors
    1.42 +
    1.43 +    ~recursive_wrapper();
    1.44 +    recursive_wrapper();
    1.45 +
    1.46 +    recursive_wrapper(const recursive_wrapper& operand);
    1.47 +    recursive_wrapper(const T& operand);
    1.48 +
    1.49 +private: // helpers, for modifiers (below)
    1.50 +
    1.51 +    void assign(const T& rhs);
    1.52 +
    1.53 +public: // modifiers
    1.54 +
    1.55 +    recursive_wrapper& operator=(const recursive_wrapper& rhs)
    1.56 +    {
    1.57 +        assign( rhs.get() );
    1.58 +        return *this;
    1.59 +    }
    1.60 +
    1.61 +    recursive_wrapper& operator=(const T& rhs)
    1.62 +    {
    1.63 +        assign( rhs );
    1.64 +        return *this;
    1.65 +    }
    1.66 +
    1.67 +    void swap(recursive_wrapper& operand)
    1.68 +    {
    1.69 +        T* temp = operand.p_;
    1.70 +        operand.p_ = p_;
    1.71 +        p_ = temp;
    1.72 +    }
    1.73 +
    1.74 +public: // queries
    1.75 +
    1.76 +    T& get() { return *get_pointer(); }
    1.77 +    const T& get() const { return *get_pointer(); }
    1.78 +
    1.79 +    T* get_pointer() { return p_; }
    1.80 +    const T* get_pointer() const { return p_; }
    1.81 +
    1.82 +};
    1.83 +
    1.84 +template <typename T>
    1.85 +recursive_wrapper<T>::~recursive_wrapper()
    1.86 +{
    1.87 +    boost::checked_delete(p_);
    1.88 +}
    1.89 +
    1.90 +template <typename T>
    1.91 +recursive_wrapper<T>::recursive_wrapper()
    1.92 +    : p_(new T)
    1.93 +{
    1.94 +}
    1.95 +
    1.96 +template <typename T>
    1.97 +recursive_wrapper<T>::recursive_wrapper(const recursive_wrapper& operand)
    1.98 +    : p_(new T( operand.get() ))
    1.99 +{
   1.100 +}
   1.101 +
   1.102 +template <typename T>
   1.103 +recursive_wrapper<T>::recursive_wrapper(const T& operand)
   1.104 +    : p_(new T(operand))
   1.105 +{
   1.106 +}
   1.107 +
   1.108 +template <typename T>
   1.109 +void recursive_wrapper<T>::assign(const T& rhs)
   1.110 +{
   1.111 +    this->get() = rhs;
   1.112 +}
   1.113 +
   1.114 +// function template swap
   1.115 +//
   1.116 +// Swaps two recursive_wrapper<T> objects of the same type T.
   1.117 +//
   1.118 +template <typename T>
   1.119 +inline void swap(recursive_wrapper<T>& lhs, recursive_wrapper<T>& rhs)
   1.120 +{
   1.121 +    lhs.swap(rhs);
   1.122 +}
   1.123 +
   1.124 +} // namespace boost
   1.125 +
   1.126 +#endif // BOOST_VARIANT_RECURSIVE_WRAPPER_HPP