NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
scope-lite.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020-2020 Martin Moene
3 //
4 // https://github.com/martinmoene/scope-lite
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 
9 // C++ standard libraries extensions, version 3
10 // https://en.cppreference.com/w/cpp/experimental/lib_extensions_3
11 
12 #ifndef NONSTD_SCOPE_LITE_HPP
13 #define NONSTD_SCOPE_LITE_HPP
14 
15 #define scope_lite_MAJOR 0
16 #define scope_lite_MINOR 2
17 #define scope_lite_PATCH 0
18 
19 #define scope_lite_VERSION scope_STRINGIFY(scope_lite_MAJOR) "." scope_STRINGIFY(scope_lite_MINOR) "." scope_STRINGIFY(scope_lite_PATCH)
20 
21 #define scope_STRINGIFY( x ) scope_STRINGIFY_( x )
22 #define scope_STRINGIFY_( x ) #x
23 
24 // scope-lite configuration:
25 
26 #define scope_SCOPE_DEFAULT 0
27 #define scope_SCOPE_NONSTD 1
28 #define scope_SCOPE_STD 2
29 
30 // tweak header support:
31 
32 #ifdef __has_include
33 # if __has_include(<nonstd/scope.tweak.hpp>)
34 # include <nonstd/scope.tweak.hpp>
35 # endif
36 #define scope_HAVE_TWEAK_HEADER 1
37 #else
38 #define scope_HAVE_TWEAK_HEADER 0
39 //# pragma message("scope.hpp: Note: Tweak header not supported.")
40 #endif
41 
42 // scope selection and configuration:
43 
44 #if !defined( scope_CONFIG_SELECT_SCOPE )
45 # define scope_CONFIG_SELECT_SCOPE ( scope_HAVE_STD_SCOPE ? scope_SCOPE_STD : scope_SCOPE_NONSTD )
46 #endif
47 
48 // #if !defined( scope_CONFIG_STRICT )
49 // # define scope_CONFIG_STRICT 0
50 // #endif
51 
52 // C++ language version detection (C++20 is speculative):
53 // Note: VC14.0/1900 (VS2015) lacks too much from C++14.
54 
55 #ifndef scope_CPLUSPLUS
56 # if defined(_MSVC_LANG ) && !defined(__clang__)
57 # define scope_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG )
58 # else
59 # define scope_CPLUSPLUS __cplusplus
60 # endif
61 #endif
62 
63 #define scope_CPP98_OR_GREATER ( scope_CPLUSPLUS >= 199711L )
64 #define scope_CPP11_OR_GREATER ( scope_CPLUSPLUS >= 201103L )
65 #define scope_CPP14_OR_GREATER ( scope_CPLUSPLUS >= 201402L )
66 #define scope_CPP17_OR_GREATER ( scope_CPLUSPLUS >= 201703L )
67 #define scope_CPP20_OR_GREATER ( scope_CPLUSPLUS >= 202000L )
68 
69 // Use C++yy <scope> if available and requested:
70 
71 #if scope_CPP20_OR_GREATER && defined(__has_include )
72 # if __has_include( <scope> )
73 # define scope_HAVE_STD_SCOPE 1
74 # else
75 # define scope_HAVE_STD_SCOPE 0
76 # endif
77 #else
78 # define scope_HAVE_STD_SCOPE 0
79 #endif
80 
81 #define scope_USES_STD_SCOPE ( (scope_CONFIG_SELECT_SCOPE == scope_SCOPE_STD) || ((scope_CONFIG_SELECT_SCOPE == scope_SCOPE_DEFAULT) && scope_HAVE_STD_SCOPE) )
82 
83 //
84 // Using std <scope>:
85 //
86 
87 #if scope_USES_STD_SCOPE
88 
89 #include <scope>
90 
91 namespace nonstd
92 {
93  using std::scope_exit;
94  using std::scope_fail;
95  using std::scope_success;
96  using std::unique_resource;
97 
102 }
103 
104 #else // scope_USES_STD_SCOPE
105 
106 // half-open range [lo..hi):
107 #define scope_BETWEEN( v, lo, hi ) ( (lo) <= (v) && (v) < (hi) )
108 
109 // Compiler versions:
110 //
111 // MSVC++ 6.0 _MSC_VER == 1200 scope_COMPILER_MSVC_VERSION == 60 (Visual Studio 6.0)
112 // MSVC++ 7.0 _MSC_VER == 1300 scope_COMPILER_MSVC_VERSION == 70 (Visual Studio .NET 2002)
113 // MSVC++ 7.1 _MSC_VER == 1310 scope_COMPILER_MSVC_VERSION == 71 (Visual Studio .NET 2003)
114 // MSVC++ 8.0 _MSC_VER == 1400 scope_COMPILER_MSVC_VERSION == 80 (Visual Studio 2005)
115 // MSVC++ 9.0 _MSC_VER == 1500 scope_COMPILER_MSVC_VERSION == 90 (Visual Studio 2008)
116 // MSVC++ 10.0 _MSC_VER == 1600 scope_COMPILER_MSVC_VERSION == 100 (Visual Studio 2010)
117 // MSVC++ 11.0 _MSC_VER == 1700 scope_COMPILER_MSVC_VERSION == 110 (Visual Studio 2012)
118 // MSVC++ 12.0 _MSC_VER == 1800 scope_COMPILER_MSVC_VERSION == 120 (Visual Studio 2013)
119 // MSVC++ 14.0 _MSC_VER == 1900 scope_COMPILER_MSVC_VERSION == 140 (Visual Studio 2015)
120 // MSVC++ 14.1 _MSC_VER >= 1910 scope_COMPILER_MSVC_VERSION == 141 (Visual Studio 2017)
121 // MSVC++ 14.2 _MSC_VER >= 1920 scope_COMPILER_MSVC_VERSION == 142 (Visual Studio 2019)
122 
123 #if defined(_MSC_VER ) && !defined(__clang__)
124 # define scope_COMPILER_MSVC_VER (_MSC_VER )
125 # define scope_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * ( 5 + (_MSC_VER < 1900 ) ) )
126 #else
127 # define scope_COMPILER_MSVC_VER 0
128 # define scope_COMPILER_MSVC_VERSION 0
129 #endif
130 
131 // Courtesy of https://github.com/gsl-lite/gsl-lite
132 // AppleClang 7.0.0 __apple_build_version__ == 7000172 scope_COMPILER_APPLECLANG_VERSION == 700 (Xcode 7.0, 7.0.1) (LLVM 3.7.0)
133 // AppleClang 7.0.0 __apple_build_version__ == 7000176 scope_COMPILER_APPLECLANG_VERSION == 700 (Xcode 7.1) (LLVM 3.7.0)
134 // AppleClang 7.0.2 __apple_build_version__ == 7000181 scope_COMPILER_APPLECLANG_VERSION == 702 (Xcode 7.2, 7.2.1) (LLVM 3.7.0)
135 // AppleClang 7.3.0 __apple_build_version__ == 7030029 scope_COMPILER_APPLECLANG_VERSION == 730 (Xcode 7.3) (LLVM 3.8.0)
136 // AppleClang 7.3.0 __apple_build_version__ == 7030031 scope_COMPILER_APPLECLANG_VERSION == 730 (Xcode 7.3.1) (LLVM 3.8.0)
137 // AppleClang 8.0.0 __apple_build_version__ == 8000038 scope_COMPILER_APPLECLANG_VERSION == 800 (Xcode 8.0) (LLVM 3.9.0)
138 // AppleClang 8.0.0 __apple_build_version__ == 8000042 scope_COMPILER_APPLECLANG_VERSION == 800 (Xcode 8.1, 8.2, 8.2.1) (LLVM 3.9.0)
139 // AppleClang 8.1.0 __apple_build_version__ == 8020038 scope_COMPILER_APPLECLANG_VERSION == 810 (Xcode 8.3) (LLVM 3.9.0)
140 // AppleClang 8.1.0 __apple_build_version__ == 8020041 scope_COMPILER_APPLECLANG_VERSION == 810 (Xcode 8.3.1) (LLVM 3.9.0)
141 // AppleClang 8.1.0 __apple_build_version__ == 8020042 scope_COMPILER_APPLECLANG_VERSION == 810 (Xcode 8.3.2, 8.3.3) (LLVM 3.9.0)
142 // AppleClang 9.0.0 __apple_build_version__ == 9000037 scope_COMPILER_APPLECLANG_VERSION == 900 (Xcode 9.0) (LLVM 4.0.0?)
143 // AppleClang 9.0.0 __apple_build_version__ == 9000038 scope_COMPILER_APPLECLANG_VERSION == 900 (Xcode 9.1) (LLVM 4.0.0?)
144 // AppleClang 9.0.0 __apple_build_version__ == 9000039 scope_COMPILER_APPLECLANG_VERSION == 900 (Xcode 9.2) (LLVM 4.0.0?)
145 // AppleClang 9.1.0 __apple_build_version__ == 9020039 scope_COMPILER_APPLECLANG_VERSION == 910 (Xcode 9.3, 9.3.1) (LLVM 5.0.2?)
146 // AppleClang 9.1.0 __apple_build_version__ == 9020039 scope_COMPILER_APPLECLANG_VERSION == 910 (Xcode 9.4, 9.4.1) (LLVM 5.0.2?)
147 // AppleClang 10.0.0 __apple_build_version__ == 10001145 scope_COMPILER_APPLECLANG_VERSION == 1000 (Xcode 10.0, 10.1) (LLVM 6.0.1?)
148 // AppleClang 10.0.1 __apple_build_version__ == 10010046 scope_COMPILER_APPLECLANG_VERSION == 1001 (Xcode 10.2, 10.2.1, 10.3) (LLVM 7.0.0?)
149 // AppleClang 11.0.0 __apple_build_version__ == 11000033 scope_COMPILER_APPLECLANG_VERSION == 1100 (Xcode 11.1, 11.2, 11.3) (LLVM 8.0.0?)
150 
151 #define scope_COMPILER_VERSION( major, minor, patch ) ( 10 * ( 10 * (major) + (minor) ) + (patch) )
152 
153 #if defined( __apple_build_version__ )
154 # define scope_COMPILER_APPLECLANG_VERSION scope_COMPILER_VERSION( __clang_major__, __clang_minor__, __clang_patchlevel__ )
155 # define scope_COMPILER_CLANG_VERSION 0
156 #elif defined( __clang__ )
157 # define scope_COMPILER_APPLECLANG_VERSION 0
158 # define scope_COMPILER_CLANG_VERSION scope_COMPILER_VERSION( __clang_major__, __clang_minor__, __clang_patchlevel__ )
159 #else
160 # define scope_COMPILER_APPLECLANG_VERSION 0
161 # define scope_COMPILER_CLANG_VERSION 0
162 #endif
163 
164 #if defined(__GNUC__) && !defined(__clang__)
165 # define scope_COMPILER_GNUC_VERSION scope_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
166 #else
167 # define scope_COMPILER_GNUC_VERSION 0
168 #endif
169 
170 // Presence of language and library features:
171 
172 #define scope_HAVE( feature ) ( scope_HAVE_##feature )
173 
174 #ifdef _HAS_CPP0X
175 # define scope_HAS_CPP0X _HAS_CPP0X
176 #else
177 # define scope_HAS_CPP0X 0
178 #endif
179 
180 #define scope_CPP11_90 (scope_CPP11_OR_GREATER || scope_COMPILER_MSVC_VER >= 1500)
181 #define scope_CPP11_100 (scope_CPP11_OR_GREATER || scope_COMPILER_MSVC_VER >= 1600)
182 #define scope_CPP11_110 (scope_CPP11_OR_GREATER || scope_COMPILER_MSVC_VER >= 1700)
183 #define scope_CPP11_120 (scope_CPP11_OR_GREATER || scope_COMPILER_MSVC_VER >= 1800)
184 #define scope_CPP11_140 (scope_CPP11_OR_GREATER || scope_COMPILER_MSVC_VER >= 1900)
185 
186 #define scope_CPP14_000 (scope_CPP14_OR_GREATER)
187 
188 #define scope_CPP17_000 (scope_CPP17_OR_GREATER)
189 #define scope_CPP17_140 (scope_CPP17_OR_GREATER || scope_COMPILER_MSVC_VER >= 1900)
190 
191 // Presence of C++11 language features:
192 
193 #define scope_HAVE_CONSTEXPR_11 scope_CPP11_140
194 // #define scope_HAVE_ENUM_CLASS scope_CPP11_110
195 #define scope_HAVE_IS_DEFAULT scope_CPP11_120
196 #define scope_HAVE_IS_DELETE scope_CPP11_120
197 #define scope_HAVE_NOEXCEPT scope_CPP11_140
198 #define scope_HAVE_DEFAULT_FUNCTION_TEMPLATE_ARG scope_CPP11_120
199 #define scope_HAVE_STATIC_ASSERT scope_CPP11_90
200 #define scope_HAVE_TRAILING_RETURN_TYPE scope_CPP11_120
201 #define scope_HAVE_VALUE_INITIALIZATION scope_CPP11_120
202 
203 // Presence of C++14 language features:
204 
205 #define scope_HAVE_CONSTEXPR_14 scope_CPP14_000
206 
207 // Presence of C++17 language features:
208 
209 #define scope_HAVE_DEDUCTION_GUIDES scope_CPP17_000
210 #define scope_HAVE_NODISCARD scope_CPP17_000
211 
212 // Presence of C++11 library features:
213 
214 #define scope_HAVE_IS_TRIVIAL scope_CPP11_110
215 #define scope_HAVE_IS_TRIVIALLY_COPYABLE scope_CPP11_110 && !scope_BETWEEN(scope_COMPILER_GNUC_VERSION, 1, 500) // GCC >= 5
216 #define scope_HAVE_IS_CONSTRUCTIBLE scope_CPP11_110
217 #define scope_HAVE_IS_COPY_CONSTRUCTIBLE scope_CPP11_110
218 #define scope_HAVE_IS_MOVE_CONSTRUCTIBLE scope_CPP11_110
219 #define scope_HAVE_IS_NOTHROW_CONSTRUCTIBLE scope_CPP11_110
220 #define scope_HAVE_IS_NOTHROW_COPY_CONSTRUCTIBLE scope_CPP11_110
221 #define scope_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE scope_CPP11_110
222 #define scope_HAVE_IS_COPY_ASSIGNABLE scope_CPP11_110
223 #define scope_HAVE_IS_NOTHROW_ASSIGNABLE scope_CPP11_110
224 #define scope_HAVE_IS_NOTHROW_MOVE_ASSIGNABLE scope_CPP11_110
225 
226 #define scope_HAVE_REFERENCE_WRAPPER scope_CPP11_110
227 
228 #define scope_HAVE_REMOVE_CV scope_CPP11_90
229 #define scope_HAVE_REMOVE_REFERENCE scope_CPP11_90
230 
231 #define scope_HAVE_TYPE_TRAITS scope_CPP11_110
232 #define scope_HAVE_TR1_TYPE_TRAITS ((!! scope_COMPILER_GNUC_VERSION ) && scope_CPP11_OR_GREATER)
233 
234 #define scope_HAVE_DECAY scope_CPP11_110
235 #define scope_HAVE_DECAY_TR1 scope_HAVE_TR1_TYPE_TRAITS
236 
237 #define scope_HAVE_IS_SAME scope_HAVE_TYPE_TRAITS
238 #define scope_HAVE_IS_SAME_TR1 scope_HAVE_TR1_TYPE_TRAITS
239 
240 // #define scope_HAVE_CSTDINT scope_CPP11_90
241 
242 // Presence of C++14 library features:
243 
244 // Presence of C++17 library features:
245 
246 #define scope_HAVE_UNCAUGHT_EXCEPTIONS scope_CPP17_140
247 
248 // Presence of C++ language features:
249 
250 #if scope_HAVE_CONSTEXPR_11
251 # define scope_constexpr constexpr
252 #else
253 # define scope_constexpr /*constexpr*/
254 #endif
255 
256 #if scope_HAVE_CONSTEXPR_14
257 # define scope_constexpr14 constexpr
258 #else
259 # define scope_constexpr14 /*constexpr*/
260 #endif
261 
262 #if scope_HAVE( IS_DELETE )
263 # define scope_is_delete = delete
264 # define scope_is_delete_access public
265 #else
266 # define scope_is_delete
267 # define scope_is_delete_access private
268 #endif
269 
270 #if scope_HAVE_NOEXCEPT
271 # define scope_noexcept noexcept
272 # define scope_noexcept_op(expr) noexcept(expr)
273 #else
274 # define scope_noexcept /*noexcept*/
275 # define scope_noexcept_op(expr) /*noexcept(expr)*/
276 #endif
277 
278 #if scope_HAVE_NODISCARD
279 # define scope_nodiscard [[nodiscard]]
280 #else
281 # define scope_nodiscard /*[[nodiscard]]*/
282 #endif
283 
284 #if scope_HAVE_STATIC_ASSERT
285 # define scope_static_assert(expr, msg) static_assert((expr), msg)
286 #else
287 # define scope_static_assert(expr, msg) /*static_assert((expr), msg)*/
288 #endif
289 
290 // Select C++98 version
291 
292 #define scope_USE_POST_CPP98_VERSION scope_CPP11_100
293 
294 // Additional includes:
295 
296 #include <exception> // exception, terminate(), uncaught_exceptions()
297 #include <limits> // std::numeric_limits<>
298 #include <utility> // move(), forward<>(), swap()
299 
300 #if scope_HAVE_TYPE_TRAITS
301 # include <type_traits>
302 #elif scope_HAVE_TR1_TYPE_TRAITS
303 # include <tr1/type_traits>
304 #endif
305 
306 // Method enabling (return type):
307 
308 #if scope_HAVE( TYPE_TRAITS )
309 # define scope_ENABLE_IF_R_(VA, R) typename std::enable_if< (VA), R >::type
310 #else
311 # define scope_ENABLE_IF_R_(VA, R) R
312 #endif
313 
314 // Method enabling (funtion template argument):
315 
316 #if scope_HAVE( TYPE_TRAITS ) && scope_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG )
317 // VS 2013 seems to have trouble with SFINAE for default non-type arguments:
318 # if !scope_BETWEEN( scope_COMPILER_MSVC_VERSION, 1, 140 )
319 # define scope_ENABLE_IF_(VA) , typename std::enable_if< ( VA ), int >::type = 0
320 # else
321 # define scope_ENABLE_IF_(VA) , typename = typename std::enable_if< ( VA ), ::nonstd::scope::enabler >::type
322 # endif
323 #else
324 # define scope_ENABLE_IF_(VA)
325 #endif
326 
327 // Declare __cxa_get_globals() or equivalent in namespace nonstd::scope for uncaught_exceptions():
328 
329 #if !scope_HAVE( UNCAUGHT_EXCEPTIONS )
330 # if scope_COMPILER_MSVC_VERSION // libstl :)
331  namespace nonstd { namespace scope { extern "C" char * __cdecl _getptd(); }}
332 # elif scope_COMPILER_CLANG_VERSION || scope_COMPILER_GNUC_VERSION || scope_COMPILER_APPLECLANG_VERSION
333 # if defined(__GLIBCXX__) || defined(__GLIBCPP__) // libstdc++: prototype from cxxabi.h
334 # include <cxxabi.h>
335 # elif !defined(BOOST_CORE_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED_) // libc++: prototype from Boost?
336 # if defined(__FreeBSD__) || defined(__OpenBSD__)
337  namespace __cxxabiv1 { struct __cxa_eh_globals; extern "C" __cxa_eh_globals * __cxa_get_globals(); }
338 # else
339  namespace __cxxabiv1 { struct __cxa_eh_globals; extern "C" __cxa_eh_globals * __cxa_get_globals() scope_noexcept; }
340 # endif
341 # endif
342  namespace nonstd { namespace scope { using ::__cxxabiv1::__cxa_get_globals; }}
343 # endif // scope_COMPILER_MSVC_VERSION
344 #endif // !scope_HAVE( UNCAUGHT_EXCEPTIONS )
345 
346 // Namespace nonstd:
347 
348 namespace nonstd {
349 namespace scope {
350 
351 // for scope_ENABLE_IF_():
352 
353 /*enum*/ class enabler{};
354 
355 // C++11 emulation:
356 
357 namespace std11 {
358 
359 template< class T, T v > struct integral_constant { enum { value = v }; };
360 template< bool B > struct bool_constant : integral_constant<bool, B>{};
361 
364 
365 template <class T> struct is_reference : false_type{};
366 template <class T> struct is_reference<T&> : true_type {};
367 #if scope_CPP11_100
368 template <class T> struct is_reference<T&&> : true_type {};
369 #endif
370 
371 template< class T > struct remove_pointer { typedef T type; };
372 template< class T > struct remove_pointer<T*> { typedef T type; };
373 template< class T > struct remove_pointer<T* const> { typedef T type; };
374 template< class T > struct remove_pointer<T* volatile> { typedef T type; };
375 template< class T > struct remove_pointer<T* const volatile> { typedef T type; };
376 
377 template<bool B, class T, class F>
378 struct conditional { typedef T type; };
379 
380 template<class T, class F>
381 struct conditional<false, T, F> { typedef F type; };
382 
383 #if scope_HAVE( DECAY )
384  using std::decay;
385 #elif scope_HAVE( DECAY_TR1 )
386  using std::tr1::decay;
387 #else
388  template< class T > struct decay{ typedef T type; };
389 #endif
390 
391 #if scope_HAVE( IS_TRIVIAL )
392  using std::is_trivial;
393 #else
394  template< class T > struct is_trivial : std11::true_type{};
395 #endif
396 
397 #if scope_HAVE( IS_TRIVIALLY_COPYABLE )
398  using std::is_trivially_copyable;
399 #else
400  template< class T > struct is_trivially_copyable : std11::true_type{};
401 #endif
402 
403 #if scope_HAVE( IS_CONSTRUCTIBLE )
404  using std::is_constructible;
405 #else
406  template< class T > struct is_constructible : std11::true_type{};
407 #endif
408 
409 #if scope_HAVE( IS_COPY_CONSTRUCTIBLE )
410  using std::is_copy_constructible;
411 #else
412  template< class T > struct is_copy_constructible : std11::true_type{};
413 #endif
414 
415 #if scope_HAVE( IS_MOVE_CONSTRUCTIBLE )
416  using std::is_move_constructible;
417 #else
418  template< class T > struct is_move_constructible : std11::true_type{};
419 #endif
420 
421 #if scope_HAVE( IS_NOTHROW_CONSTRUCTIBLE )
422  using std::is_nothrow_constructible;
423 #else
424  template< class T, class U > struct is_nothrow_constructible : std11::true_type{};
425 #endif
426 
427 #if scope_HAVE( IS_NOTHROW_COPY_CONSTRUCTIBLE )
428  using std::is_nothrow_copy_constructible;
429 #else
430  template< class T > struct is_nothrow_copy_constructible : std11::true_type{};
431 #endif
432 
433 #if scope_HAVE( IS_NOTHROW_MOVE_CONSTRUCTIBLE )
434  using std::is_nothrow_move_constructible;
435 #else
436  template< class T > struct is_nothrow_move_constructible : std11::true_type{};
437 #endif
438 
439 #if scope_HAVE( IS_COPY_ASSIGNABLE )
440  using std::is_copy_assignable;
441 #else
442  template< class T > struct is_copy_assignable : std11::true_type{};
443 #endif
444 
445 #if scope_HAVE( IS_NOTHROW_ASSIGNABLE )
446  using std::is_nothrow_assignable;
447 #else
448  template< class T, class U > struct is_nothrow_assignable : std11::true_type{};
449 #endif
450 
451 #if scope_HAVE( IS_NOTHROW_MOVE_ASSIGNABLE )
452  using std::is_nothrow_move_assignable;
453 #else
454  template< class T > struct is_nothrow_move_assignable : std11::true_type{};
455 #endif
456 
457 #if scope_HAVE( IS_SAME )
458  using std::is_same;
459 #elif scope_HAVE( IS_SAME_TR1 )
460  using std::tr1::is_same;
461 #else
462  template< class T, class U > struct is_same : std11::true_type{};
463 #endif
464 
465 #if scope_HAVE( REMOVE_CV )
466  using std::remove_cv;
467 #else
468  template< class T > struct remove_cv{ typedef T type; };
469 #endif
470 
471 #if scope_HAVE( REMOVE_REFERENCE )
472  using std::remove_reference;
473 #else
474  template< class T > struct remove_reference{ typedef T type; };
475 #endif
476 
477 #if scope_HAVE( REFERENCE_WRAPPER )
478  using std::reference_wrapper;
479 #else
480  template< class T > struct reference_wrapper{ typedef T type; };
481 #endif
482 
483 } // namepsace std11
484 
485 // C++14 emulation:
486 
487 namespace std14 {
488 
489 #if scope_CPP11_100
490 #if scope_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG )
491 template< class T, class U = T >
492 #else
493 template< class T, class U /*= T*/ >
494 #endif
495 scope_constexpr14 T exchange( T & obj, U && new_value )
496 {
497  T old_value = std::move( obj );
498  obj = std::forward<U>( new_value );
499  return old_value;
500 }
501 #else
502 // C++98 version?
503 #endif
504 
505 } // namespace std14
506 
507 // C++17 emulation (uncaught_exceptions):
508 
509 namespace std17 {
510 
511 template< typename T >
512 inline int to_int( T x ) scope_noexcept
513 {
514  return static_cast<int>( x );
515 }
516 
517 #if scope_HAVE( UNCAUGHT_EXCEPTIONS )
518 
519 inline int uncaught_exceptions() scope_noexcept
520 {
521  return to_int( std::uncaught_exceptions() );
522 }
523 
524 #elif scope_COMPILER_MSVC_VERSION
525 
526 inline int uncaught_exceptions() scope_noexcept
527 {
528  return to_int( *reinterpret_cast<const unsigned*>(_getptd() + (sizeof(void*) == 8 ? 0x100 : 0x90) ) );
529 }
530 
531 #elif scope_COMPILER_CLANG_VERSION || scope_COMPILER_GNUC_VERSION || scope_COMPILER_APPLECLANG_VERSION
532 
533 inline int uncaught_exceptions() scope_noexcept
534 {
535  return to_int( *reinterpret_cast<const unsigned*>(
536  reinterpret_cast<const unsigned char*>(__cxa_get_globals()) + sizeof(void*) ) );
537 }
538 
539 #endif // scope_HAVE( UNCAUGHT_EXCEPTIONS )
540 
541 } // namespace std17
542 
543 // C++20 emulation:
544 
545 namespace std20 {
546 
547 template< class T >
549 {
551 };
552 
553 template< class T, class U >
554 struct same_as : std11::integral_constant<bool, std11::is_same<T,U>::value && std11::is_same<U,T>::value> {};
555 
556 template< class T >
557 struct type_identity { typedef T type; };
558 
559 } // namepsace std20
560 
561 //
562 // For reference:
563 //
564 
565 #if 0
566 
567 template< class EF>
568 class scope_exit;
569 
570 template< class EF>
571 class scope_fail;
572 
573 template< class EF>
574 class scope_success;
575 
576 template<class R,class D>
577 class unique_resource;
578 
579 // special factory function:
580 
581 template<class R,class D, class S=R>
582 unique_resource<decay_t<R>, decay_t<D>>
583 make_unique_resource_checked(R&& r, S const& invalid, D&& d)
584 noexcept(is_nothrow_constructible_v<decay_t<R>, R> && is_nothrow_constructible_v<decay_t<D>, D>);
585 
586 // optional factory functions (should at least be present for LFTS3):
587 
588 template< class EF>
590 make_scope_exit(EF&& exit_function) ;
591 
592 template< class EF>
594 make_scope_fail(EF&& exit_function) ;
595 
596 template< class EF>
598 make_scope_success(EF&& exit_function) ;
599 
600 #endif // reference
601 
602 #if scope_USE_POST_CPP98_VERSION
603 
604 //
605 // Post-C++98 version:
606 //
607 
608 template< typename T >
609 T && conditional_forward( T && t, std11::true_type )
610 {
611  return std::forward<T>( t );
612 }
613 
614 template< typename T >
615 T const & conditional_forward( T && t, std11::false_type )
616 {
617  return t;
618 }
619 
620 template< typename T >
621 T && conditional_move( T && t, std11::true_type )
622 {
623  return std::move( t );
624 }
625 
626 template< typename T >
627 T const & conditional_move( T && t, std11::false_type )
628 {
629  return t;
630 }
631 
632 // template< typename FE, typename Fn >
633 // struct to_argument_type<EF,Fn>
634 // {
635 // };
636 
637 // scope_exit:
638 
639 template< class EF >
640 class scope_exit
641 {
642 public:
643  template< class Fn
647  ))
648  >
649  explicit scope_exit( Fn&& fn )
651  ((
654  ))
655  : exit_function(
656 // to_argument_type<EF,Fn>( std::forward<Fn>(fn) ) )
657  conditional_forward<Fn>( std::forward<Fn>(fn)
659  , execute_on_destruction( true )
660  {}
661 
662  scope_exit( scope_exit && other )
664  ((
667  ))
668  : exit_function( std::forward<EF>( other.exit_function ) )
669  , execute_on_destruction( other.execute_on_destruction )
670  {
671  other.release();
672  }
673 
675  {
676  if ( execute_on_destruction )
677  exit_function();
678  }
679 
680  void release() scope_noexcept
681  {
682  execute_on_destruction = false;
683  }
684 
687 
688  scope_exit & operator=( scope_exit const & ) scope_is_delete;
689  scope_exit & operator=( scope_exit && ) scope_is_delete;
690 
691 private:
692  EF exit_function;
693  bool execute_on_destruction; // { true };
694 };
695 
696 // scope_fail:
697 
698 template< class EF >
699 class scope_fail
700 {
701 public:
702  template< class Fn
706  ))
707  >
708  explicit scope_fail( Fn&& fn )
710  ((
713  ))
714  : exit_function(
715  conditional_forward<Fn>( std::forward<Fn>(fn)
717  , uncaught_on_creation( std17::uncaught_exceptions() )
718  {}
719 
720  scope_fail( scope_fail && other )
722  ((
725  ))
726  : exit_function( std::forward<EF>( other.exit_function ) )
727  , uncaught_on_creation( other.uncaught_on_creation )
728  {
729  other.release();
730  }
731 
733  {
734  if ( uncaught_on_creation < std17::uncaught_exceptions() )
735  exit_function();
736  }
737 
738  void release() scope_noexcept
739  {
740  uncaught_on_creation = std::numeric_limits<int>::max();
741  }
742 
745 
746  scope_fail & operator=( scope_fail const & ) scope_is_delete;
747  scope_fail & operator=( scope_fail && ) scope_is_delete;
748 
749 private:
750  EF exit_function;
751  int uncaught_on_creation; // { std17::uncaught_exceptions() };
752 };
753 
754 // scope_success:
755 
756 template< class EF >
757 class scope_success
758 {
759 public:
760  template< class Fn
764  ))
765  >
766  explicit scope_success( Fn&& fn )
768  ((
771  ))
772  : exit_function(
773  conditional_forward<Fn>( std::forward<Fn>(fn)
775  , uncaught_on_creation( std17::uncaught_exceptions() )
776  {}
777 
778  scope_success( scope_success && other )
780  ((
783  ))
784  : exit_function( std::forward<EF>( other.exit_function ) )
785  , uncaught_on_creation( other.uncaught_on_creation )
786  {
787  other.release();
788  }
789 
791  {
792  if ( uncaught_on_creation >= std17::uncaught_exceptions() )
793  exit_function();
794  }
795 
796  void release() scope_noexcept
797  {
798  uncaught_on_creation = -1;
799  }
800 
803 
804  scope_success & operator=( scope_success const & ) scope_is_delete;
805  scope_success & operator=( scope_success && ) scope_is_delete;
806 
807 private:
808  EF exit_function;
809  int uncaught_on_creation; // { std17::uncaught_exceptions() };
810 };
811 
812 #if scope_HAVE( DEDUCTION_GUIDES )
813 template< class EF > scope_exit(EF) -> scope_exit<EF>;
814 template< class EF > scope_fail(EF) -> scope_fail<EF>;
815 template< class EF > scope_success(EF) -> scope_success<EF>;
816 #endif
817 
818 // optional factory functions (should at least be present for LFTS3):
819 
820 template< class EF >
822 make_scope_exit( EF && exit_function )
823 {
824  return scope_exit<typename std11::decay<EF>::type>( std::forward<EF>( exit_function ) );
825 }
826 
827 template< class EF >
829 make_scope_fail( EF && exit_function )
830 {
831  return scope_fail<typename std11::decay<EF>::type>( std::forward<EF>( exit_function ) );
832 }
833 
834 template< class EF >
836 make_scope_success( EF && exit_function )
837 {
838  return scope_success<typename std11::decay<EF>::type>( std::forward<EF>( exit_function ) );
839 }
840 
841 // unique_resource:
842 
843 template< class R, class D >
844 class unique_resource
845 {
846 private:
850  , "resource must be nothrow_move_constructible or copy_constructible"
851  );
852 
856  , "deleter must be nothrow_move_constructible or copy_constructible"
857  );
858 
859  typedef typename std11::conditional<
862  , R
863  >::type R1;
864 
865 public:
866  // This overload only participates in overload resolution if:
867  // - std::is_default_constructible_v<R>
868  // - && std::is_default_constructible_v<D>
869 
871 #if scope_HAVE( VALUE_INITIALIZATION )
872  : resource{}
873  , deleter{}
874  , execute_on_reset{ false }
875 #else
876  : resource()
877  , deleter()
878  , execute_on_reset( false )
879 #endif
880  {}
881 
882  // construction: note extra execute default parameter
883 
884  template< class RR, class DD
885 #if scope_BETWEEN( scope_COMPILER_MSVC_VERSION, 120, 130 )
886  scope_ENABLE_IF_(( true
887  // && std11::is_constructible<R1, RR>::value
889  // && (std11::is_nothrow_constructible<R1, RR>::value || std11::is_constructible<R1, RR&>::value )
891  ))
892 #else
893  scope_ENABLE_IF_(( true
898  ))
899 #endif
900  >
901  unique_resource( RR && r, DD && d, bool execute = true )
905  ))
906  : resource( conditional_forward<RR>( std::forward<RR>(r)
908  , deleter( ( conditional_forward<DD>( std::forward<DD>(d)
910  , execute_on_reset( execute )
911  {}
912 
913  // Move constructor.
914  //
915  // The stored resource handle is initialized from the one of other, using std::move if
916  // std::is_nothrow_move_constructible_v<RS> is true.
917  //
918  // If initialization of the stored resource handle throws an exception, other is not modified.
919  //
920  // Then, the deleter is initialized with the one of other, using std::move if
921  // std::is_nothrow_move_constructible_v<D> is true.
922  //
923  // If initialization of the deleter throws an exception and std::is_nothrow_move_constructible_v<RS> is true and
924  // other owns the resource, calls the deleter of other with res_ to dispose the resource, then calls other.release().
925  //
926  // After construction, the constructed unique_resource owns its resource if and only if other owned the resource before
927  // the construction, and other is set to not own the resource.
928 
929  unique_resource( unique_resource && other )
932  )
933  try
934  : resource( conditional_move( std::move(other.resource), typename std11::bool_constant< std11::is_nothrow_move_assignable<R>::value >() ) )
935  , deleter( conditional_move( std::move(other.deleter ), typename std11::bool_constant< std11::is_nothrow_move_constructible<D>::value >() ) )
936  , execute_on_reset( std14::exchange( other.execute_on_reset, false ) )
937  {}
938  catch(...)
939  {
940  if ( other.execute_on_reset && std11::is_nothrow_move_constructible<R>::value )
941  {
942  other.get_deleter()( this->get() );
943  other.release();
944  }
945  }
946 
947  ~unique_resource()
948  {
949  reset();
950  }
951 
952 private:
953  // assign_rd( r, is_nothrow_move_assignable_v<R>, is_nothrow_move_assignable_v<D> ):
954 
955  void assign_rd( unique_resource && other, std11::true_type, std11::true_type )
956  {
957  resource = std::move( other.resource );
958  deleter = std::move( other.deleter );
959  }
960 
961  void assign_rd( unique_resource && other, std11::true_type, std11::false_type )
962  {
963  resource = std::move( other.resource );
964  deleter = other.deleter;
965  }
966 
967  void assign_rd( unique_resource && other, std11::false_type, std11::true_type )
968  {
969  deleter = std::move( other.deleter );
970  resource = other.resource;
971  }
972 
973  void assign_rd( unique_resource && other, std11::false_type, std11::false_type )
974  {
975  resource = other.resource;
976  deleter = other.deleter;
977  }
978 
979 public:
980  unique_resource & operator=( unique_resource && other )
983  )
984  {
987  , "The resource must be nothrow-move assignable, or copy assignable"
988  );
989 
992  , "The deleter must be nothrow-move assignable, or copy assignable");
993 
994  if ( &other != this )
995  {
996  reset();
997  assign_rd(
998  std::move( other )
1001  );
1002  execute_on_reset = std14::exchange( other.execute_on_reset, false );
1003  }
1004 
1005  return *this;
1006  }
1007 
1008  void reset() scope_noexcept
1009  {
1010  if ( execute_on_reset )
1011  {
1012  execute_on_reset = false;
1013  get_deleter()( get() );
1014  }
1015  }
1016 
1017  template< class RR >
1018  void reset( RR && r )
1019 #if scope_CPP11_110
1020  {
1021  auto && guard = make_scope_fail( [&, this]{ get_deleter()(r); } ); // -Wunused-variable on clang
1022 
1023  reset();
1024  resource = conditional_forward<RR>( std::forward<RR>(r)
1026  execute_on_reset = true;
1027  }
1028 #else // scope_CPP11_110
1029  try
1030  {
1031  reset();
1032  resource = conditional_forward<RR>( std::forward<RR>(r)
1034  execute_on_reset = true;
1035  }
1036  catch(...)
1037  {
1038  this->get_deleter()(r);
1039  }
1040 #endif // scope_CPP11_110
1041 
1042  void release() scope_noexcept
1043  {
1044  execute_on_reset = false;
1045  }
1046 
1047  R1 const & get() const scope_noexcept
1048  {
1049  return resource;
1050  }
1051 
1052  // VC120/VS2013 produces ICE:
1053 
1054 #if scope_HAVE( TRAILING_RETURN_TYPE ) && !scope_BETWEEN( scope_COMPILER_MSVC_VERSION, 120, 130 )
1055  template< class RR=R >
1056  auto operator*() const scope_noexcept ->
1058  std::is_pointer<RR>::value && !std::is_void<typename std::remove_pointer<RR>::type>::value
1059  , typename std::add_lvalue_reference<typename std::remove_pointer<R>::type>::type
1060  )
1061 #else
1062  typename std::add_lvalue_reference<typename std::remove_pointer<R>::type>::type
1063  operator*() const scope_noexcept
1064 #endif
1065  {
1066  return *get();
1067  }
1068 
1069  // VC120/VS2013 produces ICE:
1070 
1071 #if scope_HAVE( TRAILING_RETURN_TYPE ) && !scope_BETWEEN( scope_COMPILER_MSVC_VERSION, 120, 130 )
1072  template< class RR=R >
1073  auto operator->() const scope_noexcept -> scope_ENABLE_IF_R_( std::is_pointer<RR>::value, R )
1074 #else
1075  R operator->() const scope_noexcept
1076 #endif
1077  {
1078  return get();
1079  }
1080 
1081  D const & get_deleter() const scope_noexcept
1082  {
1083  return deleter;
1084  }
1085 
1087  unique_resource & operator=( unique_resource const & ) scope_is_delete;
1089 
1090 private:
1091  R1 resource;
1092  D deleter;
1093  bool execute_on_reset;
1094 };
1095 
1096 #if scope_HAVE( DEDUCTION_GUIDES )
1097 template< typename R, typename D >
1099 #endif
1100 
1101 // special factory function make_unique_resource_checked():
1102 
1103 #if scope_HAVE_DEFAULT_FUNCTION_TEMPLATE_ARG
1104 
1105 template< class R, class D, class S = typename std11::decay<R>::type >
1107 <
1108  typename std11::decay<R>::type
1109  , typename std11::decay<D>::type
1110 >
1111 //make_unique_resource_checked( R && resource, typename std20::type_identity<S>::type const & invalid, D && deleter )
1112 make_unique_resource_checked( R && resource, S const & invalid, D && deleter )
1114 ((
1115  std11::is_nothrow_constructible<typename std11::decay<R>::type, R>::value
1117 ))
1118 {
1120  std::forward<R>( resource ), std::forward<D>( deleter ), !bool( resource == invalid ) );
1121 }
1122 
1123 #else // scope_HAVE_DEFAULT_FUNCTION_TEMPLATE_ARG
1124 
1125 // avoid default template arguments:
1126 
1127 template< class R, class D >
1129 <
1130  typename std11::decay<R>::type
1131  , typename std11::decay<D>::type
1132 >
1133 make_unique_resource_checked( R && resource, R const & invalid, D && deleter )
1135 ((
1136  std11::is_nothrow_constructible<typename std11::decay<R>::type, R>::value
1138 ))
1139 {
1141  std::forward<R>( resource ), std::forward<D>( deleter ), !bool( resource == invalid ) );
1142 }
1143 
1144 template< class R, class D, class S >
1146 <
1147  typename std11::decay<R>::type
1148  , typename std11::decay<D>::type
1149 >
1150 make_unique_resource_checked( R && resource, S const & invalid, D && deleter )
1152 ((
1153  std11::is_nothrow_constructible<typename std11::decay<R>::type, R>::value
1155 ))
1156 {
1158  std::forward<R>( resource ), std::forward<D>( deleter ), !bool( resource == invalid ) );
1159 }
1160 
1161 #endif // scope_HAVE_DEFAULT_FUNCTION_TEMPLATE_ARG
1162 
1163 #else // #if scope_USE_POST_CPP98_VERSION
1164 
1165 //
1166 // C++98 version:
1167 //
1168 
1170 {
1171  mutable bool invoke_;
1172 
1174  : invoke_( true )
1175  {}
1176 
1178  : invoke_( other.invoke_ )
1179  {
1180  other.invoke_ = false;
1181  }
1182 
1183  void release()
1184  {
1185  invoke_ = false;
1186  }
1187 
1188  bool perform()
1189  {
1190  return invoke_;
1191  }
1192 };
1193 
1195 {
1196  mutable int ucount_;
1197 
1199  : ucount_( std17::uncaught_exceptions() )
1200  {}
1201 
1203  : ucount_( other.ucount_ )
1204  {
1205  other.ucount_ = std::numeric_limits<int>::max();
1206  }
1207 
1208  void release()
1209  {
1210  ucount_ = std::numeric_limits<int>::max();
1211  }
1212 
1213  bool perform()
1214  {
1215  return ucount_ < std17::uncaught_exceptions();
1216  }
1217 };
1218 
1220 {
1221  mutable int ucount_;
1222 
1224  : ucount_( std17::uncaught_exceptions() )
1225  {}
1226 
1228  : ucount_( other.ucount_ )
1229  {
1230  other.ucount_ = -1;
1231  }
1232 
1233  void release()
1234  {
1235  ucount_ = -1;
1236  }
1237 
1238  bool perform()
1239  {
1240  return ucount_ >= std17::uncaught_exceptions();
1241  }
1242 };
1243 
1244 template< typename Policy, typename Action >
1245 class scope_guard : public Policy
1246 {
1247 public:
1249  : Policy()
1250  , action_( action )
1251  {}
1252 
1253  scope_guard( scope_guard const & other )
1254  : Policy( other )
1255  , action_( other.action_ )
1256  {}
1257 
1258  virtual ~scope_guard()
1259  {
1260  if ( this->perform() )
1261  action_();
1262  }
1263 
1264 private:
1265  scope_guard & operator=( scope_guard const & );
1266 
1267 private:
1268  Action action_;
1269 };
1270 
1271 template< typename Fn = void(*)() >
1272 class scope_exit : public scope_guard< on_exit_policy, Fn >
1273 {
1274 public:
1275  scope_exit( Fn action ) : scope_guard<on_exit_policy, Fn>( action ) {}
1276 };
1277 
1278 template< typename Fn = void(*)() >
1279 class scope_fail : public scope_guard< on_fail_policy, Fn >
1280 {
1281 public:
1282  scope_fail( Fn action ) : scope_guard<on_fail_policy, Fn>( action ) {}
1283 };
1284 
1285 template< typename Fn = void(*)() >
1286 class scope_success : public scope_guard< on_success_policy, Fn >
1287 {
1288 public:
1290 };
1291 
1292 // unique_resource (C++98):
1293 
1294 template< class R, class D >
1296 {
1297 public:
1299  : resource()
1300  , deleter()
1301  , execute_on_reset( false )
1302  {}
1303 
1304  template< class RR, class DD >
1305  unique_resource( RR const & r, DD const & d, bool execute = true )
1306  : resource( r )
1307  , deleter( d )
1308  , execute_on_reset( execute )
1309  {}
1310 
1311  // 'move' construction
1312 
1314  : resource( other.resource )
1315  , deleter( other.deleter )
1316  , execute_on_reset( other.execute_on_reset )
1317  {
1318  other.execute_on_reset = false; // other.release();
1319  }
1320 
1322  {
1323  reset();
1324  }
1325 
1326  // 'move' assignment
1327 
1329  {
1330  reset();
1331  resource = other.resource;
1332  deleter = other.deleter;
1333  execute_on_reset = other.execute_on_reset;
1334  other.execute_on_reset = false; // other.release();
1335 
1336  return *this;
1337  }
1338 
1339  void reset()
1340  {
1341  if ( execute_on_reset )
1342  {
1343  execute_on_reset = false;
1344  get_deleter()( get() );
1345  }
1346  }
1347 
1348  template< class RR >
1349  void reset( RR const & r )
1350  try
1351  {
1352  reset();
1353  resource = r;
1354  execute_on_reset = true;
1355  }
1356  catch(...)
1357  {
1358  this->get_deleter()( r );
1359  }
1360 
1361  void release()
1362  {
1363  execute_on_reset = false;
1364  }
1365 
1366  R const & get() const
1367  {
1368  return resource;
1369  }
1370 
1372  operator*() const
1373  {
1374  return *get();
1375  }
1376 
1377  R operator->() const
1378  {
1379  return get();
1380  }
1381 
1382  D const & get_deleter() const
1383  {
1384  return deleter;
1385  }
1386 
1387 private:
1388  // using R1 = conditional_t< is_reference_v<R>, reference_wrapper<remove_reference_t<R>>, R >; // exposition only
1389  // typedef R R1;
1390  R resource;
1391  D deleter;
1392  mutable bool execute_on_reset;
1393 };
1394 
1395 template< class EF >
1397 {
1398  return scope_exit<EF>( action );
1399 }
1400 
1401 template< class EF >
1403 {
1404  return scope_fail<EF>( action );
1405 }
1406 
1407 template< class EF >
1409 {
1410  return scope_success<EF>( action );
1411 }
1412 
1413 template< class R, class D, class S >
1415 <
1416  typename std11::decay<R>::type
1417  , typename std11::decay<D>::type
1418 >
1419 make_unique_resource_checked( R const & resource, S const & invalid, D const & deleter )
1420 {
1422  resource,deleter, !bool( resource == invalid ) );
1423 }
1424 
1425 #endif // #if scope_USE_POST_CPP98_VERSION
1426 
1427 }} // namespace nonstd::scope
1428 
1429 //
1430 // Make type available in namespace nonstd:
1431 //
1432 
1433 namespace nonstd
1434 {
1435  using scope::scope_exit;
1436  using scope::scope_fail;
1437  using scope::scope_success;
1438  using scope::unique_resource;
1439 
1440  using scope::make_scope_exit;
1441  using scope::make_scope_fail;
1444 }
1445 
1446 #endif // scope_USES_STD_SCOPE
1447 
1448 #endif // NONSTD_SCOPE_LITE_HPP
#define scope_is_delete
Definition: scope-lite.hpp:266
std11::remove_cv< typename std11::remove_reference< T >::type >::type type
Definition: scope-lite.hpp:550
#define scope_ENABLE_IF_(VA)
Definition: scope-lite.hpp:324
bool invalid(value code)
Test whether a close code is invalid on the wire.
Definition: close.hpp:199
unique_resource< typename std11::decay< R >::type, typename std11::decay< D >::type > make_unique_resource_checked(R const &resource, S const &invalid, D const &deleter)
#define scope_is_delete_access
Definition: scope-lite.hpp:267
scope_exit< EF > make_scope_exit(EF action)
#define scope_constexpr14
Definition: scope-lite.hpp:259
scope_success< EF > make_scope_success(EF action)
#define scope_static_assert(expr, msg)
Definition: scope-lite.hpp:287
on_exit_policy(on_exit_policy const &other)
#define scope_ENABLE_IF_R_(VA, R)
Definition: scope-lite.hpp:311
std11::remove_pointer< R >::type & operator*() const
scope_fail< EF > make_scope_fail(EF action)
unique_resource & operator=(unique_resource const &other)
unique_resource(RR const &r, DD const &d, bool execute=true)
bool_constant< false > false_type
Definition: scope-lite.hpp:363
scope_guard(scope_guard const &other)
bool_constant< true > true_type
Definition: scope-lite.hpp:362
#define scope_noexcept
Definition: scope-lite.hpp:274
on_success_policy(on_success_policy const &other)
on_fail_policy(on_fail_policy const &other)
int to_int(T x) scope_noexcept
Definition: scope-lite.hpp:512
unique_resource(unique_resource const &other)
#define scope_noexcept_op(expr)
Definition: scope-lite.hpp:275