Skip to content

Commit ba4797f

Browse files
committed
v1: stdx + macros.hpp
1 parent 6f7a978 commit ba4797f

File tree

30 files changed

+465
-228
lines changed

30 files changed

+465
-228
lines changed

src/bsoncxx/include/bsoncxx/docs/v1.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,17 @@
4040
/// @warning For internal use only!
4141
///
4242

43+
///
44+
/// @dir bsoncxx/v1/stdx
45+
/// Provides headers declaring entities in @ref bsoncxx::v1::stdx.
46+
///
47+
4348
///
4449
/// @namespace bsoncxx::v1
4550
/// Declares entities whose ABI stability is guaranteed for documented symbols.
4651
///
52+
53+
///
54+
/// @namespace bsoncxx::v1::stdx
55+
/// @copydoc bsoncxx::stdx
56+
///

src/bsoncxx/include/bsoncxx/v1/detail/compare.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414

1515
#pragma once
1616

17+
#include <bsoncxx/v1/detail/prelude.hpp>
18+
19+
#include <bsoncxx/v1/detail/macros.hpp>
20+
#include <bsoncxx/v1/detail/type_traits.hpp>
21+
1722
#include <cstddef>
1823
#include <functional>
1924
#include <type_traits>
2025

21-
#include <bsoncxx/stdx/type_traits.hpp>
22-
23-
#include <bsoncxx/config/prelude.hpp>
24-
2526
namespace bsoncxx {
2627
namespace detail {
2728

@@ -208,11 +209,11 @@ struct is_totally_ordered_with : conjunction<
208209
} // namespace detail
209210
} // namespace bsoncxx
210211

211-
#include <bsoncxx/config/postlude.hpp>
212+
#include <bsoncxx/v1/detail/postlude.hpp>
212213

213214
///
214215
/// @file
215-
/// Provides comparison-related utilities for internal use.
216+
/// For internal use only!
216217
///
217218
/// @warning For internal use only!
218219
///

src/bsoncxx/include/bsoncxx/v1/detail/macros.hpp

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
// Copyright 2009-present MongoDB, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Traditional include guard is required to support v_noabi include-via-prelude.
16+
#if !defined(BSONCXX_V1_DETAIL_MACROS_HPP)
17+
#define BSONCXX_V1_DETAIL_MACROS_HPP
18+
119
// Convert the given macro argument to a string literal, after macro expansion.
220
#define BSONCXX_STRINGIFY(...) BSONCXX_STRINGIFY_IMPL(__VA_ARGS__)
321
#define BSONCXX_STRINGIFY_IMPL(...) #__VA_ARGS__
@@ -65,6 +83,28 @@
6583
#define bsoncxx_cxx14_constexpr inline
6684
#endif
6785

86+
#define BSONCXX_IF_MSVC(...)
87+
#define BSONCXX_IF_GCC(...)
88+
#define BSONCXX_IF_CLANG(...)
89+
#define BSONCXX_IF_GNU_LIKE(...) \
90+
BSONCXX_IF_GCC(__VA_ARGS__) \
91+
BSONCXX_IF_CLANG(__VA_ARGS__)
92+
93+
// clang-format off
94+
#ifdef __GNUC__
95+
#ifdef __clang__
96+
#undef BSONCXX_IF_CLANG
97+
#define BSONCXX_IF_CLANG(...) __VA_ARGS__
98+
#else
99+
#undef BSONCXX_IF_GCC
100+
#define BSONCXX_IF_GCC(...) __VA_ARGS__
101+
#endif
102+
#elif defined(_MSC_VER)
103+
#undef BSONCXX_IF_MSVC
104+
#define BSONCXX_IF_MSVC(...) __VA_ARGS__
105+
#endif
106+
// clang-format on
107+
68108
// Disable a warning for a particular compiler.
69109
//
70110
// The argument should be of the form:
@@ -103,9 +143,17 @@
103143

104144
#define BSONCXX_FWD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__)
105145

