-
Notifications
You must be signed in to change notification settings - Fork 543
CXX-2745 relocate top-level dependencies into v1 headers #1318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
41f5f2b
format: add v1 header groups
eramongodb e65e63a
Fix library name in mongocxx doc.hpp
eramongodb 64097b4
v1: doc.hpp
eramongodb 2470ebb
v1: add macro guard headers
eramongodb b13118e
v1: export.hpp
eramongodb 90dc075
v1 <- v_noabi: config.hpp
eramongodb d6ffdb9
v1: config.hpp
eramongodb ea6e914
v1 <- v_noabi: version.hpp
eramongodb 1a9e26d
v1: version.hpp
eramongodb 1a1a701
v1: add BSONCXX_VERSION_STRING
eramongodb 6f7a978
v1 <- v_noabi: stdx
eramongodb ba4797f
v1: stdx + macros.hpp
eramongodb 9f8b738
Use consistent prefix for private macros used in public headers
eramongodb 629d262
Move comparison-related type traits into type_traits.hpp
eramongodb 9096a30
Relocate internal components out of v_noabi subdirectories
eramongodb 87d2cab
Revert "Relocate internal components out of v_noabi subdirectories"
eramongodb 7ffd8c2
Add static assertions for *_VERSION_STRING macros
eramongodb df4fad9
Remove redundant include category of v1 private headers
eramongodb 0450683
Update descriptions of format include categories
eramongodb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2009-present MongoDB, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#if !defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR) | ||
#error "This file is for documentation purposes only. It should not be included." | ||
#endif // !defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR) | ||
|
||
/// | ||
/// @file | ||
/// For documentation purposes only. | ||
/// | ||
/// @note This header is not includable! | ||
/// | ||
|
||
/// | ||
/// @dir bsoncxx/v1 | ||
/// Provides headers declaring entities in @ref bsoncxx::v1. | ||
/// | ||
|
||
/// | ||
/// @dir bsoncxx/v1/config | ||
/// Provides headers related to bsoncxx library configuration. | ||
/// | ||
|
||
/// | ||
/// @dir bsoncxx/v1/detail | ||
/// Provides headers for internal use only. | ||
/// | ||
/// @warning For internal use only! | ||
/// | ||
|
||
/// | ||
/// @dir bsoncxx/v1/stdx | ||
/// Provides headers declaring entities in @ref bsoncxx::v1::stdx. | ||
/// | ||
|
||
/// | ||
/// @namespace bsoncxx::v1 | ||
/// Declares entities whose ABI stability is guaranteed for documented symbols. | ||
/// | ||
|
||
/// | ||
/// @namespace bsoncxx::v1::stdx | ||
/// @copydoc bsoncxx::stdx | ||
/// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
// Copyright 2009-present MongoDB, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <bsoncxx/v1/detail/prelude.hpp> | ||
|
||
#include <bsoncxx/v1/detail/macros.hpp> | ||
#include <bsoncxx/v1/detail/type_traits.hpp> | ||
|
||
#include <cstddef> | ||
#include <functional> | ||
#include <type_traits> | ||
|
||
namespace bsoncxx { | ||
namespace detail { | ||
|
||
// Callable object and tag type for equality comparison. | ||
struct equal_to { | ||
template <typename L, typename R> | ||
constexpr requires_t<bool, is_equality_comparable<L, R>> operator()(L&& l, R&& r) const noexcept(noexcept(l == r)) { | ||
return l == r; | ||
} | ||
}; | ||
|
||
// Derive from this class to define ADL-only operator== and operator!= on the basis of | ||
// an ADL-only tag_invoke(equal_to, l, r). | ||
class equality_operators { | ||
template <typename L, typename R> | ||
constexpr static auto impl(rank<1>, L& l, R& r) BSONCXX_PRIVATE_RETURNS(tag_invoke(equal_to{}, l, r)); | ||
|
||
template <typename L, typename R> | ||
constexpr static auto impl(rank<0>, L& l, R& r) BSONCXX_PRIVATE_RETURNS(tag_invoke(equal_to{}, r, l)); | ||
|
||
// @cond DOXYGEN_DISABLE "Found ';' while parsing initializer list!" | ||
template <typename Left, typename Other> | ||
constexpr friend auto operator==(Left const& self, Other const& other) | ||
BSONCXX_PRIVATE_RETURNS(equality_operators::impl(rank<1>{}, self, other)); | ||
// @endcond | ||
|
||
// @cond DOXYGEN_DISABLE "Found ';' while parsing initializer list!" | ||
template <typename Left, typename Other> | ||
constexpr friend auto operator!=(Left const& self, Other const& other) | ||
BSONCXX_PRIVATE_RETURNS(!equality_operators::impl(rank<1>{}, self, other)); | ||
// @endcond | ||
}; | ||
|
||
// Very basic impl of C++20 std::strong_ordering. | ||
// | ||
// We don't need other weaker orderings yet, so this is all that we have. | ||
class strong_ordering { | ||
signed char _c; | ||
struct _construct {}; | ||
|
||
constexpr strong_ordering(_construct, signed char c) noexcept : _c(c) {} | ||
|
||
public: | ||
static strong_ordering const less; | ||
static strong_ordering const greater; | ||
static strong_ordering const equivalent; | ||
static strong_ordering const equal; | ||
|
||
constexpr strong_ordering(std::nullptr_t) noexcept : strong_ordering(_construct{}, 0) {} | ||
|
||
constexpr bool operator==(strong_ordering o) const noexcept { | ||
return _c == o._c; | ||
} | ||
constexpr bool operator!=(strong_ordering o) const noexcept { | ||
return !(*this == o); | ||
} | ||
#pragma push_macro("DEFOP") | ||
#undef DEFOP | ||
#define DEFOP(Op) \ | ||
constexpr bool operator Op(std::nullptr_t) const noexcept { \ | ||
return _c Op 0; \ | ||
} \ | ||
static_assert(true, "") | ||
DEFOP(<); | ||
DEFOP(>); | ||
DEFOP(<=); | ||
DEFOP(>=); | ||
#pragma pop_macro("DEFOP") | ||
|
||
// nonstd: Swap greater/less values | ||
constexpr strong_ordering inverted() const noexcept { | ||
return *this < nullptr ? greater : *this > nullptr ? less : *this; | ||
} | ||
}; | ||
|
||
#pragma push_macro("INLINE_VAR") | ||
#undef INLINE_VAR | ||
#define INLINE_VAR \ | ||
BSONCXX_PRIVATE_IF_GNU_LIKE([[gnu::weak]]) \ | ||
BSONCXX_PRIVATE_IF_MSVC(__declspec(selectany)) | ||
|
||
INLINE_VAR const strong_ordering strong_ordering::less = strong_ordering(strong_ordering::_construct{}, -1); | ||
INLINE_VAR const strong_ordering strong_ordering::greater = strong_ordering(strong_ordering::_construct{}, 1); | ||
INLINE_VAR const strong_ordering strong_ordering::equivalent = strong_ordering(strong_ordering::_construct{}, 0); | ||
INLINE_VAR const strong_ordering strong_ordering::equal = strong_ordering(strong_ordering::_construct{}, 0); | ||
|
||
#pragma pop_macro("INLINE_VAR") | ||
|
||
// Implements a three-way comparison between two objects. That is, in | ||
// a single operation, determine whether the left operand is less-than, greater-than, | ||
// or equal-to the right-hand operand. | ||
struct compare_three_way { | ||
BSONCXX_PRIVATE_WARNINGS_PUSH(); | ||
BSONCXX_PRIVATE_WARNINGS_DISABLE(GNU("-Wfloat-equal")); | ||
template < | ||
typename L, | ||
typename R, | ||
typename = decltype(std::declval<L>() < std::declval<R>()), | ||
typename = decltype(std::declval<L>() == std::declval<R>())> | ||
constexpr static strong_ordering impl(L const& l, R const& r, rank<1>) { | ||
return (l < r) ? strong_ordering::less : (l == r ? strong_ordering::equal : strong_ordering::greater); | ||
} | ||
BSONCXX_PRIVATE_WARNINGS_POP(); | ||
|
||
template < | ||
typename L, | ||
typename R, | ||
typename = decltype(tag_invoke(std::declval<compare_three_way>(), std::declval<L>(), std::declval<R>()))> | ||
constexpr static strong_ordering impl(L const& l, R const& r, rank<2>) { | ||
return tag_invoke(compare_three_way{}, l, r); | ||
} | ||
|
||
template <typename L, typename R> | ||
constexpr auto operator()(L const& l, R const& r) const BSONCXX_PRIVATE_RETURNS((impl)(l, r, rank<2>{})); | ||
}; | ||
|
||
// Inherit to define ADL-visible ordering operators based on an ADL-visible | ||
// implementation of tag_invoke(compare_three_way, l, r). | ||
struct ordering_operators { | ||
template <typename L, typename R> | ||
constexpr static auto impl(L const& l, R const& r, rank<1>) | ||
BSONCXX_PRIVATE_RETURNS(tag_invoke(compare_three_way{}, l, r)); | ||
|
||
template <typename L, typename R> | ||
constexpr static auto impl(L const& l, R const& r, rank<0>) | ||
BSONCXX_PRIVATE_RETURNS(tag_invoke(compare_three_way{}, r, l).inverted()); | ||
|
||
#pragma push_macro("DEFOP") | ||
#undef DEFOP | ||
#define DEFOP(Oper) \ | ||
template <typename L, typename R> \ | ||
constexpr friend auto operator Oper(L const& l, R const& r) \ | ||
BSONCXX_PRIVATE_RETURNS(ordering_operators::impl(l, r, rank<1>{}) Oper nullptr) | ||
DEFOP(<); | ||
DEFOP(>); | ||
DEFOP(<=); | ||
DEFOP(>=); | ||
#pragma pop_macro("DEFOP") | ||
}; | ||
|
||
} // namespace detail | ||
} // namespace bsoncxx | ||
|
||
#include <bsoncxx/v1/detail/postlude.hpp> | ||
|
||
/// | ||
/// @file | ||
/// For internal use only! | ||
/// | ||
/// @warning For internal use only! | ||
/// |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no
bsoncxx/
subdirectory underv1/
(e.g.bsoncxx/v1/bsoncxx/
) as there is no future plans to update or remove the existing include directory paths tobsoncxx/v_noabi/bsoncxx/
to support<bsoncxx/header.hpp>
(unstable ABI interfaces). Thev_noabi
headers will continue to provide root namespace redeclarations even after stable ABI interfaces are released and the ABI version number is made stable. Only users who need to maintain ABI stability requirements will need to include ABI-specific headers (e.g. following an API breaking change that updates redeclarations fromv1 -> v2
while preserving the ABI stability ofv1
symbols).