Publishing R3
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / common / boost / 1.64.0 / include / boost-1_64 / boost / core / addressof.hpp
1 /*
2 Copyright (C) 2002 Brad King (brad.king@kitware.com)
3                    Douglas Gregor (gregod@cs.rpi.edu)
4
5 Copyright (C) 2002, 2008, 2013 Peter Dimov
6
7 Copyright (C) 2017 Glen Joseph Fernandes (glenjofe@gmail.com)
8
9 Distributed under the Boost Software License, Version 1.0.
10 (See accompanying file LICENSE_1_0.txt or copy at
11 http://www.boost.org/LICENSE_1_0.txt)
12 */
13
14 #ifndef BOOST_CORE_ADDRESSOF_HPP
15 #define BOOST_CORE_ADDRESSOF_HPP
16
17 #include <boost/config.hpp>
18
19 #if defined(BOOST_MSVC_FULL_VER) && BOOST_MSVC_FULL_VER >= 190024215
20 #define BOOST_CORE_HAS_BUILTIN_ADDRESSOF
21 #elif defined(BOOST_GCC) && BOOST_GCC >= 70000
22 #define BOOST_CORE_HAS_BUILTIN_ADDRESSOF
23 #elif defined(__has_builtin)
24 #if __has_builtin(__builtin_addressof)
25 #define BOOST_CORE_HAS_BUILTIN_ADDRESSOF
26 #endif
27 #endif
28
29 #if defined(BOOST_CORE_HAS_BUILTIN_ADDRESSOF)
30 #if defined(BOOST_NO_CXX11_CONSTEXPR)
31 #define BOOST_CORE_NO_CONSTEXPR_ADDRESSOF
32 #endif
33
34 namespace boost {
35
36 template<class T>
37 BOOST_CONSTEXPR inline T*
38 addressof(T& o) BOOST_NOEXCEPT
39 {
40     return __builtin_addressof(o);
41 }
42
43 } /* boost */
44 #else
45 #include <boost/detail/workaround.hpp>
46 #include <cstddef>
47
48 namespace boost {
49 namespace detail {
50
51 template<class T>
52 class addressof_ref {
53 public:
54     BOOST_FORCEINLINE addressof_ref(T& o) BOOST_NOEXCEPT
55         : o_(o) { }
56     BOOST_FORCEINLINE operator T&() const BOOST_NOEXCEPT {
57         return o_;
58     }
59 private:
60     addressof_ref& operator=(const addressof_ref&);
61     T& o_;
62 };
63
64 template<class T>
65 struct address_of {
66     static BOOST_FORCEINLINE T* get(T& o, long) BOOST_NOEXCEPT {
67         return reinterpret_cast<T*>(&
68             const_cast<char&>(reinterpret_cast<const volatile char&>(o)));
69     }
70     static BOOST_FORCEINLINE T* get(T* p, int) BOOST_NOEXCEPT {
71         return p;
72     }
73 };
74
75 #if !defined(BOOST_NO_CXX11_NULLPTR)
76 #if !defined(BOOST_NO_CXX11_DECLTYPE) && \
77     (defined(__INTEL_COMPILER) || \
78         (defined(__clang__) && !defined(_LIBCPP_VERSION)))
79 typedef decltype(nullptr) addressof_null_t;
80 #else
81 typedef std::nullptr_t addressof_null_t;
82 #endif
83
84 template<>
85 struct address_of<addressof_null_t> {
86     typedef addressof_null_t type;
87     static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT {
88         return &o;
89     }
90 };
91
92 template<>
93 struct address_of<const addressof_null_t> {
94     typedef const addressof_null_t type;
95     static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT {
96         return &o;
97     }
98 };
99
100 template<>
101 struct address_of<volatile addressof_null_t> {
102     typedef volatile addressof_null_t type;
103     static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT {
104         return &o;
105     }
106 };
107
108 template<>
109 struct address_of<const volatile addressof_null_t> {
110     typedef const volatile addressof_null_t type;
111     static BOOST_FORCEINLINE type* get(type& o, int) BOOST_NOEXCEPT {
112         return &o;
113     }
114 };
115 #endif
116
117 } /* detail */
118
119 #if defined(BOOST_NO_CXX11_SFINAE_EXPR) || \
120     defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \
121     defined(BOOST_NO_CXX11_CONSTEXPR) || \
122     defined(BOOST_NO_CXX11_DECLTYPE)
123 #define BOOST_CORE_NO_CONSTEXPR_ADDRESSOF
124
125 template<class T>
126 BOOST_FORCEINLINE T*
127 addressof(T& o) BOOST_NOEXCEPT
128 {
129 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610)) || \
130     BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5120)
131     return detail::address_of<T>::get(o, 0);
132 #else
133     return detail::address_of<T>::get(detail::addressof_ref<T>(o), 0);
134 #endif
135 }
136
137 #if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
138 namespace detail {
139
140 template<class T>
141 struct addressof_result {
142     typedef T* type;
143 };
144
145 } /* detail */
146
147 template<class T, std::size_t N>
148 BOOST_FORCEINLINE typename detail::addressof_result<T[N]>::type
149 addressof(T (&o)[N]) BOOST_NOEXCEPT
150 {
151     return &o;
152 }
153 #endif
154
155 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
156 template<class T, std::size_t N>
157 BOOST_FORCEINLINE
158 T (*addressof(T (&o)[N]) BOOST_NOEXCEPT)[N]
159 {
160    return reinterpret_cast<T(*)[N]>(&o);
161 }
162
163 template<class T, std::size_t N>
164 BOOST_FORCEINLINE
165 const T (*addressof(const T (&o)[N]) BOOST_NOEXCEPT)[N]
166 {
167    return reinterpret_cast<const T(*)[N]>(&o);
168 }
169 #endif
170 #else
171 namespace detail {
172
173 template<class T>
174 T&& addressof_declval() BOOST_NOEXCEPT;
175
176 template<class>
177 struct addressof_void {
178     typedef void type;
179 };
180
181 template<class T, class E = void>
182 struct addressof_member_operator {
183     static constexpr bool value = false;
184 };
185
186 template<class T>
187 struct addressof_member_operator<T, typename
188     addressof_void<decltype(addressof_declval<T&>().operator&())>::type> {
189     static constexpr bool value = true;
190 };
191
192 #if BOOST_WORKAROUND(BOOST_INTEL, < 1600)
193 struct addressof_addressable { };
194
195 addressof_addressable*
196 operator&(addressof_addressable&) BOOST_NOEXCEPT;
197 #endif
198
199 template<class T, class E = void>
200 struct addressof_non_member_operator {
201     static constexpr bool value = false;
202 };
203
204 template<class T>
205 struct addressof_non_member_operator<T, typename
206     addressof_void<decltype(operator&(addressof_declval<T&>()))>::type> {
207     static constexpr bool value = true;
208 };
209
210 template<class T, class E = void>
211 struct addressof_expression {
212     static constexpr bool value = false;
213 };
214
215 template<class T>
216 struct addressof_expression<T,
217     typename addressof_void<decltype(&addressof_declval<T&>())>::type> {
218     static constexpr bool value = true;
219 };
220
221 template<class T>
222 struct addressof_is_constexpr {
223     static constexpr bool value = addressof_expression<T>::value &&
224         !addressof_member_operator<T>::value &&
225         !addressof_non_member_operator<T>::value;
226 };
227
228 template<bool E, class T>
229 struct addressof_if { };
230
231 template<class T>
232 struct addressof_if<true, T> {
233     typedef T* type;
234 };
235
236 template<class T>
237 BOOST_FORCEINLINE
238 typename addressof_if<!addressof_is_constexpr<T>::value, T>::type
239 addressof(T& o) BOOST_NOEXCEPT
240 {
241     return address_of<T>::get(addressof_ref<T>(o), 0);
242 }
243
244 template<class T>
245 constexpr BOOST_FORCEINLINE
246 typename addressof_if<addressof_is_constexpr<T>::value, T>::type
247 addressof(T& o) BOOST_NOEXCEPT
248 {
249     return &o;
250 }
251
252 } /* detail */
253
254 template<class T>
255 constexpr BOOST_FORCEINLINE T*
256 addressof(T& o) BOOST_NOEXCEPT
257 {
258     return detail::addressof(o);
259 }
260 #endif
261
262 } /* boost */
263 #endif
264
265 #endif