146+
#define BSONCXX_UNREACHABLE \
147+
if (1) { \
148+
std::abort(); \
149+
} else \
150+
((void)0)
151+
152+
#endif // BSONCXX_V1_DETAIL_MACROS_HPP
153+
106154
///
107155
/// @file
108-
/// Provides macros for internal use.
156+
/// For internal use only!
109157
///
110158
/// @warning For internal use only!
111159
///

src/bsoncxx/include/bsoncxx/v1/detail/postlude.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,33 @@
3939
#pragma pop_macro("BSONCXX_VERSION_EXTRA")
4040
#endif
4141

42+
// bsoncxx/v1/detail/macros.hpp
43+
#pragma pop_macro("BSONCXX_V1_DETAIL_MACROS_HPP")
44+
#if !defined(BSONCXX_V1_DETAIL_MACROS_HPP)
45+
#pragma pop_macro("BSONCXX_CONCAT")
46+
#pragma pop_macro("BSONCXX_CONCAT_IMPL")
47+
#pragma pop_macro("BSONCXX_DISABLE_WARNING")
48+
#pragma pop_macro("BSONCXX_FORCE_SEMICOLON")
49+
#pragma pop_macro("BSONCXX_FWD")
50+
#pragma pop_macro("BSONCXX_IF_CLANG")
51+
#pragma pop_macro("BSONCXX_IF_GCC")
52+
#pragma pop_macro("BSONCXX_IF_GNU_LIKE")
53+
#pragma pop_macro("BSONCXX_IF_MSVC")
54+
#pragma pop_macro("BSONCXX_POP_WARNINGS")
55+
#pragma pop_macro("BSONCXX_PRAGMA")
56+
#pragma pop_macro("BSONCXX_PUSH_WARNINGS")
57+
#pragma pop_macro("BSONCXX_RETURNS")
58+
#pragma pop_macro("BSONCXX_STRINGIFY")
59+
#pragma pop_macro("BSONCXX_STRINGIFY_IMPL")
60+
#pragma pop_macro("BSONCXX_UNREACHABLE")
61+
#pragma pop_macro("_bsoncxxDisableWarningImpl_for_Clang")
62+
#pragma pop_macro("_bsoncxxDisableWarningImpl_for_GCC")
63+
#pragma pop_macro("_bsoncxxDisableWarningImpl_for_GNU")
64+
#pragma pop_macro("_bsoncxxDisableWarningImpl_for_MSVC")
65+
#pragma pop_macro("_bsoncxxPragma")
66+
#pragma pop_macro("bsoncxx_cxx14_constexpr")
67+
#endif
68+
4269
#if !defined(BSONCXX_PRIVATE_V1_INSIDE_MACRO_GUARD_SCOPE)
4370
#error "postlude header included without a matching prelude header"
4471
#endif

src/bsoncxx/include/bsoncxx/v1/detail/prelude.hpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,55 @@
5555
#undef BSONCXX_VERSION_EXTRA
5656
#endif
5757

