1//////////////////////////////////////////////////////////////////////////////
2//
3// (C) Copyright Ion Gaztanaga 2014-2014. Distributed under the Boost
4// Software License, Version 1.0. (See accompanying file
5// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7// See http://www.boost.org/libs/interprocess for documentation.
8//
9//////////////////////////////////////////////////////////////////////////////
10
11#ifndef BOOST_MOVE_DETAIL_WORKAROUND_HPP
12#define BOOST_MOVE_DETAIL_WORKAROUND_HPP
13
14#ifndef BOOST_CONFIG_HPP
15# include <boost/config.hpp>
16#endif
17#
18#if defined(BOOST_HAS_PRAGMA_ONCE)
19# pragma once
20#endif
21
22#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
23 #define BOOST_MOVE_PERFECT_FORWARDING
24#endif
25
26#if defined(__has_feature)
27 #define BOOST_MOVE_HAS_FEATURE __has_feature
28#else
29 #define BOOST_MOVE_HAS_FEATURE(x) 0
30#endif
31
32#if BOOST_MOVE_HAS_FEATURE(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
33 #define BOOST_MOVE_ADDRESS_SANITIZER_ON
34#endif
35
36//Macros for documentation purposes. For code, expands to the argument
37#define BOOST_MOVE_IMPDEF(TYPE) TYPE
38#define BOOST_MOVE_SEEDOC(TYPE) TYPE
39#define BOOST_MOVE_DOC0PTR(TYPE) TYPE
40#define BOOST_MOVE_DOC1ST(TYPE1, TYPE2) TYPE2
41#define BOOST_MOVE_I ,
42#define BOOST_MOVE_DOCIGN(T1) T1
43
44#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 5) && !defined(__clang__)
45 //Pre-standard rvalue binding rules
46 #define BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
47#elif defined(_MSC_VER) && (_MSC_VER == 1600)
48 //Standard rvalue binding rules but with some bugs
49 #define BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG
50 #define BOOST_MOVE_MSVC_AUTO_MOVE_RETURN_BUG
51#elif defined(_MSC_VER) && (_MSC_VER == 1700)
52 #define BOOST_MOVE_MSVC_AUTO_MOVE_RETURN_BUG
53#endif
54
55//#define BOOST_MOVE_DISABLE_FORCEINLINE
56
57#if defined(BOOST_MOVE_DISABLE_FORCEINLINE)
58 #define BOOST_MOVE_FORCEINLINE inline
59#elif defined(BOOST_MOVE_FORCEINLINE_IS_BOOST_FORCELINE)
60 #define BOOST_MOVE_FORCEINLINE BOOST_FORCEINLINE
61#elif defined(BOOST_MSVC) && (_MSC_VER < 1900 || defined(_DEBUG))
62 //"__forceinline" and MSVC seems to have some bugs in old versions and in debug mode
63 #define BOOST_MOVE_FORCEINLINE inline
64#elif defined(BOOST_GCC) && (__GNUC__ <= 5)
65 //Older GCCs have problems with forceinline
66 #define BOOST_MOVE_FORCEINLINE inline
67#else
68 #define BOOST_MOVE_FORCEINLINE BOOST_FORCEINLINE
69#endif
70
71namespace boost {
72namespace movelib {
73
74template <typename T1>
75BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore(T1 const&)
76{}
77
78}} //namespace boost::movelib {
79
80#if !(defined BOOST_NO_EXCEPTIONS)
81# define BOOST_MOVE_TRY { try
82# define BOOST_MOVE_CATCH(x) catch(x)
83# define BOOST_MOVE_RETHROW throw;
84# define BOOST_MOVE_CATCH_END }
85#else
86# if !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
87# define BOOST_MOVE_TRY { if (true)
88# define BOOST_MOVE_CATCH(x) else if (false)
89# else
90// warning C4127: conditional expression is constant
91# define BOOST_MOVE_TRY { \
92 __pragma(warning(push)) \
93 __pragma(warning(disable: 4127)) \
94 if (true) \
95 __pragma(warning(pop))
96# define BOOST_MOVE_CATCH(x) else \
97 __pragma(warning(push)) \
98 __pragma(warning(disable: 4127)) \
99 if (false) \
100 __pragma(warning(pop))
101# endif
102# define BOOST_MOVE_RETHROW
103# define BOOST_MOVE_CATCH_END }
104#endif
105
106#ifndef BOOST_NO_CXX11_STATIC_ASSERT
107# ifndef BOOST_NO_CXX11_VARIADIC_MACROS
108# define BOOST_MOVE_STATIC_ASSERT( ... ) static_assert(__VA_ARGS__, #__VA_ARGS__)
109# else
110# define BOOST_MOVE_STATIC_ASSERT( B ) static_assert(B, #B)
111# endif
112#else
113namespace boost {
114namespace move_detail {
115
116template<bool B>
117struct STATIC_ASSERTION_FAILURE;
118
119template<>
120struct STATIC_ASSERTION_FAILURE<true>{};
121
122template<unsigned> struct static_assert_test {};
123
124}}
125
126#define BOOST_MOVE_STATIC_ASSERT(B) \
127 typedef ::boost::move_detail::static_assert_test<\
128 (unsigned)sizeof(::boost::move_detail::STATIC_ASSERTION_FAILURE<bool(B)>)>\
129 BOOST_JOIN(boost_static_assert_typedef_, __LINE__) BOOST_ATTRIBUTE_UNUSED
130
131#endif
132
133#if !defined(__has_cpp_attribute) || defined(__CUDACC__)
134#define BOOST_MOVE_HAS_MSVC_ATTRIBUTE(ATTR) 0
135#else
136#define BOOST_MOVE_HAS_MSVC_ATTRIBUTE(ATTR) __has_cpp_attribute(msvc::ATTR)
137#endif
138
139// See https://devblogs.microsoft.com/cppblog/improving-the-state-of-debug-performance-in-c/
140// for details on how MSVC has improved debug experience, specifically for move/forward-like utilities
141#if BOOST_MOVE_HAS_MSVC_ATTRIBUTE(intrinsic)
142#define BOOST_MOVE_INTRINSIC_CAST [[msvc::intrinsic]]
143#else
144#define BOOST_MOVE_INTRINSIC_CAST BOOST_MOVE_FORCEINLINE
145#endif
146
147#endif //#ifndef BOOST_MOVE_DETAIL_WORKAROUND_HPP
148
149