core/ref.hpp
Go to the documentation of this file.
1 #ifndef BOOST_CORE_REF_HPP
2 #define BOOST_CORE_REF_HPP
3 
4 // MS compatible compilers support #pragma once
5 
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
7 # pragma once
8 #endif
9 
10 #include <boost/config.hpp>
13 
14 //
15 // ref.hpp - ref/cref, useful helper functions
16 //
17 // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
18 // Copyright (C) 2001, 2002 Peter Dimov
19 // Copyright (C) 2002 David Abrahams
20 //
21 // Copyright (C) 2014 Glen Joseph Fernandes
22 // glenfe at live dot com
23 // Copyright (C) 2014 Agustin Berge
24 //
25 // Distributed under the Boost Software License, Version 1.0. (See
26 // accompanying file LICENSE_1_0.txt or copy at
27 // http://www.boost.org/LICENSE_1_0.txt)
28 //
29 // See http://www.boost.org/libs/core/doc/html/core/ref.html for documentation.
30 //
31 
39 namespace boost
40 {
41 
42 #if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1600 )
43 
44  struct ref_workaround_tag {};
45 
46 #endif
47 
48 // reference_wrapper
49 
59 template<class T> class reference_wrapper
60 {
61 public:
65  typedef T type;
66 
74 
75 #if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1600 )
76 
77  BOOST_FORCEINLINE explicit reference_wrapper( T & t, ref_workaround_tag ): t_( boost::addressof( t ) ) {}
78 
79 #endif
80 
81 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
82 
85  BOOST_DELETED_FUNCTION(reference_wrapper(T&& t))
86 public:
87 #endif
88 
93  BOOST_FORCEINLINE operator T& () const { return *t_; }
94 
99  BOOST_FORCEINLINE T& get() const { return *t_; }
100 
106  BOOST_FORCEINLINE T* get_pointer() const { return t_; }
107 
108 private:
109 
110  T* t_;
111 };
112 
113 // ref
114 
118 #if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) )
119 # define BOOST_REF_CONST
120 #else
121 # define BOOST_REF_CONST const
122 #endif
123 
131 template<class T> BOOST_FORCEINLINE reference_wrapper<T> BOOST_REF_CONST ref( T & t )
132 {
133 #if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1600 )
134 
135  return reference_wrapper<T>( t, ref_workaround_tag() );
136 
137 #else
138 
139  return reference_wrapper<T>( t );
140 
141 #endif
142 }
143 
144 // cref
145 
150 template<class T> BOOST_FORCEINLINE reference_wrapper<T const> BOOST_REF_CONST cref( T const & t )
151 {
153 }
154 
155 #undef BOOST_REF_CONST
156 
157 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
158 
162 #if defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
163 # define BOOST_REF_DELETE
164 #else
165 # define BOOST_REF_DELETE = delete
166 #endif
167 
174 template<class T> void ref(T const&&) BOOST_REF_DELETE;
175 
179 template<class T> void cref(T const&&) BOOST_REF_DELETE;
180 
181 #undef BOOST_REF_DELETE
182 
183 #endif
184 
185 // is_reference_wrapper
186 
194 template<typename T> struct is_reference_wrapper
195 {
196  BOOST_STATIC_CONSTANT( bool, value = false );
197 };
198 
202 template<typename T> struct is_reference_wrapper< reference_wrapper<T> >
203 {
204  BOOST_STATIC_CONSTANT( bool, value = true );
205 };
206 
207 #if !defined(BOOST_NO_CV_SPECIALIZATIONS)
208 
209 template<typename T> struct is_reference_wrapper< reference_wrapper<T> const >
210 {
211  BOOST_STATIC_CONSTANT( bool, value = true );
212 };
213 
214 template<typename T> struct is_reference_wrapper< reference_wrapper<T> volatile >
215 {
216  BOOST_STATIC_CONSTANT( bool, value = true );
217 };
218 
219 template<typename T> struct is_reference_wrapper< reference_wrapper<T> const volatile >
220 {
221  BOOST_STATIC_CONSTANT( bool, value = true );
222 };
223 
224 #endif // !defined(BOOST_NO_CV_SPECIALIZATIONS)
225 
231 // unwrap_reference
232 
239 template<typename T> struct unwrap_reference
240 {
241  typedef T type;
242 };
243 
247 template<typename T> struct unwrap_reference< reference_wrapper<T> >
248 {
249  typedef T type;
250 };
251 
252 #if !defined(BOOST_NO_CV_SPECIALIZATIONS)
253 
254 template<typename T> struct unwrap_reference< reference_wrapper<T> const >
255 {
256  typedef T type;
257 };
258 
259 template<typename T> struct unwrap_reference< reference_wrapper<T> volatile >
260 {
261  typedef T type;
262 };
263 
264 template<typename T> struct unwrap_reference< reference_wrapper<T> const volatile >
265 {
266  typedef T type;
267 };
268 
269 #endif // !defined(BOOST_NO_CV_SPECIALIZATIONS)
270 
275 // unwrap_ref
276 
281 template<class T> BOOST_FORCEINLINE typename unwrap_reference<T>::type& unwrap_ref( T & t )
282 {
283  return t;
284 }
285 
286 // get_pointer
287 
291 template<class T> BOOST_FORCEINLINE T* get_pointer( reference_wrapper<T> const & r )
292 {
293  return r.get_pointer();
294 }
299 } // namespace boost
300 
301 #endif // #ifndef BOOST_CORE_REF_HPP
Determine if a type T is an instantiation of reference_wrapper.
Definition: core/ref.hpp:194
BOOST_FORCEINLINE T * addressof(T &v)
BOOST_DEDUCED_TYPENAME optional< T >::pointer_const_type get_pointer(optional< T > const &opt)
#define BOOST_DELETED_FUNCTION(fun)
Definition: suffix.hpp:680
BOOST_FORCEINLINE reference_wrapper< T const > BOOST_REF_CONST cref(T const &t)
Definition: core/ref.hpp:150
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
BOOST_FORCEINLINE T * get_pointer() const
Definition: core/ref.hpp:106
GLfloat value
GLdouble t
BOOST_FORCEINLINE reference_wrapper< T > BOOST_REF_CONST ref(T &t)
Definition: core/ref.hpp:131
GLdouble GLdouble r
Contains a reference to an object of type T.
Definition: core/ref.hpp:59
GLenum type
BOOST_FORCEINLINE unwrap_reference< T >::type & unwrap_ref(T &t)
Definition: core/ref.hpp:281
#define BOOST_FORCEINLINE
Definition: suffix.hpp:583
#define BOOST_STATIC_CONSTANT(type, assignment)
Definition: suffix.hpp:394
BOOST_FORCEINLINE reference_wrapper(T &t)
Definition: core/ref.hpp:73
Find the type in a reference_wrapper.
Definition: core/ref.hpp:239


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:39