Skip to content

Commit 6f77257

Browse files
authored
CXX-3173 Make make_unique.hpp an internal header (#1265)
* Rename: stdx/make_unique.hpp -> private/make_unique.hh * Move make_unique out of stdx namespace
1 parent 3865adf commit 6f77257

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+191
-270
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Changes prior to 3.9.0 are documented as [release notes on GitHub](https://githu
1717
- Use `bsoncxx::stdx::optional<T>` instead of `mongocxx::stdx::optional<T>`.
1818
- Use `bsoncxx::stdx::string_view` instead of `mongocxx::stdx::string_view`.
1919
- Inline namespace macros for bsoncxx and mongocxx namespace: `*_INLINE_NAMESPACE_*`.
20+
- The `<bsoncxx/stdx/make_unique.hpp>` header.
2021
- The `<bsoncxx/types/value.hpp>` header.
2122
- The `<bsoncxx/util/functor.hpp>` header.
2223
- The `<mongocxx/options/create_collection.hpp>` header.

benchmark/benchmark_runner.cpp

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

1515
#include "benchmark_runner.hpp"
1616

17-
#include <chrono>
18-
#include <cstdint>
19-
#include <fstream>
20-
#include <iomanip>
21-
#include <iostream>
22-
#include <memory>
23-
#include <sstream>
24-
2517
#include "bson/bson_encoding.hpp"
2618
#include "multi_doc/bulk_insert.hpp"
2719
#include "multi_doc/find_many.hpp"
@@ -34,55 +26,62 @@
3426
#include "single_doc/find_one_by_id.hpp"
3527
#include "single_doc/insert_one.hpp"
3628
#include "single_doc/run_command.hpp"
29+
30+
#include <chrono>
31+
#include <cstdint>
32+
#include <fstream>
33+
#include <iomanip>
34+
#include <iostream>
35+
#include <memory>
36+
#include <sstream>
37+
3738
#include <bsoncxx/builder/basic/array.hpp>
3839
#include <bsoncxx/builder/basic/document.hpp>
3940
#include <bsoncxx/builder/basic/kvp.hpp>
4041
#include <bsoncxx/builder/basic/sub_document.hpp>
4142
#include <bsoncxx/json.hpp>
42-
#include <bsoncxx/stdx/make_unique.hpp>
4343
#include <bsoncxx/types.hpp>
4444

4545
namespace benchmark {
4646

4747
// The task sizes and iteration numbers come from the Driver Perfomance Benchmarking Reference Doc.
4848
benchmark_runner::benchmark_runner(std::set<benchmark_type> types) : _types{types} {
49-
using bsoncxx::stdx::make_unique;
50-
5149
// Bson microbenchmarks
5250
_microbenches.push_back(
53-
make_unique<bson_encoding>("TestFlatEncoding", 75.31, "extended_bson/flat_bson.json"));
51+
std::make_unique<bson_encoding>("TestFlatEncoding", 75.31, "extended_bson/flat_bson.json"));
5452
_microbenches.push_back(
55-
make_unique<bson_encoding>("TestDeepEncoding", 19.64, "extended_bson/deep_bson.json"));
53+
std::make_unique<bson_encoding>("TestDeepEncoding", 19.64, "extended_bson/deep_bson.json"));
5654
_microbenches.push_back(
57-
make_unique<bson_encoding>("TestFullEncoding", 57.34, "extended_bson/full_bson.json"));
55+
std::make_unique<bson_encoding>("TestFullEncoding", 57.34, "extended_bson/full_bson.json"));
5856
// TODO CXX-1241: Add bson_decoding equivalents.
5957

6058
// Single doc microbenchmarks
61-
_microbenches.push_back(make_unique<run_command>());
62-
_microbenches.push_back(make_unique<find_one_by_id>("single_and_multi_document/tweet.json"));
63-
_microbenches.push_back(make_unique<insert_one>(
59+
_microbenches.push_back(std::make_unique<run_command>());
60+
_microbenches.push_back(
61+
std::make_unique<find_one_by_id>("single_and_multi_document/tweet.json"));
62+
_microbenches.push_back(std::make_unique<insert_one>(
6463
"TestSmallDocInsertOne", 2.75, iterations, "single_and_multi_document/small_doc.json"));
65-
_microbenches.push_back(make_unique<insert_one>(
64+
_microbenches.push_back(std::make_unique<insert_one>(
6665
"TestLargeDocInsertOne", 27.31, 10, "single_and_multi_document/large_doc.json"));
6766

6867
// Multi doc microbenchmarks
69-
_microbenches.push_back(make_unique<find_many>("single_and_multi_document/tweet.json"));
70-
_microbenches.push_back(make_unique<bulk_insert>(
68+
_microbenches.push_back(std::make_unique<find_many>("single_and_multi_document/tweet.json"));
69+
_microbenches.push_back(std::make_unique<bulk_insert>(
7170
"TestSmallDocBulkInsert", 2.75, iterations, "single_and_multi_document/small_doc.json"));
72-
_microbenches.push_back(make_unique<bulk_insert>(
71+
_microbenches.push_back(std::make_unique<bulk_insert>(
7372
"TestLargeDocBulkInsert", 27.31, 10, "single_and_multi_document/large_doc.json"));
7473
// CXX-2794: Disable GridFS benchmarks due to long runtime
7574
// _microbenches.push_back(
76-
// make_unique<gridfs_upload>("single_and_multi_document/gridfs_large.bin"));
75+
// std::make_unique<gridfs_upload>("single_and_multi_document/gridfs_large.bin"));
7776
// _microbenches.push_back(
78-
// make_unique<gridfs_download>("single_and_multi_document/gridfs_large.bin"));
77+
// std::make_unique<gridfs_download>("single_and_multi_document/gridfs_large.bin"));
7978

8079
// Parallel microbenchmarks
81-
_microbenches.push_back(make_unique<json_multi_import>("parallel/ldjson_multi"));
82-
_microbenches.push_back(make_unique<json_multi_export>("parallel/ldjson_multi"));
80+
_microbenches.push_back(std::make_unique<json_multi_import>("parallel/ldjson_multi"));
81+
_microbenches.push_back(std::make_unique<json_multi_export>("parallel/ldjson_multi"));
8382
// CXX-2794: Disable GridFS benchmarks due to long runtime
84-
// _microbenches.push_back(make_unique<gridfs_multi_import>("parallel/gridfs_multi"));
85-
// _microbenches.push_back(make_unique<gridfs_multi_export>("parallel/gridfs_multi"));
83+
// _microbenches.push_back(std::make_unique<gridfs_multi_import>("parallel/gridfs_multi"));
84+
// _microbenches.push_back(std::make_unique<gridfs_multi_export>("parallel/gridfs_multi"));
8685

8786
// Need to remove some
8887
if (!_types.empty()) {

benchmark/multi_doc/gridfs_download.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414

1515
#pragma once
1616

17+
#include "../microbench.hpp"
18+
1719
#include <algorithm>
1820
#include <fstream>
21+
#include <memory>
1922

20-
#include "../microbench.hpp"
21-
#include <bsoncxx/stdx/make_unique.hpp>
2223
#include <bsoncxx/stdx/optional.hpp>
24+
2325
#include <mongocxx/client.hpp>
2426
#include <mongocxx/gridfs/bucket.hpp>
2527
#include <mongocxx/instance.hpp>
@@ -29,7 +31,6 @@ namespace benchmark {
2931

3032
using bsoncxx::builder::basic::kvp;
3133
using bsoncxx::builder::basic::make_document;
32-
using bsoncxx::stdx::make_unique;
3334

3435
class gridfs_download : public microbench {
3536
public:
@@ -74,7 +75,7 @@ void gridfs_download::task() {
7475
auto file_length = downloader.file_length();
7576

7677
auto buffer_size = std::min(file_length, static_cast<std::int64_t>(downloader.chunk_size()));
77-
auto buffer = make_unique<std::uint8_t[]>(static_cast<std::size_t>(buffer_size));
78+
auto buffer = std::make_unique<std::uint8_t[]>(static_cast<std::size_t>(buffer_size));
7879

7980
while ([[maybe_unused]] auto length_read =
8081
downloader.read(buffer.get(), static_cast<std::size_t>(buffer_size))) {

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/value.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
#include <bsoncxx/array/view_or_value.hpp>
2626
#include <bsoncxx/document/view_or_value.hpp>
27-
#include <bsoncxx/stdx/make_unique.hpp>
2827
#include <bsoncxx/types/bson_value/view.hpp>
2928

3029
#include <bsoncxx/config/prelude.hpp>

src/bsoncxx/lib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ set_dist_list(src_bsoncxx_lib_DIST
7777
bsoncxx/v_noabi/bsoncxx/config/version.hpp.in
7878
bsoncxx/v_noabi/bsoncxx/private/b64_ntop.hh
7979
bsoncxx/v_noabi/bsoncxx/private/helpers.hh
80+
bsoncxx/v_noabi/bsoncxx/private/make_unique.hh
8081
bsoncxx/v_noabi/bsoncxx/private/itoa.hh
8182
bsoncxx/v_noabi/bsoncxx/private/libbson.hh
8283
bsoncxx/v_noabi/bsoncxx/private/stack.hh

src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/builder/core.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
#include <bsoncxx/exception/exception.hpp>
2020
#include <bsoncxx/private/itoa.hh>
2121
#include <bsoncxx/private/libbson.hh>
22+
#include <bsoncxx/private/make_unique.hh>
2223
#include <bsoncxx/private/stack.hh>
2324
#include <bsoncxx/private/suppress_deprecation_warnings.hh>
24-
#include <bsoncxx/stdx/make_unique.hpp>
2525
#include <bsoncxx/stdx/string_view.hpp>
2626
#include <bsoncxx/string/to_string.hpp>
2727
#include <bsoncxx/types.hpp>
@@ -256,7 +256,7 @@ class core::impl {
256256
};
257257

258258
core::core(bool is_array) {
259-
_impl = stdx::make_unique<impl>(is_array);
259+
_impl = make_unique<impl>(is_array);
260260
}
261261

262262
core::core(core&&) noexcept = default;

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/make_unique.hpp renamed to src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/private/make_unique.hh

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
#include <bsoncxx/stdx/type_traits.hpp>
3737

3838
namespace bsoncxx {
39-
namespace v_noabi {
40-
namespace stdx {
4139
namespace detail {
4240

4341
// Switch backend of make_unique by the type we are creating.
@@ -95,21 +93,17 @@ template <typename T>
9593
struct make_unique_impl<T&&> {};
9694

9795
} // namespace detail
98-
} // namespace stdx
99-
} // namespace v_noabi
10096
} // namespace bsoncxx
10197

10298
#endif // !defined(BSONCXX_DETAIL_USE_STD_MAKE_UNIQUE) ||
10399
// !defined(__cpp_lib_smart_ptr_for_overwrite)
104100

105101
namespace bsoncxx {
106-
namespace v_noabi {
107-
namespace stdx {
108102

109103
// Unlike other C++17 polyfill features, this is a C++14 feature.
110104
// Use feature testing rather than polyfill library selection macros.
111105
#if defined(BSONCXX_DETAIL_USE_STD_MAKE_UNIQUE)
112-
using ::std::make_unique;
106+
using std::make_unique;
113107
#else
114108

115109
// Equivalent to `std::make_unique<T>(args...)` where `T` is a non-array type.
@@ -143,7 +137,7 @@ std::unique_ptr<T> make_unique(std::size_t count) {
143137
// Unlike other C++17 polyfill features, this is a C++20 feature.
144138
// Use feature testing rather than polyfill library selection macros.
145139
#if defined(__cpp_lib_smart_ptr_for_overwrite)
146-
using ::std::make_unique_for_overwrite;
140+
using std::make_unique_for_overwrite;
147141
#else
148142

149143
// Equivalent to `std::make_unique_for_overwrite<T>()` where `T` is a non-array type.
@@ -168,68 +162,8 @@ std::unique_ptr<T> make_unique_for_overwrite(std::size_t count) {
168162

169163
#endif
170164

171-
} // namespace stdx
172-
} // namespace v_noabi
173165
} // namespace bsoncxx
174166

175167
#pragma pop_macro("BSONCXX_DETAIL_USE_STD_MAKE_UNIQUE")
176168

177169
#include <bsoncxx/config/postlude.hpp>
178-
179-
namespace bsoncxx {
180-
namespace stdx {
181-
182-
using ::bsoncxx::v_noabi::stdx::make_unique;
183-
using ::bsoncxx::v_noabi::stdx::make_unique_for_overwrite;
184-
185-
} // namespace stdx
186-
} // namespace bsoncxx
187-
188-
///
189-
/// @file
190-
/// Provides `std::make_unique`-related polyfills for internal use.
191-
///
192-
/// @deprecated Primarily for internal use; will be removed in an upcoming major release.
193-
///
194-
195-
#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
196-
197-
namespace bsoncxx {
198-
namespace v_noabi {
199-
namespace stdx {
200-
201-
///
202-
/// Equivalent to `std::make_unique` for non-array types.
203-
///
204-
/// @deprecated Primarily for internal use; will be removed in an upcoming major release.
205-
///
206-
template <typename T, typename... Args>
207-
std::unique_ptr<T> make_unique(Args&&... args);
208-
209-
///
210-
/// Equivalent to `std::make_unique` for array types.
211-
///
212-
/// @deprecated Primarily for internal use. Will be removed in an upcoming major release.
213-
///
214-
template <typename T>
215-
std::unique_ptr<T> make_unique(std::size_t count);
216-
217-
} // namespace stdx
218-
} // namespace v_noabi
219-
} // namespace bsoncxx
220-
221-
namespace bsoncxx {
222-
namespace stdx {
223-
224-
/// @ref bsoncxx::v_noabi::stdx::make_unique(Args&&... args)
225-
template <typename T, typename... Args>
226-
std::unique_ptr<T> make_unique(Args&&... args);
227-
228-
/// @ref bsoncxx::v_noabi::stdx::make_unique(std::size_t count)
229-
template <typename T>
230-
std::unique_ptr<T> make_unique(std::size_t count);
231-
232-
} // namespace stdx
233-
} // namespace bsoncxx
234-
235-
#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)

0 commit comments

Comments
 (0)