MongoDB C++ Driver  mongocxx-3.10.2
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
util.hpp
1 // clang-format off
6 #define BSONCXX_STRINGIFY(...) BSONCXX_STRINGIFY_IMPL(__VA_ARGS__)
7 #define BSONCXX_STRINGIFY_IMPL(...) #__VA_ARGS__
8 
12 #define BSONCXX_CONCAT(A, ...) BSONCXX_CONCAT_IMPL(A, __VA_ARGS__)
13 #define BSONCXX_CONCAT_IMPL(A, ...) A##__VA_ARGS__
14 
31 #define BSONCXX_PRAGMA(...) _bsoncxxPragma(__VA_ARGS__)
32 #ifdef _MSC_VER
33 // Old MSVC doesn't recognize C++11 _Pragma(), but it always recognized __pragma
34 #define _bsoncxxPragma(...) __pragma(__VA_ARGS__)
35 #else
36 #define _bsoncxxPragma(...) _Pragma(BSONCXX_STRINGIFY(__VA_ARGS__))
37 #endif
38 
45 #define BSONCXX_FORCE_SEMICOLON static_assert(true, "")
46 
65 #define BSONCXX_RETURNS(...) \
66  noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) { \
67  return __VA_ARGS__; \
68  } \
69  BSONCXX_FORCE_SEMICOLON
70 
80 #if __cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L && _MSC_VER > 1910)
81 #define bsoncxx_cxx14_constexpr constexpr
82 #else
83 #define bsoncxx_cxx14_constexpr inline
84 #endif
85 
99 #define BSONCXX_DISABLE_WARNING(Spec) \
100  BSONCXX_CONCAT(_bsoncxxDisableWarningImpl_for_, Spec) \
101  BSONCXX_FORCE_SEMICOLON
102 
107 #define BSONCXX_PUSH_WARNINGS() \
108  BSONCXX_IF_GNU_LIKE(BSONCXX_PRAGMA(GCC diagnostic push)) \
109  BSONCXX_IF_MSVC(BSONCXX_PRAGMA(warning(push))) \
110  BSONCXX_FORCE_SEMICOLON
111 
117 #define BSONCXX_POP_WARNINGS() \
118  BSONCXX_IF_GNU_LIKE(BSONCXX_PRAGMA(GCC diagnostic pop)) \
119  BSONCXX_IF_MSVC(BSONCXX_PRAGMA(warning(pop))) \
120  BSONCXX_FORCE_SEMICOLON
121 
122 #define _bsoncxxDisableWarningImpl_for_GCC(...) \
123  BSONCXX_IF_GCC(BSONCXX_PRAGMA(GCC diagnostic ignored __VA_ARGS__))
124 
125 #define _bsoncxxDisableWarningImpl_for_Clang(...) \
126  BSONCXX_IF_CLANG(BSONCXX_PRAGMA(GCC diagnostic ignored __VA_ARGS__))
127 
128 #define _bsoncxxDisableWarningImpl_for_GNU(...) \
129  _bsoncxxDisableWarningImpl_for_GCC(__VA_ARGS__) \
130  _bsoncxxDisableWarningImpl_for_Clang(__VA_ARGS__)
131 
132 #define _bsoncxxDisableWarningImpl_for_MSVC(...) \
133  BSONCXX_IF_MSVC(BSONCXX_PRAGMA(warning(disable : __VA_ARGS__)))
134 
135 #define BSONCXX_FWD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__)
136