reference_content.hpp
Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 // boost detail/reference_content.hpp header file
00003 // See http://www.boost.org for updates, documentation, and revision history.
00004 //-----------------------------------------------------------------------------
00005 //
00006 // Copyright (c) 2003
00007 // Eric Friedman
00008 //
00009 // Distributed under the Boost Software License, Version 1.0. (See
00010 // accompanying file LICENSE_1_0.txt or copy at
00011 // http://www.boost.org/LICENSE_1_0.txt)
00012 
00013 #ifndef BOOST_DETAIL_REFERENCE_CONTENT_HPP
00014 #define BOOST_DETAIL_REFERENCE_CONTENT_HPP
00015 
00016 #include "boost/config.hpp"
00017 
00018 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
00019 #   include "boost/mpl/bool.hpp"
00020 #   include "boost/type_traits/has_nothrow_copy.hpp"
00021 #else
00022 #   include "boost/mpl/if.hpp"
00023 #   include "boost/type_traits/is_reference.hpp"
00024 #endif
00025 
00026 #include "boost/mpl/void.hpp"
00027 
00028 namespace boost {
00029 
00030 namespace detail {
00031 
00033 // (detail) class template reference_content
00034 //
00035 // Non-Assignable wrapper for references.
00036 //
00037 template <typename RefT>
00038 class reference_content
00039 {
00040 private: // representation
00041 
00042     RefT content_;
00043 
00044 public: // structors
00045 
00046     ~reference_content()
00047     {
00048     }
00049 
00050     reference_content(RefT r)
00051         : content_( r )
00052     {
00053     }
00054 
00055     reference_content(const reference_content& operand)
00056         : content_( operand.content_ )
00057     {
00058     }
00059 
00060 private: // non-Assignable
00061 
00062     reference_content& operator=(const reference_content&);
00063 
00064 public: // queries
00065 
00066     RefT get() const
00067     {
00068         return content_;
00069     }
00070 
00071 };
00072 
00074 // (detail) metafunction make_reference_content
00075 //
00076 // Wraps with reference_content if specified type is reference.
00077 //
00078 
00079 template <typename T = mpl::void_> struct make_reference_content;
00080 
00081 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
00082 
00083 template <typename T>
00084 struct make_reference_content
00085 {
00086     typedef T type;
00087 };
00088 
00089 template <typename T>
00090 struct make_reference_content< T& >
00091 {
00092     typedef reference_content<T&> type;
00093 };
00094 
00095 #else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
00096 
00097 template <typename T>
00098 struct make_reference_content
00099     : mpl::if_<
00100           is_reference<T>
00101         , reference_content<T>
00102         , T
00103         >
00104 {
00105 };
00106 
00107 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround
00108 
00109 template <>
00110 struct make_reference_content< mpl::void_ >
00111 {
00112     template <typename T>
00113     struct apply
00114         : make_reference_content<T>
00115     {
00116     };
00117 
00118     typedef mpl::void_ type;
00119 };
00120 
00121 } // namespace detail
00122 
00124 // reference_content<T&> type traits specializations
00125 //
00126 
00127 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
00128 
00129 template <typename T>
00130 struct has_nothrow_copy<
00131       ::boost::detail::reference_content< T& >
00132     >
00133     : mpl::true_
00134 {
00135 };
00136 
00137 #endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
00138 
00139 } // namespace boost
00140 
00141 #endif // BOOST_DETAIL_REFERENCE_CONTENT_HPP


appl
Author(s): petercai
autogenerated on Tue Jan 7 2014 11:02:29