]> git.lyx.org Git - lyx.git/blob - boost/boost/detail/reference_content.hpp
Boost 1.31.0
[lyx.git] / boost / boost / detail / reference_content.hpp
1 //-----------------------------------------------------------------------------
2 // boost detail/reference_content.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
5 //
6 // Copyright (c) 2003
7 // Eric Friedman
8 //
9 // Permission to use, copy, modify, distribute and sell this software
10 // and its documentation for any purpose is hereby granted without fee, 
11 // provided that the above copyright notice appears in all copies and 
12 // that both the copyright notice and this permission notice appear in 
13 // supporting documentation. No representations are made about the 
14 // suitability of this software for any purpose. It is provided "as is" 
15 // without express or implied warranty.
16
17 #ifndef BOOST_DETAIL_REFERENCE_CONTENT_HPP
18 #define BOOST_DETAIL_REFERENCE_CONTENT_HPP
19
20 #include "boost/config.hpp"
21
22 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
23 #   include "boost/mpl/bool.hpp"
24 #   include "boost/type_traits/has_nothrow_copy.hpp"
25 #else
26 #   include "boost/mpl/if.hpp"
27 #   include "boost/type_traits/is_reference.hpp"
28 #endif
29
30 #include "boost/mpl/void.hpp"
31
32 namespace boost {
33
34 namespace detail {
35
36 ///////////////////////////////////////////////////////////////////////////////
37 // (detail) class template reference_content
38 //
39 // Non-Assignable wrapper for references.
40 //
41 template <typename RefT>
42 class reference_content
43 {
44 private: // representation
45
46     RefT content_;
47
48 public: // structors
49
50     ~reference_content()
51     {
52     }
53
54     reference_content(RefT r)
55         : content_( r )
56     {
57     }
58
59     reference_content(const reference_content& operand)
60         : content_( operand.content_ )
61     {
62     }
63
64 private: // non-Assignable
65
66     reference_content& operator=(const reference_content&);
67
68 public: // queries
69
70     RefT get() const
71     {
72         return content_;
73     }
74
75 };
76
77 ///////////////////////////////////////////////////////////////////////////////
78 // (detail) metafunction make_reference_content
79 //
80 // Wraps with reference_content if specified type is reference.
81 //
82
83 template <typename T = mpl::void_> struct make_reference_content;
84
85 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
86
87 template <typename T>
88 struct make_reference_content
89 {
90     typedef T type;
91 };
92
93 template <typename T>
94 struct make_reference_content< T& >
95 {
96     typedef reference_content<T&> type;
97 };
98
99 #else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
100
101 template <typename T>
102 struct make_reference_content
103     : mpl::if_<
104           is_reference<T>
105         , reference_content<T>
106         , T
107         >
108 {
109 };
110
111 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround
112
113 template <>
114 struct make_reference_content< mpl::void_ >
115 {
116     template <typename T>
117     struct apply
118         : make_reference_content<T>
119     {
120     };
121
122     typedef mpl::void_ type;
123 };
124
125 } // namespace detail
126
127 ///////////////////////////////////////////////////////////////////////////////
128 // reference_content<T&> type traits specializations
129 //
130
131 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
132
133 template <typename T>
134 struct has_nothrow_copy<
135       ::boost::detail::reference_content< T& >
136     >
137     : mpl::true_
138 {
139 };
140
141 #endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
142
143 } // namespace boost
144
145 #endif // BOOST_DETAIL_REFERENCE_CONTENT_HPP