58+
// bsoncxx/v1/detail/macros.hpp
59+
#pragma push_macro("BSONCXX_V1_DETAIL_MACROS_HPP")
60+
#if !defined(BSONCXX_V1_DETAIL_MACROS_HPP)
61+
#pragma push_macro("BSONCXX_CONCAT")
62+
#undef BSONCXX_CONCAT
63+
#pragma push_macro("BSONCXX_CONCAT_IMPL")
64+
#undef BSONCXX_CONCAT_IMPL
65+
#pragma push_macro("BSONCXX_DISABLE_WARNING")
66+
#undef BSONCXX_DISABLE_WARNING
67+
#pragma push_macro("BSONCXX_FORCE_SEMICOLON")
68+
#undef BSONCXX_FORCE_SEMICOLON
69+
#pragma push_macro("BSONCXX_FWD")
70+
#undef BSONCXX_FWD
71+
#pragma push_macro("BSONCXX_IF_CLANG")
72+
#undef BSONCXX_IF_CLANG
73+
#pragma push_macro("BSONCXX_IF_GCC")
74+
#undef BSONCXX_IF_GCC
75+
#pragma push_macro("BSONCXX_IF_GNU_LIKE")
76+
#undef BSONCXX_IF_GNU_LIKE
77+
#pragma push_macro("BSONCXX_IF_MSVC")
78+
#undef BSONCXX_IF_MSVC
79+
#pragma push_macro("BSONCXX_POP_WARNINGS")
80+
#undef BSONCXX_POP_WARNINGS
81+
#pragma push_macro("BSONCXX_PRAGMA")
82+
#undef BSONCXX_PRAGMA
83+
#pragma push_macro("BSONCXX_PUSH_WARNINGS")
84+
#undef BSONCXX_PUSH_WARNINGS
85+
#pragma push_macro("BSONCXX_RETURNS")
86+
#undef BSONCXX_RETURNS
87+
#pragma push_macro("BSONCXX_STRINGIFY")
88+
#undef BSONCXX_STRINGIFY
89+
#pragma push_macro("BSONCXX_STRINGIFY_IMPL")
90+
#undef BSONCXX_STRINGIFY_IMPL
91+
#pragma push_macro("BSONCXX_UNREACHABLE")
92+
#undef BSONCXX_UNREACHABLE
93+
#pragma push_macro("_bsoncxxDisableWarningImpl_for_Clang")
94+
#undef _bsoncxxDisableWarningImpl_for_Clang
95+
#pragma push_macro("_bsoncxxDisableWarningImpl_for_GCC")
96+
#undef _bsoncxxDisableWarningImpl_for_GCC
97+
#pragma push_macro("_bsoncxxDisableWarningImpl_for_GNU")
98+
#undef _bsoncxxDisableWarningImpl_for_GNU
99+
#pragma push_macro("_bsoncxxDisableWarningImpl_for_MSVC")
100+
#undef _bsoncxxDisableWarningImpl_for_MSVC
101+
#pragma push_macro("_bsoncxxPragma")
102+
#undef _bsoncxxPragma
103+
#pragma push_macro("bsoncxx_cxx14_constexpr")
104+
#undef bsoncxx_cxx14_constexpr
105+
#endif
106+
58107
///
59108
/// @file
60109
/// The bsoncxx v1 macro guard prelude header.

src/bsoncxx/include/bsoncxx/v1/detail/type_traits.hpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414

1515
#pragma once
1616

17+
#include <bsoncxx/v1/detail/prelude.hpp>
18+
19+
#include <bsoncxx/v1/detail/macros.hpp>
20+
1721
#include <type_traits>
1822
#include <utility>
1923

20-
#include <bsoncxx/config/prelude.hpp>
21-
2224
namespace bsoncxx {
2325
namespace detail {
2426

@@ -433,12 +435,11 @@ template <typename T, typename U>
433435
auto is_swappable_f(rank<0>) -> std::false_type;
434436

435437
template <typename T, typename U>
436-
auto is_swappable_f(rank<1>) //
437-
noexcept(
438-
noexcept(swap(std::declval<T>(), std::declval<U>())) && noexcept(swap(std::declval<U>(), std::declval<T>())))
439-
-> true_t<
440-
decltype(swap(std::declval<T>(), std::declval<U>())),
441-
decltype(swap(std::declval<U>(), std::declval<T>()))>;
438+
auto is_swappable_f(rank<1>) noexcept(
439+
noexcept(swap(std::declval<T>(), std::declval<U>())) && noexcept(swap(std::declval<U>(), std::declval<T>())))
440+
-> true_t<
441+
decltype(swap(std::declval<T>(), std::declval<U>())),
442+
decltype(swap(std::declval<U>(), std::declval<T>()))>;
442443

443444
template <typename T, typename U>
444445
auto is_nothrow_swappable_f(rank<0>) -> std::false_type;
@@ -464,11 +465,11 @@ struct is_nothrow_swappable : is_nothrow_swappable_with<T&, T&> {};
464465
} // namespace detail
465466
} // namespace bsoncxx
466467

467-
#include <bsoncxx/config/postlude.hpp>
468+
#include <bsoncxx/v1/detail/postlude.hpp>
468469

469470
///
470471
/// @file
471-
/// Provides `<type_traits>`-related polyfills for internal use.
472+
/// For internal use only!
472473
///
473474
/// @warning For internal use only!
474475
///

0 commit comments

Comments
 (0)