annotate DEPENDENCIES/generic/include/boost/core/ref.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents f46d142149f5
children
rev   line source
Chris@102 1 #ifndef BOOST_CORE_REF_HPP
Chris@102 2 #define BOOST_CORE_REF_HPP
Chris@102 3
Chris@102 4 // MS compatible compilers support #pragma once
Chris@102 5
Chris@102 6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
Chris@102 7 # pragma once
Chris@102 8 #endif
Chris@102 9
Chris@102 10 #include <boost/config.hpp>
Chris@102 11 #include <boost/utility/addressof.hpp>
Chris@102 12 #include <boost/detail/workaround.hpp>
Chris@102 13
Chris@102 14 //
Chris@102 15 // ref.hpp - ref/cref, useful helper functions
Chris@102 16 //
Chris@102 17 // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
Chris@102 18 // Copyright (C) 2001, 2002 Peter Dimov
Chris@102 19 // Copyright (C) 2002 David Abrahams
Chris@102 20 //
Chris@102 21 // Copyright (C) 2014 Glen Joseph Fernandes
Chris@102 22 // glenfe at live dot com
Chris@102 23 // Copyright (C) 2014 Agustin Berge
Chris@102 24 //
Chris@102 25 // Distributed under the Boost Software License, Version 1.0. (See
Chris@102 26 // accompanying file LICENSE_1_0.txt or copy at
Chris@102 27 // http://www.boost.org/LICENSE_1_0.txt)
Chris@102 28 //
Chris@102 29 // See http://www.boost.org/libs/core/doc/html/core/ref.html for documentation.
Chris@102 30 //
Chris@102 31
Chris@102 32 /**
Chris@102 33 @file
Chris@102 34 */
Chris@102 35
Chris@102 36 /**
Chris@102 37 Boost namespace.
Chris@102 38 */
Chris@102 39 namespace boost
Chris@102 40 {
Chris@102 41
Chris@102 42 #if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1600 )
Chris@102 43
Chris@102 44 struct ref_workaround_tag {};
Chris@102 45
Chris@102 46 #endif
Chris@102 47
Chris@102 48 // reference_wrapper
Chris@102 49
Chris@102 50 /**
Chris@102 51 @brief Contains a reference to an object of type `T`.
Chris@102 52
Chris@102 53 `reference_wrapper` is primarily used to "feed" references to
Chris@102 54 function templates (algorithms) that take their parameter by
Chris@102 55 value. It provides an implicit conversion to `T&`, which
Chris@102 56 usually allows the function templates to work on references
Chris@102 57 unmodified.
Chris@102 58 */
Chris@102 59 template<class T> class reference_wrapper
Chris@102 60 {
Chris@102 61 public:
Chris@102 62 /**
Chris@102 63 Type `T`.
Chris@102 64 */
Chris@102 65 typedef T type;
Chris@102 66
Chris@102 67 /**
Chris@102 68 Constructs a `reference_wrapper` object that stores a
Chris@102 69 reference to `t`.
Chris@102 70
Chris@102 71 @remark Does not throw.
Chris@102 72 */
Chris@102 73 BOOST_FORCEINLINE explicit reference_wrapper(T& t): t_(boost::addressof(t)) {}
Chris@102 74
Chris@102 75 #if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1600 )
Chris@102 76
Chris@102 77 BOOST_FORCEINLINE explicit reference_wrapper( T & t, ref_workaround_tag ): t_( boost::addressof( t ) ) {}
Chris@102 78
Chris@102 79 #endif
Chris@102 80
Chris@102 81 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
Chris@102 82 /**
Chris@102 83 @remark Construction from a temporary object is disabled.
Chris@102 84 */
Chris@102 85 BOOST_DELETED_FUNCTION(reference_wrapper(T&& t))
Chris@102 86 public:
Chris@102 87 #endif
Chris@102 88
Chris@102 89 /**
Chris@102 90 @return The stored reference.
Chris@102 91 @remark Does not throw.
Chris@102 92 */
Chris@102 93 BOOST_FORCEINLINE operator T& () const { return *t_; }
Chris@102 94
Chris@102 95 /**
Chris@102 96 @return The stored reference.
Chris@102 97 @remark Does not throw.
Chris@102 98 */
Chris@102 99 BOOST_FORCEINLINE T& get() const { return *t_; }
Chris@102 100
Chris@102 101 /**
Chris@102 102 @return A pointer to the object referenced by the stored
Chris@102 103 reference.
Chris@102 104 @remark Does not throw.
Chris@102 105 */
Chris@102 106 BOOST_FORCEINLINE T* get_pointer() const { return t_; }
Chris@102 107
Chris@102 108 private:
Chris@102 109
Chris@102 110 T* t_;
Chris@102 111 };
Chris@102 112
Chris@102 113 // ref
Chris@102 114
Chris@102 115 /**
Chris@102 116 @cond
Chris@102 117 */
Chris@102 118 #if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) )
Chris@102 119 # define BOOST_REF_CONST
Chris@102 120 #else
Chris@102 121 # define BOOST_REF_CONST const
Chris@102 122 #endif
Chris@102 123 /**
Chris@102 124 @endcond
Chris@102 125 */
Chris@102 126
Chris@102 127 /**
Chris@102 128 @return `reference_wrapper<T>(t)`
Chris@102 129 @remark Does not throw.
Chris@102 130 */
Chris@102 131 template<class T> BOOST_FORCEINLINE reference_wrapper<T> BOOST_REF_CONST ref( T & t )
Chris@102 132 {
Chris@102 133 #if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1600 )
Chris@102 134
Chris@102 135 return reference_wrapper<T>( t, ref_workaround_tag() );
Chris@102 136
Chris@102 137 #else
Chris@102 138
Chris@102 139 return reference_wrapper<T>( t );
Chris@102 140
Chris@102 141 #endif
Chris@102 142 }
Chris@102 143
Chris@102 144 // cref
Chris@102 145
Chris@102 146 /**
Chris@102 147 @return `reference_wrapper<T const>(t)`
Chris@102 148 @remark Does not throw.
Chris@102 149 */
Chris@102 150 template<class T> BOOST_FORCEINLINE reference_wrapper<T const> BOOST_REF_CONST cref( T const & t )
Chris@102 151 {
Chris@102 152 return reference_wrapper<T const>(t);
Chris@102 153 }
Chris@102 154
Chris@102 155 #undef BOOST_REF_CONST
Chris@102 156
Chris@102 157 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
Chris@102 158
Chris@102 159 /**
Chris@102 160 @cond
Chris@102 161 */
Chris@102 162 #if defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
Chris@102 163 # define BOOST_REF_DELETE
Chris@102 164 #else
Chris@102 165 # define BOOST_REF_DELETE = delete
Chris@102 166 #endif
Chris@102 167 /**
Chris@102 168 @endcond
Chris@102 169 */
Chris@102 170
Chris@102 171 /**
Chris@102 172 @remark Construction from a temporary object is disabled.
Chris@102 173 */
Chris@102 174 template<class T> void ref(T const&&) BOOST_REF_DELETE;
Chris@102 175
Chris@102 176 /**
Chris@102 177 @remark Construction from a temporary object is disabled.
Chris@102 178 */
Chris@102 179 template<class T> void cref(T const&&) BOOST_REF_DELETE;
Chris@102 180
Chris@102 181 #undef BOOST_REF_DELETE
Chris@102 182
Chris@102 183 #endif
Chris@102 184
Chris@102 185 // is_reference_wrapper
Chris@102 186
Chris@102 187 /**
Chris@102 188 @brief Determine if a type `T` is an instantiation of
Chris@102 189 `reference_wrapper`.
Chris@102 190
Chris@102 191 The value static constant will be true if the type `T` is a
Chris@102 192 specialization of `reference_wrapper`.
Chris@102 193 */
Chris@102 194 template<typename T> struct is_reference_wrapper
Chris@102 195 {
Chris@102 196 BOOST_STATIC_CONSTANT( bool, value = false );
Chris@102 197 };
Chris@102 198
Chris@102 199 /**
Chris@102 200 @cond
Chris@102 201 */
Chris@102 202 template<typename T> struct is_reference_wrapper< reference_wrapper<T> >
Chris@102 203 {
Chris@102 204 BOOST_STATIC_CONSTANT( bool, value = true );
Chris@102 205 };
Chris@102 206
Chris@102 207 #if !defined(BOOST_NO_CV_SPECIALIZATIONS)
Chris@102 208
Chris@102 209 template<typename T> struct is_reference_wrapper< reference_wrapper<T> const >
Chris@102 210 {
Chris@102 211 BOOST_STATIC_CONSTANT( bool, value = true );
Chris@102 212 };
Chris@102 213
Chris@102 214 template<typename T> struct is_reference_wrapper< reference_wrapper<T> volatile >
Chris@102 215 {
Chris@102 216 BOOST_STATIC_CONSTANT( bool, value = true );
Chris@102 217 };
Chris@102 218
Chris@102 219 template<typename T> struct is_reference_wrapper< reference_wrapper<T> const volatile >
Chris@102 220 {
Chris@102 221 BOOST_STATIC_CONSTANT( bool, value = true );
Chris@102 222 };
Chris@102 223
Chris@102 224 #endif // !defined(BOOST_NO_CV_SPECIALIZATIONS)
Chris@102 225
Chris@102 226 /**
Chris@102 227 @endcond
Chris@102 228 */
Chris@102 229
Chris@102 230
Chris@102 231 // unwrap_reference
Chris@102 232
Chris@102 233 /**
Chris@102 234 @brief Find the type in a `reference_wrapper`.
Chris@102 235
Chris@102 236 The `typedef` type is `T::type` if `T` is a
Chris@102 237 `reference_wrapper`, `T` otherwise.
Chris@102 238 */
Chris@102 239 template<typename T> struct unwrap_reference
Chris@102 240 {
Chris@102 241 typedef T type;
Chris@102 242 };
Chris@102 243
Chris@102 244 /**
Chris@102 245 @cond
Chris@102 246 */
Chris@102 247 template<typename T> struct unwrap_reference< reference_wrapper<T> >
Chris@102 248 {
Chris@102 249 typedef T type;
Chris@102 250 };
Chris@102 251
Chris@102 252 #if !defined(BOOST_NO_CV_SPECIALIZATIONS)
Chris@102 253
Chris@102 254 template<typename T> struct unwrap_reference< reference_wrapper<T> const >
Chris@102 255 {
Chris@102 256 typedef T type;
Chris@102 257 };
Chris@102 258
Chris@102 259 template<typename T> struct unwrap_reference< reference_wrapper<T> volatile >
Chris@102 260 {
Chris@102 261 typedef T type;
Chris@102 262 };
Chris@102 263
Chris@102 264 template<typename T> struct unwrap_reference< reference_wrapper<T> const volatile >
Chris@102 265 {
Chris@102 266 typedef T type;
Chris@102 267 };
Chris@102 268
Chris@102 269 #endif // !defined(BOOST_NO_CV_SPECIALIZATIONS)
Chris@102 270
Chris@102 271 /**
Chris@102 272 @endcond
Chris@102 273 */
Chris@102 274
Chris@102 275 // unwrap_ref
Chris@102 276
Chris@102 277 /**
Chris@102 278 @return `unwrap_reference<T>::type&(t)`
Chris@102 279 @remark Does not throw.
Chris@102 280 */
Chris@102 281 template<class T> BOOST_FORCEINLINE typename unwrap_reference<T>::type& unwrap_ref( T & t )
Chris@102 282 {
Chris@102 283 return t;
Chris@102 284 }
Chris@102 285
Chris@102 286 // get_pointer
Chris@102 287
Chris@102 288 /**
Chris@102 289 @cond
Chris@102 290 */
Chris@102 291 template<class T> BOOST_FORCEINLINE T* get_pointer( reference_wrapper<T> const & r )
Chris@102 292 {
Chris@102 293 return r.get_pointer();
Chris@102 294 }
Chris@102 295 /**
Chris@102 296 @endcond
Chris@102 297 */
Chris@102 298
Chris@102 299 } // namespace boost
Chris@102 300
Chris@102 301 #endif // #ifndef BOOST_CORE_REF_HPP