diff options
Diffstat (limited to 'src/mongo/db/matcher')
48 files changed, 237 insertions, 232 deletions
diff --git a/src/mongo/db/matcher/copyable_match_expression.h b/src/mongo/db/matcher/copyable_match_expression.h index 01aa490e8a8..e9a9bb16346 100644 --- a/src/mongo/db/matcher/copyable_match_expression.h +++ b/src/mongo/db/matcher/copyable_match_expression.h @@ -54,7 +54,7 @@ public: CopyableMatchExpression(BSONObj matchAST, const boost::intrusive_ptr<ExpressionContext>& expCtx, std::unique_ptr<const ExtensionsCallback> extensionsCallback = - stdx::make_unique<ExtensionsCallbackNoop>(), + std::make_unique<ExtensionsCallbackNoop>(), MatchExpressionParser::AllowedFeatureSet allowedFeatures = MatchExpressionParser::kDefaultSpecialFeatures) : _matchAST(matchAST), _extensionsCallback(std::move(extensionsCallback)) { diff --git a/src/mongo/db/matcher/expression.h b/src/mongo/db/matcher/expression.h index 50a0aac4578..c01bee6c697 100644 --- a/src/mongo/db/matcher/expression.h +++ b/src/mongo/db/matcher/expression.h @@ -30,6 +30,7 @@ #pragma once #include <functional> +#include <memory> #include "mongo/base/status.h" #include "mongo/bson/bsonobj.h" @@ -37,7 +38,6 @@ #include "mongo/db/matcher/match_details.h" #include "mongo/db/matcher/matchable.h" #include "mongo/db/pipeline/dependencies.h" -#include "mongo/stdx/memory.h" #include "mongo/util/fail_point_service.h" namespace mongo { diff --git a/src/mongo/db/matcher/expression_algo.cpp b/src/mongo/db/matcher/expression_algo.cpp index 67acd98d672..bd57e96b5fe 100644 --- a/src/mongo/db/matcher/expression_algo.cpp +++ b/src/mongo/db/matcher/expression_algo.cpp @@ -250,7 +250,7 @@ unique_ptr<MatchExpression> createAndOfNodes(std::vector<unique_ptr<MatchExpress return std::move(children->at(0)); } - unique_ptr<AndMatchExpression> splitAnd = stdx::make_unique<AndMatchExpression>(); + unique_ptr<AndMatchExpression> splitAnd = std::make_unique<AndMatchExpression>(); for (auto&& expr : *children) { splitAnd->add(expr.release()); } @@ -266,7 +266,7 @@ unique_ptr<MatchExpression> createNorOfNodes(std::vector<unique_ptr<MatchExpress return nullptr; } - unique_ptr<NorMatchExpression> splitNor = stdx::make_unique<NorMatchExpression>(); + unique_ptr<NorMatchExpression> splitNor = std::make_unique<NorMatchExpression>(); for (auto&& expr : *children) { splitNor->add(expr.release()); } diff --git a/src/mongo/db/matcher/expression_always_boolean.h b/src/mongo/db/matcher/expression_always_boolean.h index d638a4b4851..6db02f58bc0 100644 --- a/src/mongo/db/matcher/expression_always_boolean.h +++ b/src/mongo/db/matcher/expression_always_boolean.h @@ -101,7 +101,7 @@ public: } std::unique_ptr<MatchExpression> shallowClone() const final { - return stdx::make_unique<AlwaysFalseMatchExpression>(); + return std::make_unique<AlwaysFalseMatchExpression>(); } bool isTriviallyFalse() const final { @@ -120,7 +120,7 @@ public: } std::unique_ptr<MatchExpression> shallowClone() const final { - return stdx::make_unique<AlwaysTrueMatchExpression>(); + return std::make_unique<AlwaysTrueMatchExpression>(); } bool isTriviallyTrue() const final { diff --git a/src/mongo/db/matcher/expression_always_boolean_test.cpp b/src/mongo/db/matcher/expression_always_boolean_test.cpp index 5f89e36c48c..e18c7be11e8 100644 --- a/src/mongo/db/matcher/expression_always_boolean_test.cpp +++ b/src/mongo/db/matcher/expression_always_boolean_test.cpp @@ -46,7 +46,7 @@ TEST(AlwaysFalseMatchExpression, RejectsAllObjects) { } TEST(AlwaysFalseMatchExpression, EquivalentReturnsCorrectResults) { - auto falseExpr = stdx::make_unique<AlwaysFalseMatchExpression>(); + auto falseExpr = std::make_unique<AlwaysFalseMatchExpression>(); ASSERT_TRUE(falseExpr->equivalent(falseExpr.get())); ASSERT_TRUE(falseExpr->equivalent(falseExpr->shallowClone().get())); @@ -65,7 +65,7 @@ TEST(AlwaysTrueMatchExpression, AcceptsAllObjects) { } TEST(AlwaysTrueMatchExpression, EquivalentReturnsCorrectResults) { - auto trueExpr = stdx::make_unique<AlwaysTrueMatchExpression>(); + auto trueExpr = std::make_unique<AlwaysTrueMatchExpression>(); ASSERT_TRUE(trueExpr->equivalent(trueExpr.get())); ASSERT_TRUE(trueExpr->equivalent(trueExpr->shallowClone().get())); diff --git a/src/mongo/db/matcher/expression_arity.h b/src/mongo/db/matcher/expression_arity.h index 9e1766197b9..2d2d93c5875 100644 --- a/src/mongo/db/matcher/expression_arity.h +++ b/src/mongo/db/matcher/expression_arity.h @@ -31,9 +31,9 @@ #include <algorithm> #include <array> +#include <memory> #include "mongo/db/matcher/expression.h" -#include "mongo/stdx/memory.h" namespace mongo { @@ -123,7 +123,7 @@ public: return orig ? orig->shallowClone() : std::unique_ptr<MatchExpression>(nullptr); }); - std::unique_ptr<T> clone = stdx::make_unique<T>(std::move(clonedExpressions)); + std::unique_ptr<T> clone = std::make_unique<T>(std::move(clonedExpressions)); if (getTag()) { clone->setTag(getTag()->clone()); diff --git a/src/mongo/db/matcher/expression_array.h b/src/mongo/db/matcher/expression_array.h index 471549f105e..dc27f2f2ef0 100644 --- a/src/mongo/db/matcher/expression_array.h +++ b/src/mongo/db/matcher/expression_array.h @@ -76,8 +76,8 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const { std::unique_ptr<ElemMatchObjectMatchExpression> e = - stdx::make_unique<ElemMatchObjectMatchExpression>(path(), - _sub->shallowClone().release()); + std::make_unique<ElemMatchObjectMatchExpression>(path(), + _sub->shallowClone().release()); if (getTag()) { e->setTag(getTag()->clone()); } @@ -129,7 +129,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const { std::unique_ptr<ElemMatchValueMatchExpression> e = - stdx::make_unique<ElemMatchValueMatchExpression>(path()); + std::make_unique<ElemMatchValueMatchExpression>(path()); for (size_t i = 0; i < _subs.size(); ++i) { e->add(_subs[i]->shallowClone().release()); } @@ -169,7 +169,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const { std::unique_ptr<SizeMatchExpression> e = - stdx::make_unique<SizeMatchExpression>(path(), _size); + std::make_unique<SizeMatchExpression>(path(), _size); if (getTag()) { e->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/expression_expr.cpp b/src/mongo/db/matcher/expression_expr.cpp index de1c1f956eb..f58c1c14ef8 100644 --- a/src/mongo/db/matcher/expression_expr.cpp +++ b/src/mongo/db/matcher/expression_expr.cpp @@ -102,7 +102,7 @@ std::unique_ptr<MatchExpression> ExprMatchExpression::shallowClone() const { boost::intrusive_ptr<Expression> clonedExpr = Expression::parseOperand(_expCtx, bob.obj().firstElement(), _expCtx->variablesParseState); - auto clone = stdx::make_unique<ExprMatchExpression>(std::move(clonedExpr), _expCtx); + auto clone = std::make_unique<ExprMatchExpression>(std::move(clonedExpr), _expCtx); if (_rewriteResult) { clone->_rewriteResult = _rewriteResult->clone(); } @@ -126,7 +126,7 @@ MatchExpression::ExpressionOptimizerFunc ExprMatchExpression::getOptimizer() con RewriteExpr::rewrite(exprMatchExpr._expression, exprMatchExpr._expCtx->getCollator()); if (exprMatchExpr._rewriteResult->matchExpression()) { - auto andMatch = stdx::make_unique<AndMatchExpression>(); + auto andMatch = std::make_unique<AndMatchExpression>(); andMatch->add(exprMatchExpr._rewriteResult->releaseMatchExpression().release()); andMatch->add(expression.release()); // Re-optimize the new AND in order to make sure that any AND children are absorbed. diff --git a/src/mongo/db/matcher/expression_expr_test.cpp b/src/mongo/db/matcher/expression_expr_test.cpp index ce97e822b37..16fdd7b6485 100644 --- a/src/mongo/db/matcher/expression_expr_test.cpp +++ b/src/mongo/db/matcher/expression_expr_test.cpp @@ -547,7 +547,7 @@ TEST_F(ExprMatchTest, TEST_F(ExprMatchTest, InitialCollationUsedForComparisons) { auto collator = - stdx::make_unique<CollatorInterfaceMock>(CollatorInterfaceMock::MockType::kToLowerString); + std::make_unique<CollatorInterfaceMock>(CollatorInterfaceMock::MockType::kToLowerString); setCollator(collator.get()); createMatcher(fromjson("{$expr: {$eq: ['$x', 'abc']}}")); @@ -562,7 +562,7 @@ TEST_F(ExprMatchTest, SetCollatorChangesCollationUsedForComparisons) { createMatcher(fromjson("{$expr: {$eq: ['$x', 'abc']}}")); auto collator = - stdx::make_unique<CollatorInterfaceMock>(CollatorInterfaceMock::MockType::kToLowerString); + std::make_unique<CollatorInterfaceMock>(CollatorInterfaceMock::MockType::kToLowerString); setCollator(collator.get()); ASSERT_TRUE(matches(BSON("x" @@ -607,7 +607,7 @@ TEST(ExprMatchTest, IdenticalPostOptimizedExpressionsAreEquivalent) { // Create and optimize an ExprMatchExpression. const boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest()); std::unique_ptr<MatchExpression> matchExpr = - stdx::make_unique<ExprMatchExpression>(expression.firstElement(), expCtx); + std::make_unique<ExprMatchExpression>(expression.firstElement(), expCtx); matchExpr = MatchExpression::optimize(std::move(matchExpr)); // We expect that the optimized 'matchExpr' is still an ExprMatchExpression. @@ -636,7 +636,7 @@ TEST(ExprMatchTest, ExpressionOptimizeRewritesVariableDereferenceAsConstant) { // Create and optimize an ExprMatchExpression. std::unique_ptr<MatchExpression> matchExpr = - stdx::make_unique<ExprMatchExpression>(expression.firstElement(), expCtx); + std::make_unique<ExprMatchExpression>(expression.firstElement(), expCtx); matchExpr = MatchExpression::optimize(std::move(matchExpr)); // We expect that the optimized 'matchExpr' is still an ExprMatchExpression. @@ -656,7 +656,7 @@ TEST(ExprMatchTest, OptimizingIsANoopWhenAlreadyOptimized) { // Create and optimize an ExprMatchExpression. std::unique_ptr<MatchExpression> singlyOptimized = - stdx::make_unique<ExprMatchExpression>(expression.firstElement(), expCtx); + std::make_unique<ExprMatchExpression>(expression.firstElement(), expCtx); singlyOptimized = MatchExpression::optimize(std::move(singlyOptimized)); // We expect that the optimized 'matchExpr' is now an $and. @@ -664,7 +664,7 @@ TEST(ExprMatchTest, OptimizingIsANoopWhenAlreadyOptimized) { // We expect the twice-optimized match expression to be equivalent to the once-optimized one. std::unique_ptr<MatchExpression> doublyOptimized = - stdx::make_unique<ExprMatchExpression>(expression.firstElement(), expCtx); + std::make_unique<ExprMatchExpression>(expression.firstElement(), expCtx); for (size_t i = 0; i < 2u; ++i) { doublyOptimized = MatchExpression::optimize(std::move(doublyOptimized)); } @@ -677,7 +677,7 @@ TEST(ExprMatchTest, OptimizingAnAlreadyOptimizedCloneIsANoop) { // Create and optimize an ExprMatchExpression. std::unique_ptr<MatchExpression> singlyOptimized = - stdx::make_unique<ExprMatchExpression>(expression.firstElement(), expCtx); + std::make_unique<ExprMatchExpression>(expression.firstElement(), expCtx); singlyOptimized = MatchExpression::optimize(std::move(singlyOptimized)); // We expect that the optimized 'matchExpr' is now an $and. diff --git a/src/mongo/db/matcher/expression_geo.cpp b/src/mongo/db/matcher/expression_geo.cpp index 99081c3e910..18e38b319f0 100644 --- a/src/mongo/db/matcher/expression_geo.cpp +++ b/src/mongo/db/matcher/expression_geo.cpp @@ -403,7 +403,7 @@ bool GeoMatchExpression::equivalent(const MatchExpression* other) const { std::unique_ptr<MatchExpression> GeoMatchExpression::shallowClone() const { std::unique_ptr<GeoMatchExpression> next = - stdx::make_unique<GeoMatchExpression>(path(), _query, _rawObj); + std::make_unique<GeoMatchExpression>(path(), _query, _rawObj); next->_canSkipValidation = _canSkipValidation; if (getTag()) { next->setTag(getTag()->clone()); @@ -461,7 +461,7 @@ bool GeoNearMatchExpression::equivalent(const MatchExpression* other) const { std::unique_ptr<MatchExpression> GeoNearMatchExpression::shallowClone() const { std::unique_ptr<GeoNearMatchExpression> next = - stdx::make_unique<GeoNearMatchExpression>(path(), _query, _rawObj); + std::make_unique<GeoNearMatchExpression>(path(), _query, _rawObj); if (getTag()) { next->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/expression_geo_test.cpp b/src/mongo/db/matcher/expression_geo_test.cpp index 56ddaa674ea..5d8d6744a34 100644 --- a/src/mongo/db/matcher/expression_geo_test.cpp +++ b/src/mongo/db/matcher/expression_geo_test.cpp @@ -31,11 +31,12 @@ #include "mongo/unittest/unittest.h" +#include <memory> + #include "mongo/db/jsobj.h" #include "mongo/db/json.h" #include "mongo/db/matcher/expression.h" #include "mongo/db/matcher/expression_geo.h" -#include "mongo/stdx/memory.h" namespace mongo { @@ -74,7 +75,7 @@ std::unique_ptr<GeoMatchExpression> makeGeoMatchExpression(const BSONObj& locQue ASSERT_OK(gq->parseFrom(locQuery)); std::unique_ptr<GeoMatchExpression> ge = - stdx::make_unique<GeoMatchExpression>("a", gq.release(), locQuery); + std::make_unique<GeoMatchExpression>("a", gq.release(), locQuery); return ge; } @@ -84,7 +85,7 @@ std::unique_ptr<GeoNearMatchExpression> makeGeoNearMatchExpression(const BSONObj ASSERT_OK(nq->parseFrom(locQuery)); std::unique_ptr<GeoNearMatchExpression> gne = - stdx::make_unique<GeoNearMatchExpression>("a", nq.release(), locQuery); + std::make_unique<GeoNearMatchExpression>("a", nq.release(), locQuery); return gne; } diff --git a/src/mongo/db/matcher/expression_internal_expr_eq.cpp b/src/mongo/db/matcher/expression_internal_expr_eq.cpp index 6757384bcf5..4c7e32f353b 100644 --- a/src/mongo/db/matcher/expression_internal_expr_eq.cpp +++ b/src/mongo/db/matcher/expression_internal_expr_eq.cpp @@ -58,7 +58,7 @@ bool InternalExprEqMatchExpression::matchesSingleElement(const BSONElement& elem } std::unique_ptr<MatchExpression> InternalExprEqMatchExpression::shallowClone() const { - auto clone = stdx::make_unique<InternalExprEqMatchExpression>(path(), _rhs); + auto clone = std::make_unique<InternalExprEqMatchExpression>(path(), _rhs); clone->setCollator(_collator); if (getTag()) { clone->setTag(getTag()->clone()); diff --git a/src/mongo/db/matcher/expression_internal_expr_eq_test.cpp b/src/mongo/db/matcher/expression_internal_expr_eq_test.cpp index 337dc1bfff8..a16a7fe6447 100644 --- a/src/mongo/db/matcher/expression_internal_expr_eq_test.cpp +++ b/src/mongo/db/matcher/expression_internal_expr_eq_test.cpp @@ -291,7 +291,7 @@ TEST(InternalExprEqMatchExpression, EquivalentToClone) { CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString); Matcher eq(query, expCtx); eq.getMatchExpression()->setCollator(&collator); - auto relevantTag = stdx::make_unique<RelevantTag>(); + auto relevantTag = std::make_unique<RelevantTag>(); relevantTag->first.push_back(0u); relevantTag->notFirst.push_back(1u); eq.getMatchExpression()->setTag(relevantTag.release()); diff --git a/src/mongo/db/matcher/expression_leaf.cpp b/src/mongo/db/matcher/expression_leaf.cpp index 334dd0201e7..ee43237617e 100644 --- a/src/mongo/db/matcher/expression_leaf.cpp +++ b/src/mongo/db/matcher/expression_leaf.cpp @@ -32,6 +32,7 @@ #include "mongo/db/matcher/expression_leaf.h" #include <cmath> +#include <memory> #include <pcrecpp.h> #include "mongo/bson/bsonelement_comparator.h" @@ -43,7 +44,6 @@ #include "mongo/db/matcher/expression_parser.h" #include "mongo/db/matcher/path.h" #include "mongo/db/query/collation/collator_interface.h" -#include "mongo/stdx/memory.h" #include "mongo/util/regex_util.h" #include "mongo/util/str.h" @@ -367,7 +367,7 @@ InMatchExpression::InMatchExpression(StringData path) _eltCmp(BSONElementComparator::FieldNamesMode::kIgnore, _collator) {} std::unique_ptr<MatchExpression> InMatchExpression::shallowClone() const { - auto next = stdx::make_unique<InMatchExpression>(path()); + auto next = std::make_unique<InMatchExpression>(path()); next->setCollator(_collator); if (getTag()) { next->setTag(getTag()->clone()); @@ -551,7 +551,7 @@ MatchExpression::ExpressionOptimizerFunc InMatchExpression::getOptimizer() const auto& childRe = regexList.front(); invariant(!childRe->getTag()); - auto simplifiedExpression = stdx::make_unique<RegexMatchExpression>( + auto simplifiedExpression = std::make_unique<RegexMatchExpression>( expression->path(), childRe->getString(), childRe->getFlags()); if (expression->getTag()) { simplifiedExpression->setTag(expression->getTag()->clone()); @@ -559,7 +559,7 @@ MatchExpression::ExpressionOptimizerFunc InMatchExpression::getOptimizer() const return std::move(simplifiedExpression); } else if (equalitySet.size() == 1 && regexList.empty()) { // Simplify IN of exactly one equality to be an EqualityMatchExpression. - auto simplifiedExpression = stdx::make_unique<EqualityMatchExpression>( + auto simplifiedExpression = std::make_unique<EqualityMatchExpression>( expression->path(), *(equalitySet.begin())); simplifiedExpression->setCollator(collator); if (expression->getTag()) { diff --git a/src/mongo/db/matcher/expression_leaf.h b/src/mongo/db/matcher/expression_leaf.h index 931ef828d03..df0654e8c87 100644 --- a/src/mongo/db/matcher/expression_leaf.h +++ b/src/mongo/db/matcher/expression_leaf.h @@ -29,13 +29,14 @@ #pragma once +#include <memory> + #include "mongo/bson/bsonelement_comparator.h" #include "mongo/bson/bsonmisc.h" #include "mongo/bson/bsonobj.h" #include "mongo/db/matcher/expression.h" #include "mongo/db/matcher/expression_path.h" #include "mongo/db/query/collation/collator_interface.h" -#include "mongo/stdx/memory.h" #include "mongo/stdx/unordered_map.h" namespace pcrecpp { @@ -191,7 +192,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const { std::unique_ptr<ComparisonMatchExpression> e = - stdx::make_unique<EqualityMatchExpression>(path(), _rhs); + std::make_unique<EqualityMatchExpression>(path(), _rhs); if (getTag()) { e->setTag(getTag()->clone()); } @@ -213,7 +214,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const { std::unique_ptr<ComparisonMatchExpression> e = - stdx::make_unique<LTEMatchExpression>(path(), _rhs); + std::make_unique<LTEMatchExpression>(path(), _rhs); if (getTag()) { e->setTag(getTag()->clone()); } @@ -235,7 +236,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const { std::unique_ptr<ComparisonMatchExpression> e = - stdx::make_unique<LTMatchExpression>(path(), _rhs); + std::make_unique<LTMatchExpression>(path(), _rhs); if (getTag()) { e->setTag(getTag()->clone()); } @@ -257,7 +258,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const { std::unique_ptr<ComparisonMatchExpression> e = - stdx::make_unique<GTMatchExpression>(path(), _rhs); + std::make_unique<GTMatchExpression>(path(), _rhs); if (getTag()) { e->setTag(getTag()->clone()); } @@ -279,7 +280,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const { std::unique_ptr<ComparisonMatchExpression> e = - stdx::make_unique<GTEMatchExpression>(path(), _rhs); + std::make_unique<GTEMatchExpression>(path(), _rhs); if (getTag()) { e->setTag(getTag()->clone()); } @@ -299,7 +300,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const { std::unique_ptr<RegexMatchExpression> e = - stdx::make_unique<RegexMatchExpression>(path(), _regex, _flags); + std::make_unique<RegexMatchExpression>(path(), _regex, _flags); if (getTag()) { e->setTag(getTag()->clone()); } @@ -343,7 +344,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const { std::unique_ptr<ModMatchExpression> m = - stdx::make_unique<ModMatchExpression>(path(), _divisor, _remainder); + std::make_unique<ModMatchExpression>(path(), _divisor, _remainder); if (getTag()) { m->setTag(getTag()->clone()); } @@ -379,7 +380,7 @@ public: explicit ExistsMatchExpression(StringData path); virtual std::unique_ptr<MatchExpression> shallowClone() const { - std::unique_ptr<ExistsMatchExpression> e = stdx::make_unique<ExistsMatchExpression>(path()); + std::unique_ptr<ExistsMatchExpression> e = std::make_unique<ExistsMatchExpression>(path()); if (getTag()) { e->setTag(getTag()->clone()); } @@ -563,7 +564,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const { std::unique_ptr<BitTestMatchExpression> bitTestMatchExpression = - stdx::make_unique<BitsAllSetMatchExpression>(path(), getBitPositions()); + std::make_unique<BitsAllSetMatchExpression>(path(), getBitPositions()); if (getTag()) { bitTestMatchExpression->setTag(getTag()->clone()); } @@ -584,7 +585,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const { std::unique_ptr<BitTestMatchExpression> bitTestMatchExpression = - stdx::make_unique<BitsAllClearMatchExpression>(path(), getBitPositions()); + std::make_unique<BitsAllClearMatchExpression>(path(), getBitPositions()); if (getTag()) { bitTestMatchExpression->setTag(getTag()->clone()); } @@ -605,7 +606,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const { std::unique_ptr<BitTestMatchExpression> bitTestMatchExpression = - stdx::make_unique<BitsAnySetMatchExpression>(path(), getBitPositions()); + std::make_unique<BitsAnySetMatchExpression>(path(), getBitPositions()); if (getTag()) { bitTestMatchExpression->setTag(getTag()->clone()); } @@ -626,7 +627,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const { std::unique_ptr<BitTestMatchExpression> bitTestMatchExpression = - stdx::make_unique<BitsAnyClearMatchExpression>(path(), getBitPositions()); + std::make_unique<BitsAnyClearMatchExpression>(path(), getBitPositions()); if (getTag()) { bitTestMatchExpression->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/expression_optimize_test.cpp b/src/mongo/db/matcher/expression_optimize_test.cpp index ba9345a84a1..cec775d9eb8 100644 --- a/src/mongo/db/matcher/expression_optimize_test.cpp +++ b/src/mongo/db/matcher/expression_optimize_test.cpp @@ -78,7 +78,7 @@ Status isValid(const std::string& queryStr, const QueryRequest& qrRaw) { TEST(ExpressionOptimizeTest, IsValidText) { // Filter inside QueryRequest is not used. - auto qr = stdx::make_unique<QueryRequest>(nss); + auto qr = std::make_unique<QueryRequest>(nss); ASSERT_OK(qr->validate()); // Valid: regular TEXT. @@ -134,7 +134,7 @@ TEST(ExpressionOptimizeTest, IsValidText) { TEST(ExpressionOptimizeTest, IsValidTextTailable) { // Filter inside QueryRequest is not used. - auto qr = stdx::make_unique<QueryRequest>(nss); + auto qr = std::make_unique<QueryRequest>(nss); qr->setTailableMode(TailableModeEnum::kTailable); ASSERT_OK(qr->validate()); @@ -144,7 +144,7 @@ TEST(ExpressionOptimizeTest, IsValidTextTailable) { TEST(ExpressionOptimizeTest, IsValidGeo) { // Filter inside QueryRequest is not used. - auto qr = stdx::make_unique<QueryRequest>(nss); + auto qr = std::make_unique<QueryRequest>(nss); ASSERT_OK(qr->validate()); // Valid: regular GEO_NEAR. @@ -210,7 +210,7 @@ TEST(ExpressionOptimizeTest, IsValidGeo) { TEST(ExpressionOptimizeTest, IsValidTextAndGeo) { // Filter inside QueryRequest is not used. - auto qr = stdx::make_unique<QueryRequest>(nss); + auto qr = std::make_unique<QueryRequest>(nss); ASSERT_OK(qr->validate()); // Invalid: TEXT and GEO_NEAR. @@ -231,7 +231,7 @@ TEST(ExpressionOptimizeTest, IsValidTextAndGeo) { TEST(ExpressionOptimizeTest, IsValidTextAndNaturalAscending) { // Filter inside QueryRequest is not used. - auto qr = stdx::make_unique<QueryRequest>(nss); + auto qr = std::make_unique<QueryRequest>(nss); qr->setSort(fromjson("{$natural: 1}")); ASSERT_OK(qr->validate()); @@ -241,7 +241,7 @@ TEST(ExpressionOptimizeTest, IsValidTextAndNaturalAscending) { TEST(ExpressionOptimizeTest, IsValidTextAndNaturalDescending) { // Filter inside QueryRequest is not used. - auto qr = stdx::make_unique<QueryRequest>(nss); + auto qr = std::make_unique<QueryRequest>(nss); qr->setSort(fromjson("{$natural: -1}")); ASSERT_OK(qr->validate()); @@ -251,7 +251,7 @@ TEST(ExpressionOptimizeTest, IsValidTextAndNaturalDescending) { TEST(ExpressionOptimizeTest, IsValidTextAndHint) { // Filter inside QueryRequest is not used. - auto qr = stdx::make_unique<QueryRequest>(nss); + auto qr = std::make_unique<QueryRequest>(nss); qr->setHint(fromjson("{a: 1}")); ASSERT_OK(qr->validate()); @@ -262,7 +262,7 @@ TEST(ExpressionOptimizeTest, IsValidTextAndHint) { // SERVER-14366 TEST(ExpressionOptimizeTest, IsValidGeoNearNaturalSort) { // Filter inside QueryRequest is not used. - auto qr = stdx::make_unique<QueryRequest>(nss); + auto qr = std::make_unique<QueryRequest>(nss); qr->setSort(fromjson("{$natural: 1}")); ASSERT_OK(qr->validate()); @@ -273,7 +273,7 @@ TEST(ExpressionOptimizeTest, IsValidGeoNearNaturalSort) { // SERVER-14366 TEST(ExpressionOptimizeTest, IsValidGeoNearNaturalHint) { // Filter inside QueryRequest is not used. - auto qr = stdx::make_unique<QueryRequest>(nss); + auto qr = std::make_unique<QueryRequest>(nss); qr->setHint(fromjson("{$natural: 1}")); ASSERT_OK(qr->validate()); @@ -331,7 +331,7 @@ TEST(ExpressionOptimizeTest, NormalizeWithInAndRegexPreservesTags) { TEST(ExpressionOptimizeTest, NormalizeWithInPreservesCollator) { CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString); BSONObj obj = fromjson("{'': 'string'}"); - auto inMatchExpression = stdx::make_unique<InMatchExpression>(""); + auto inMatchExpression = std::make_unique<InMatchExpression>(""); inMatchExpression->setCollator(&collator); std::vector<BSONElement> equalities{obj.firstElement()}; ASSERT_OK(inMatchExpression->setEqualities(std::move(equalities))); diff --git a/src/mongo/db/matcher/expression_parser.cpp b/src/mongo/db/matcher/expression_parser.cpp index e65d6885227..c92ae07f18a 100644 --- a/src/mongo/db/matcher/expression_parser.cpp +++ b/src/mongo/db/matcher/expression_parser.cpp @@ -31,6 +31,7 @@ #include "mongo/db/matcher/expression_parser.h" +#include <memory> #include <pcrecpp.h> #include "mongo/base/init.h" @@ -65,7 +66,6 @@ #include "mongo/db/matcher/schema/json_schema_parser.h" #include "mongo/db/namespace_string.h" #include "mongo/db/query/query_knobs_gen.h" -#include "mongo/stdx/memory.h" #include "mongo/util/str.h" #include "mongo/util/string_map.h" @@ -139,7 +139,7 @@ StatusWithMatchExpression parseRegexElement(StringData name, BSONElement e) { if (e.type() != BSONType::RegEx) return {Status(ErrorCodes::BadValue, "not a regex")}; - return {stdx::make_unique<RegexMatchExpression>(name, e.regex(), e.regexFlags())}; + return {std::make_unique<RegexMatchExpression>(name, e.regex(), e.regexFlags())}; } StatusWithMatchExpression parseComparison( @@ -242,7 +242,7 @@ StatusWithMatchExpression parse(const BSONObj& obj, const ExtensionsCallback* extensionsCallback, MatchExpressionParser::AllowedFeatureSet allowedFeatures, DocumentParseLevel currentLevel) { - auto root = stdx::make_unique<AndMatchExpression>(); + auto root = std::make_unique<AndMatchExpression>(); const DocumentParseLevel nextLevel = (currentLevel == DocumentParseLevel::kPredicateTopLevel) ? DocumentParseLevel::kUserDocumentTopLevel @@ -300,7 +300,7 @@ StatusWithMatchExpression parse(const BSONObj& obj, auto eq = parseComparison(e.fieldNameStringData(), - stdx::make_unique<EqualityMatchExpression>(e.fieldNameStringData(), e), + std::make_unique<EqualityMatchExpression>(e.fieldNameStringData(), e), e, expCtx, allowedFeatures); @@ -365,7 +365,7 @@ StatusWithMatchExpression parseDBRef(StringData name, const ExtensionsCallback* extensionsCallback, MatchExpressionParser::AllowedFeatureSet allowedFeatures, DocumentParseLevel currentLevel) { - auto eq = stdx::make_unique<EqualityMatchExpression>(elem.fieldName(), elem); + auto eq = std::make_unique<EqualityMatchExpression>(elem.fieldName(), elem); // 'id' is collation-aware. 'ref' and 'db' are compared using binary comparison. eq->setCollator("id"_sd == name ? expCtx->getCollator() : nullptr); @@ -410,7 +410,7 @@ StatusWithMatchExpression parseAlwaysBoolean( str::stream() << T::kName << " must be an integer value of 1")}; } - return {stdx::make_unique<T>()}; + return {std::make_unique<T>()}; } StatusWithMatchExpression parseExpr(StringData name, @@ -428,7 +428,7 @@ StatusWithMatchExpression parseExpr(StringData name, return {Status(ErrorCodes::QueryFeatureNotAllowed, "$expr is not allowed in this context")}; } - return {stdx::make_unique<ExprMatchExpression>(std::move(elem), expCtx)}; + return {std::make_unique<ExprMatchExpression>(std::move(elem), expCtx)}; } StatusWithMatchExpression parseMOD(StringData name, BSONElement e) { @@ -452,7 +452,7 @@ StatusWithMatchExpression parseMOD(StringData name, BSONElement e) { if (i.more()) return {Status(ErrorCodes::BadValue, "malformed mod, too many elements")}; - return {stdx::make_unique<ModMatchExpression>(name, d.numberInt(), r.numberInt())}; + return {std::make_unique<ModMatchExpression>(name, d.numberInt(), r.numberInt())}; } StatusWithMatchExpression parseRegexDocument(StringData name, const BSONObj& doc) { @@ -500,7 +500,7 @@ StatusWithMatchExpression parseRegexDocument(StringData name, const BSONObj& doc } } - return {stdx::make_unique<RegexMatchExpression>(name, regex, regexOptions)}; + return {std::make_unique<RegexMatchExpression>(name, regex, regexOptions)}; } Status parseInExpression(InMatchExpression* inExpression, @@ -515,7 +515,7 @@ Status parseInExpression(InMatchExpression* inExpression, } if (e.type() == BSONType::RegEx) { - auto status = inExpression->addRegex(stdx::make_unique<RegexMatchExpression>(""_sd, e)); + auto status = inExpression->addRegex(std::make_unique<RegexMatchExpression>(""_sd, e)); if (!status.isOK()) { return status; } @@ -538,7 +538,7 @@ StatusWithMatchExpression parseType(StringData name, BSONElement elt) { str::stream() << name << " must match at least one type")}; } - return {stdx::make_unique<T>(name, std::move(typeSet.getValue()))}; + return {std::make_unique<T>(name, std::move(typeSet.getValue()))}; } /** @@ -621,19 +621,19 @@ StatusWithMatchExpression parseBitTest(StringData name, BSONElement e) { if (!bitPositions.isOK()) { return bitPositions.getStatus(); } - bitTestMatchExpression = stdx::make_unique<T>(name, std::move(bitPositions.getValue())); + bitTestMatchExpression = std::make_unique<T>(name, std::move(bitPositions.getValue())); } else if (e.isNumber()) { // Integer bitmask provided as value. auto bitMask = e.parseIntegerElementToNonNegativeLong(); if (!bitMask.isOK()) { return bitMask.getStatus(); } - bitTestMatchExpression = stdx::make_unique<T>(name, bitMask.getValue()); + bitTestMatchExpression = std::make_unique<T>(name, bitMask.getValue()); } else if (e.type() == BSONType::BinData) { // Binary bitmask provided as value. int eBinaryLen; auto eBinary = e.binData(eBinaryLen); - bitTestMatchExpression = stdx::make_unique<T>(name, eBinary, eBinaryLen); + bitTestMatchExpression = std::make_unique<T>(name, eBinary, eBinaryLen); } else { return Status( ErrorCodes::BadValue, @@ -672,7 +672,7 @@ StatusWithMatchExpression parseInternalSchemaFmod(StringData name, BSONElement e return {ErrorCodes::BadValue, str::stream() << path << " has too many elements"}; } - return {stdx::make_unique<InternalSchemaFmodMatchExpression>( + return {std::make_unique<InternalSchemaFmodMatchExpression>( name, d.numberDecimal(), r.numberDecimal())}; } @@ -696,7 +696,7 @@ StatusWithMatchExpression parseInternalSchemaRootDocEq( << elem.type())}; } auto rootDocEq = - stdx::make_unique<InternalSchemaRootDocEqMatchExpression>(elem.embeddedObject()); + std::make_unique<InternalSchemaRootDocEqMatchExpression>(elem.embeddedObject()); return {std::move(rootDocEq)}; } @@ -712,7 +712,7 @@ StatusWithMatchExpression parseInternalSchemaSingleIntegerArgument(StringData na return parsedInt.getStatus(); } - return {stdx::make_unique<T>(name, parsedInt.getValue())}; + return {std::make_unique<T>(name, parsedInt.getValue())}; } /** @@ -731,7 +731,7 @@ StatusWithMatchExpression parseTopLevelInternalSchemaSingleIntegerArgument( if (!parsedInt.isOK()) { return parsedInt.getStatus(); } - return {stdx::make_unique<T>(parsedInt.getValue())}; + return {std::make_unique<T>(parsedInt.getValue())}; } /** @@ -969,7 +969,7 @@ StatusWithMatchExpression parseInternalSchemaAllowedProperties( return properties.getStatus(); } - return {stdx::make_unique<InternalSchemaAllowedPropertiesMatchExpression>( + return {std::make_unique<InternalSchemaAllowedPropertiesMatchExpression>( std::move(properties.getValue()), namePlaceholder.getValue(), std::move(patternProperties.getValue()), @@ -1024,7 +1024,7 @@ StatusWithMatchExpression parseInternalSchemaMatchArrayIndex( return expressionWithPlaceholder.getStatus(); } - return {stdx::make_unique<InternalSchemaMatchArrayIndexMatchExpression>( + return {std::make_unique<InternalSchemaMatchArrayIndexMatchExpression>( path, index.getValue(), std::move(expressionWithPlaceholder.getValue()))}; } @@ -1033,12 +1033,12 @@ StatusWithMatchExpression parseGeo(StringData name, const BSONObj& section, MatchExpressionParser::AllowedFeatureSet allowedFeatures) { if (PathAcceptingKeyword::WITHIN == type || PathAcceptingKeyword::GEO_INTERSECTS == type) { - auto gq = stdx::make_unique<GeoExpression>(name.toString()); + auto gq = std::make_unique<GeoExpression>(name.toString()); auto parseStatus = gq->parseFrom(section); if (!parseStatus.isOK()) { return parseStatus; } - return {stdx::make_unique<GeoMatchExpression>(name, gq.release(), section)}; + return {std::make_unique<GeoMatchExpression>(name, gq.release(), section)}; } else { invariant(PathAcceptingKeyword::GEO_NEAR == type); @@ -1047,12 +1047,12 @@ StatusWithMatchExpression parseGeo(StringData name, "$geoNear, $near, and $nearSphere are not allowed in this context")}; } - auto nq = stdx::make_unique<GeoNearExpression>(name.toString()); + auto nq = std::make_unique<GeoNearExpression>(name.toString()); auto status = nq->parseFrom(section); if (!status.isOK()) { return status; } - return {stdx::make_unique<GeoNearMatchExpression>(name, nq.release(), section)}; + return {std::make_unique<GeoNearMatchExpression>(name, nq.release(), section)}; } } @@ -1068,7 +1068,7 @@ StatusWithMatchExpression parseTreeTopLevel( return {Status(ErrorCodes::BadValue, str::stream() << T::kName << " must be an array")}; } - auto temp = stdx::make_unique<T>(); + auto temp = std::make_unique<T>(); auto arr = elem.Obj(); if (arr.isEmpty()) { @@ -1129,7 +1129,7 @@ StatusWithMatchExpression parseElemMatch(StringData name, if (!s.isOK()) return s; - auto temp = stdx::make_unique<ElemMatchValueMatchExpression>(name); + auto temp = std::make_unique<ElemMatchValueMatchExpression>(name); for (size_t i = 0; i < theAnd.numChildren(); i++) { temp->add(theAnd.getChild(i)); @@ -1157,7 +1157,7 @@ StatusWithMatchExpression parseElemMatch(StringData name, return {Status(ErrorCodes::BadValue, "$elemMatch cannot contain $where expression")}; } - return {stdx::make_unique<ElemMatchObjectMatchExpression>(name, sub.release())}; + return {std::make_unique<ElemMatchObjectMatchExpression>(name, sub.release())}; } StatusWithMatchExpression parseAll(StringData name, @@ -1169,7 +1169,7 @@ StatusWithMatchExpression parseAll(StringData name, return {Status(ErrorCodes::BadValue, "$all needs an array")}; auto arr = e.Obj(); - auto myAnd = stdx::make_unique<AndMatchExpression>(); + auto myAnd = std::make_unique<AndMatchExpression>(); BSONObjIterator i(arr); if (arr.firstElement().type() == BSONType::Object && @@ -1207,20 +1207,20 @@ StatusWithMatchExpression parseAll(StringData name, auto e = i.next(); if (e.type() == BSONType::RegEx) { - auto expr = stdx::make_unique<RegexMatchExpression>(name, e); + auto expr = std::make_unique<RegexMatchExpression>(name, e); myAnd->add(expr.release()); } else if (e.type() == BSONType::Object && MatchExpressionParser::parsePathAcceptingKeyword(e.Obj().firstElement())) { return {Status(ErrorCodes::BadValue, "no $ expressions in $all")}; } else { - auto expr = stdx::make_unique<EqualityMatchExpression>(name, e); + auto expr = std::make_unique<EqualityMatchExpression>(name, e); expr->setCollator(expCtx->getCollator()); myAnd->add(expr.release()); } } if (myAnd->numChildren() == 0) { - return {stdx::make_unique<AlwaysFalseMatchExpression>()}; + return {std::make_unique<AlwaysFalseMatchExpression>()}; } return {std::move(myAnd)}; @@ -1274,7 +1274,7 @@ StatusWithMatchExpression parseInternalSchemaFixedArityArgument( ++position; } - return {stdx::make_unique<T>(std::move(expressions))}; + return {std::make_unique<T>(std::move(expressions))}; } StatusWithMatchExpression parseNot(StringData name, @@ -1288,7 +1288,7 @@ StatusWithMatchExpression parseNot(StringData name, if (!regex.isOK()) { return regex; } - return {stdx::make_unique<NotMatchExpression>(regex.getValue().release())}; + return {std::make_unique<NotMatchExpression>(regex.getValue().release())}; } if (elem.type() != BSONType::Object) { @@ -1300,14 +1300,14 @@ StatusWithMatchExpression parseNot(StringData name, return {ErrorCodes::BadValue, "$not cannot be empty"}; } - auto theAnd = stdx::make_unique<AndMatchExpression>(); + auto theAnd = std::make_unique<AndMatchExpression>(); auto parseStatus = parseSub( name, notObject, theAnd.get(), expCtx, extensionsCallback, allowedFeatures, currentLevel); if (!parseStatus.isOK()) { return parseStatus; } - return {stdx::make_unique<NotMatchExpression>(theAnd.release())}; + return {std::make_unique<NotMatchExpression>(theAnd.release())}; } StatusWithMatchExpression parseInternalSchemaBinDataSubType(StringData name, BSONElement e) { @@ -1333,7 +1333,7 @@ StatusWithMatchExpression parseInternalSchemaBinDataSubType(StringData name, BSO << valueAsInt.getValue()); } - return {stdx::make_unique<InternalSchemaBinDataSubTypeExpression>( + return {std::make_unique<InternalSchemaBinDataSubTypeExpression>( name, static_cast<BinDataType>(valueAsInt.getValue()))}; } @@ -1354,7 +1354,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, if ("$eq"_sd == e.fieldNameStringData()) { return parseComparison( - name, stdx::make_unique<EqualityMatchExpression>(name, e), e, expCtx, allowedFeatures); + name, std::make_unique<EqualityMatchExpression>(name, e), e, expCtx, allowedFeatures); } if ("$not"_sd == e.fieldNameStringData()) { @@ -1375,16 +1375,16 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, switch (*parseExpMatchType) { case PathAcceptingKeyword::LESS_THAN: return parseComparison( - name, stdx::make_unique<LTMatchExpression>(name, e), e, expCtx, allowedFeatures); + name, std::make_unique<LTMatchExpression>(name, e), e, expCtx, allowedFeatures); case PathAcceptingKeyword::LESS_THAN_OR_EQUAL: return parseComparison( - name, stdx::make_unique<LTEMatchExpression>(name, e), e, expCtx, allowedFeatures); + name, std::make_unique<LTEMatchExpression>(name, e), e, expCtx, allowedFeatures); case PathAcceptingKeyword::GREATER_THAN: return parseComparison( - name, stdx::make_unique<GTMatchExpression>(name, e), e, expCtx, allowedFeatures); + name, std::make_unique<GTMatchExpression>(name, e), e, expCtx, allowedFeatures); case PathAcceptingKeyword::GREATER_THAN_OR_EQUAL: return parseComparison( - name, stdx::make_unique<GTEMatchExpression>(name, e), e, expCtx, allowedFeatures); + name, std::make_unique<GTEMatchExpression>(name, e), e, expCtx, allowedFeatures); case PathAcceptingKeyword::NOT_EQUAL: { if (BSONType::RegEx == e.type()) { // Just because $ne can be rewritten as the negation of an equality does not mean @@ -1393,15 +1393,15 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, } StatusWithMatchExpression s = parseComparison(name, - stdx::make_unique<EqualityMatchExpression>(name, e), + std::make_unique<EqualityMatchExpression>(name, e), e, expCtx, allowedFeatures); - return {stdx::make_unique<NotMatchExpression>(s.getValue().release())}; + return {std::make_unique<NotMatchExpression>(s.getValue().release())}; } case PathAcceptingKeyword::EQUALITY: return parseComparison(name, - stdx::make_unique<EqualityMatchExpression>(name, e), + std::make_unique<EqualityMatchExpression>(name, e), e, expCtx, allowedFeatures); @@ -1410,7 +1410,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, if (e.type() != BSONType::Array) { return {Status(ErrorCodes::BadValue, "$in needs an array")}; } - auto temp = stdx::make_unique<InMatchExpression>(name); + auto temp = std::make_unique<InMatchExpression>(name); auto parseStatus = parseInExpression(temp.get(), e.Obj(), expCtx); if (!parseStatus.isOK()) { return parseStatus; @@ -1422,12 +1422,12 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, if (e.type() != Array) { return {Status(ErrorCodes::BadValue, "$nin needs an array")}; } - auto temp = stdx::make_unique<InMatchExpression>(name); + auto temp = std::make_unique<InMatchExpression>(name); auto parseStatus = parseInExpression(temp.get(), e.Obj(), expCtx); if (!parseStatus.isOK()) { return parseStatus; } - return {stdx::make_unique<NotMatchExpression>(temp.release())}; + return {std::make_unique<NotMatchExpression>(temp.release())}; } case PathAcceptingKeyword::SIZE: { @@ -1454,7 +1454,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, if (size < 0) { return {Status(ErrorCodes::BadValue, "$size may not be negative")}; } - return {stdx::make_unique<SizeMatchExpression>(name, size)}; + return {std::make_unique<SizeMatchExpression>(name, size)}; } case PathAcceptingKeyword::EXISTS: { @@ -1462,12 +1462,12 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, return {Status(ErrorCodes::BadValue, "$exists can't be eoo")}; } - auto existsExpr = stdx::make_unique<ExistsMatchExpression>(name); + auto existsExpr = std::make_unique<ExistsMatchExpression>(name); if (e.trueValue()) { return {std::move(existsExpr)}; } - return {stdx::make_unique<NotMatchExpression>(existsExpr.release())}; + return {std::make_unique<NotMatchExpression>(existsExpr.release())}; } case PathAcceptingKeyword::TYPE: @@ -1515,7 +1515,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, << typeName(e.type()))}; } - auto exprEqExpr = stdx::make_unique<InternalExprEqMatchExpression>(name, e); + auto exprEqExpr = std::make_unique<InternalExprEqMatchExpression>(name, e); exprEqExpr->setCollator(expCtx->getCollator()); return {std::move(exprEqExpr)}; } @@ -1565,7 +1565,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, return parsedSubObjExpr; } - return {stdx::make_unique<InternalSchemaObjectMatchExpression>( + return {std::make_unique<InternalSchemaObjectMatchExpression>( name, std::move(parsedSubObjExpr.getValue()))}; } @@ -1575,7 +1575,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, str::stream() << name << " must be a boolean of value true"}; } - return {stdx::make_unique<InternalSchemaUniqueItemsMatchExpression>(name)}; + return {std::make_unique<InternalSchemaUniqueItemsMatchExpression>(name)}; } case PathAcceptingKeyword::INTERNAL_SCHEMA_MIN_LENGTH: { @@ -1653,7 +1653,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, if (!exprWithPlaceholder.isOK()) { return exprWithPlaceholder.getStatus(); } - return {stdx::make_unique<InternalSchemaAllElemMatchFromIndexMatchExpression>( + return {std::make_unique<InternalSchemaAllElemMatchFromIndexMatchExpression>( name, parsedIndex.getValue(), std::move(exprWithPlaceholder.getValue()))}; } @@ -1662,7 +1662,7 @@ StatusWithMatchExpression parseSubField(const BSONObj& context, } case PathAcceptingKeyword::INTERNAL_SCHEMA_EQ: { - return {stdx::make_unique<InternalSchemaEqMatchExpression>(name, e)}; + return {std::make_unique<InternalSchemaEqMatchExpression>(name, e)}; } case PathAcceptingKeyword::INTERNAL_SCHEMA_BIN_DATA_ENCRYPTED_TYPE: { @@ -1757,7 +1757,7 @@ std::unique_ptr<StringMap< pathlessOperatorMap; MONGO_INITIALIZER(PathlessOperatorMap)(InitializerContext* context) { - pathlessOperatorMap = stdx::make_unique<StringMap< + pathlessOperatorMap = std::make_unique<StringMap< std::function<StatusWithMatchExpression(StringData, BSONElement, const boost::intrusive_ptr<ExpressionContext>&, @@ -1804,7 +1804,7 @@ std::unique_ptr<StringMap<PathAcceptingKeyword>> queryOperatorMap; MONGO_INITIALIZER(MatchExpressionParser)(InitializerContext* context) { queryOperatorMap = - stdx::make_unique<StringMap<PathAcceptingKeyword>>(StringMap<PathAcceptingKeyword>{ + std::make_unique<StringMap<PathAcceptingKeyword>>(StringMap<PathAcceptingKeyword>{ // TODO: SERVER-19565 Add $eq after auditing callers. {"_internalExprEq", PathAcceptingKeyword::INTERNAL_EXPR_EQ}, {"_internalSchemaAllElemMatchFromIndex", diff --git a/src/mongo/db/matcher/expression_text.cpp b/src/mongo/db/matcher/expression_text.cpp index 8fdcd65befc..49fb5971739 100644 --- a/src/mongo/db/matcher/expression_text.cpp +++ b/src/mongo/db/matcher/expression_text.cpp @@ -31,13 +31,14 @@ #include "mongo/db/matcher/expression_text.h" +#include <memory> + #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/index_catalog.h" #include "mongo/db/db_raii.h" #include "mongo/db/fts/fts_language.h" #include "mongo/db/fts/fts_spec.h" #include "mongo/db/index/fts_access_method.h" -#include "mongo/stdx/memory.h" namespace mongo { @@ -101,7 +102,7 @@ TextMatchExpression::TextMatchExpression(OperationContext* opCtx, } std::unique_ptr<MatchExpression> TextMatchExpression::shallowClone() const { - auto expr = stdx::make_unique<TextMatchExpression>(_ftsQuery); + auto expr = std::make_unique<TextMatchExpression>(_ftsQuery); // We use the query-only constructor here directly rather than using the full constructor, to // avoid needing to examine // the index catalog. diff --git a/src/mongo/db/matcher/expression_text_noop.cpp b/src/mongo/db/matcher/expression_text_noop.cpp index a2d45802823..e0dfdbc551e 100644 --- a/src/mongo/db/matcher/expression_text_noop.cpp +++ b/src/mongo/db/matcher/expression_text_noop.cpp @@ -31,7 +31,8 @@ #include "mongo/db/matcher/expression_text_noop.h" -#include "mongo/stdx/memory.h" +#include <memory> + namespace mongo { @@ -51,7 +52,7 @@ std::unique_ptr<MatchExpression> TextNoOpMatchExpression::shallowClone() const { params.caseSensitive = _ftsQuery.getCaseSensitive(); params.diacriticSensitive = _ftsQuery.getDiacriticSensitive(); - auto expr = stdx::make_unique<TextNoOpMatchExpression>(std::move(params)); + auto expr = std::make_unique<TextNoOpMatchExpression>(std::move(params)); if (getTag()) { expr->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/expression_tree.cpp b/src/mongo/db/matcher/expression_tree.cpp index 2cbdb1886f0..b56e96f4924 100644 --- a/src/mongo/db/matcher/expression_tree.cpp +++ b/src/mongo/db/matcher/expression_tree.cpp @@ -137,7 +137,7 @@ MatchExpression::ExpressionOptimizerFunc ListOfMatchExpression::getOptimizer() c // empty AND as the same thing. The planner can create inferior plans for $alwaysTrue which // it would not produce for an AND with no children. if (children.empty() && matchType == MatchExpression::OR) { - return stdx::make_unique<AlwaysFalseMatchExpression>(); + return std::make_unique<AlwaysFalseMatchExpression>(); } if (children.size() == 1) { @@ -149,7 +149,7 @@ MatchExpression::ExpressionOptimizerFunc ListOfMatchExpression::getOptimizer() c return std::unique_ptr<MatchExpression>(simplifiedExpression); } else if (matchType == NOR) { // Simplify NOR of exactly one operand to NOT of that operand. - auto simplifiedExpression = stdx::make_unique<NotMatchExpression>(children.front()); + auto simplifiedExpression = std::make_unique<NotMatchExpression>(children.front()); children.clear(); return std::move(simplifiedExpression); } @@ -160,13 +160,13 @@ MatchExpression::ExpressionOptimizerFunc ListOfMatchExpression::getOptimizer() c // An AND containing an expression that always evaluates to false can be // optimized to a single $alwaysFalse expression. if (childExpression->isTriviallyFalse() && matchType == MatchExpression::AND) { - return stdx::make_unique<AlwaysFalseMatchExpression>(); + return std::make_unique<AlwaysFalseMatchExpression>(); } // Likewise, an OR containing an expression that always evaluates to true can be // optimized to a single $alwaysTrue expression. if (childExpression->isTriviallyTrue() && matchType == MatchExpression::OR) { - return stdx::make_unique<AlwaysTrueMatchExpression>(); + return std::make_unique<AlwaysTrueMatchExpression>(); } } } diff --git a/src/mongo/db/matcher/expression_tree.h b/src/mongo/db/matcher/expression_tree.h index b89efb19461..afecd935d79 100644 --- a/src/mongo/db/matcher/expression_tree.h +++ b/src/mongo/db/matcher/expression_tree.h @@ -115,7 +115,7 @@ public: bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final; virtual std::unique_ptr<MatchExpression> shallowClone() const { - std::unique_ptr<AndMatchExpression> self = stdx::make_unique<AndMatchExpression>(); + std::unique_ptr<AndMatchExpression> self = std::make_unique<AndMatchExpression>(); for (size_t i = 0; i < numChildren(); ++i) { self->add(getChild(i)->shallowClone().release()); } @@ -144,7 +144,7 @@ public: bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final; virtual std::unique_ptr<MatchExpression> shallowClone() const { - std::unique_ptr<OrMatchExpression> self = stdx::make_unique<OrMatchExpression>(); + std::unique_ptr<OrMatchExpression> self = std::make_unique<OrMatchExpression>(); for (size_t i = 0; i < numChildren(); ++i) { self->add(getChild(i)->shallowClone().release()); } @@ -173,7 +173,7 @@ public: bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final; virtual std::unique_ptr<MatchExpression> shallowClone() const { - std::unique_ptr<NorMatchExpression> self = stdx::make_unique<NorMatchExpression>(); + std::unique_ptr<NorMatchExpression> self = std::make_unique<NorMatchExpression>(); for (size_t i = 0; i < numChildren(); ++i) { self->add(getChild(i)->shallowClone().release()); } @@ -194,7 +194,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const { std::unique_ptr<NotMatchExpression> self = - stdx::make_unique<NotMatchExpression>(_exp->shallowClone().release()); + std::make_unique<NotMatchExpression>(_exp->shallowClone().release()); if (getTag()) { self->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/expression_type.h b/src/mongo/db/matcher/expression_type.h index 3f210103c75..aa2860b8fd2 100644 --- a/src/mongo/db/matcher/expression_type.h +++ b/src/mongo/db/matcher/expression_type.h @@ -67,7 +67,7 @@ public: virtual StringData name() const = 0; std::unique_ptr<MatchExpression> shallowClone() const final { - auto expr = stdx::make_unique<T>(path(), _typeSet); + auto expr = std::make_unique<T>(path(), _typeSet); if (getTag()) { expr->setTag(getTag()->clone()); } @@ -189,7 +189,7 @@ public: std::unique_ptr<MatchExpression> shallowClone() const final { auto expr = - stdx::make_unique<InternalSchemaBinDataSubTypeExpression>(path(), _binDataSubType); + std::make_unique<InternalSchemaBinDataSubTypeExpression>(path(), _binDataSubType); if (getTag()) { expr->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/expression_where.cpp b/src/mongo/db/matcher/expression_where.cpp index 997b673c6cc..ff2069fe9ed 100644 --- a/src/mongo/db/matcher/expression_where.cpp +++ b/src/mongo/db/matcher/expression_where.cpp @@ -31,6 +31,8 @@ #include "mongo/db/matcher/expression_where.h" +#include <memory> + #include "mongo/base/init.h" #include "mongo/db/auth/authorization_session.h" #include "mongo/db/client.h" @@ -39,7 +41,6 @@ #include "mongo/db/matcher/expression_parser.h" #include "mongo/db/namespace_string.h" #include "mongo/scripting/engine.h" -#include "mongo/stdx/memory.h" #include "mongo/util/scopeguard.h" @@ -48,7 +49,6 @@ namespace mongo { using std::unique_ptr; using std::string; using std::stringstream; -using stdx::make_unique; WhereMatchExpression::WhereMatchExpression(OperationContext* opCtx, WhereParams params, @@ -104,7 +104,7 @@ unique_ptr<MatchExpression> WhereMatchExpression::shallowClone() const { params.code = getCode(); params.scope = getScope(); unique_ptr<WhereMatchExpression> e = - make_unique<WhereMatchExpression>(_opCtx, std::move(params), _dbName); + std::make_unique<WhereMatchExpression>(_opCtx, std::move(params), _dbName); if (getTag()) { e->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/expression_where_noop.cpp b/src/mongo/db/matcher/expression_where_noop.cpp index bd1469036e4..8372b0b49fe 100644 --- a/src/mongo/db/matcher/expression_where_noop.cpp +++ b/src/mongo/db/matcher/expression_where_noop.cpp @@ -31,7 +31,8 @@ #include "mongo/db/matcher/expression_where_noop.h" -#include "mongo/stdx/memory.h" +#include <memory> + namespace mongo { @@ -47,7 +48,7 @@ std::unique_ptr<MatchExpression> WhereNoOpMatchExpression::shallowClone() const params.code = getCode(); params.scope = getScope(); std::unique_ptr<WhereNoOpMatchExpression> e = - stdx::make_unique<WhereNoOpMatchExpression>(std::move(params)); + std::make_unique<WhereNoOpMatchExpression>(std::move(params)); if (getTag()) { e->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/expression_with_placeholder.cpp b/src/mongo/db/matcher/expression_with_placeholder.cpp index b0e1f1d118d..408232d9f3f 100644 --- a/src/mongo/db/matcher/expression_with_placeholder.cpp +++ b/src/mongo/db/matcher/expression_with_placeholder.cpp @@ -111,7 +111,7 @@ StatusWith<std::unique_ptr<ExpressionWithPlaceholder>> ExpressionWithPlaceholder } auto exprWithPlaceholder = - stdx::make_unique<ExpressionWithPlaceholder>(std::move(placeholder), std::move(filter)); + std::make_unique<ExpressionWithPlaceholder>(std::move(placeholder), std::move(filter)); return {std::move(exprWithPlaceholder)}; } diff --git a/src/mongo/db/matcher/expression_with_placeholder.h b/src/mongo/db/matcher/expression_with_placeholder.h index dd9150b4b0c..b61e3c6ab4e 100644 --- a/src/mongo/db/matcher/expression_with_placeholder.h +++ b/src/mongo/db/matcher/expression_with_placeholder.h @@ -92,7 +92,7 @@ public: } std::unique_ptr<ExpressionWithPlaceholder> shallowClone() const { - return stdx::make_unique<ExpressionWithPlaceholder>(_placeholder, _filter->shallowClone()); + return std::make_unique<ExpressionWithPlaceholder>(_placeholder, _filter->shallowClone()); } /* diff --git a/src/mongo/db/matcher/extensions_callback_noop.cpp b/src/mongo/db/matcher/extensions_callback_noop.cpp index b4b07efdae2..c4ce0f8f9b2 100644 --- a/src/mongo/db/matcher/extensions_callback_noop.cpp +++ b/src/mongo/db/matcher/extensions_callback_noop.cpp @@ -42,7 +42,7 @@ StatusWithMatchExpression ExtensionsCallbackNoop::parseText(BSONElement text) co return textParams.getStatus(); } - auto expr = stdx::make_unique<TextNoOpMatchExpression>(std::move(textParams.getValue())); + auto expr = std::make_unique<TextNoOpMatchExpression>(std::move(textParams.getValue())); return {std::move(expr)}; } @@ -53,7 +53,7 @@ StatusWithMatchExpression ExtensionsCallbackNoop::parseWhere(BSONElement where) return whereParams.getStatus(); } - return {stdx::make_unique<WhereNoOpMatchExpression>(std::move(whereParams.getValue()))}; + return {std::make_unique<WhereNoOpMatchExpression>(std::move(whereParams.getValue()))}; } } // namespace mongo diff --git a/src/mongo/db/matcher/extensions_callback_real.cpp b/src/mongo/db/matcher/extensions_callback_real.cpp index 97bd30a1089..313602e4752 100644 --- a/src/mongo/db/matcher/extensions_callback_real.cpp +++ b/src/mongo/db/matcher/extensions_callback_real.cpp @@ -47,7 +47,7 @@ StatusWithMatchExpression ExtensionsCallbackReal::parseText(BSONElement text) co } auto exp = - stdx::make_unique<TextMatchExpression>(_opCtx, *_nss, std::move(textParams.getValue())); + std::make_unique<TextMatchExpression>(_opCtx, *_nss, std::move(textParams.getValue())); return {std::move(exp)}; } @@ -58,7 +58,7 @@ StatusWithMatchExpression ExtensionsCallbackReal::parseWhere(BSONElement where) return whereParams.getStatus(); } - auto exp = stdx::make_unique<WhereMatchExpression>( + auto exp = std::make_unique<WhereMatchExpression>( _opCtx, std::move(whereParams.getValue()), _nss->db()); return {std::move(exp)}; } diff --git a/src/mongo/db/matcher/rewrite_expr.cpp b/src/mongo/db/matcher/rewrite_expr.cpp index c03ba61659f..01e5a6e51c5 100644 --- a/src/mongo/db/matcher/rewrite_expr.cpp +++ b/src/mongo/db/matcher/rewrite_expr.cpp @@ -76,7 +76,7 @@ std::unique_ptr<MatchExpression> RewriteExpr::_rewriteExpression( std::unique_ptr<MatchExpression> RewriteExpr::_rewriteAndExpression( const boost::intrusive_ptr<ExpressionAnd>& currExprNode) { - auto andMatch = stdx::make_unique<AndMatchExpression>(); + auto andMatch = std::make_unique<AndMatchExpression>(); for (auto&& child : currExprNode->getOperandList()) { if (auto childMatch = _rewriteExpression(child)) { @@ -94,7 +94,7 @@ std::unique_ptr<MatchExpression> RewriteExpr::_rewriteAndExpression( std::unique_ptr<MatchExpression> RewriteExpr::_rewriteOrExpression( const boost::intrusive_ptr<ExpressionOr>& currExprNode) { - auto orMatch = stdx::make_unique<OrMatchExpression>(); + auto orMatch = std::make_unique<OrMatchExpression>(); for (auto&& child : currExprNode->getOperandList()) { if (auto childExpr = _rewriteExpression(child)) { orMatch->add(childExpr.release()); @@ -151,7 +151,7 @@ std::unique_ptr<MatchExpression> RewriteExpr::_buildComparisonMatchExpression( invariant(comparisonOp == ExpressionCompare::EQ); auto eqMatchExpr = - stdx::make_unique<InternalExprEqMatchExpression>(fieldAndValue.fieldName(), fieldAndValue); + std::make_unique<InternalExprEqMatchExpression>(fieldAndValue.fieldName(), fieldAndValue); eqMatchExpr->setCollator(_collator); return std::move(eqMatchExpr); diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp index 7c2d67425b0..818054c4af1 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp @@ -47,7 +47,7 @@ InternalSchemaAllElemMatchFromIndexMatchExpression:: std::unique_ptr<MatchExpression> InternalSchemaAllElemMatchFromIndexMatchExpression::shallowClone() const { - auto clone = stdx::make_unique<InternalSchemaAllElemMatchFromIndexMatchExpression>( + auto clone = std::make_unique<InternalSchemaAllElemMatchFromIndexMatchExpression>( path(), _index, _expression->shallowClone()); if (getTag()) { clone->setTag(getTag()->clone()); diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp index ee985195455..e110980de91 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp @@ -162,7 +162,7 @@ std::unique_ptr<MatchExpression> InternalSchemaAllowedPropertiesMatchExpression: constraint.second->shallowClone()); } - auto clone = stdx::make_unique<InternalSchemaAllowedPropertiesMatchExpression>( + auto clone = std::make_unique<InternalSchemaAllowedPropertiesMatchExpression>( _properties, _namePlaceholder, std::move(clonedPatternProperties), diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h index aff80f95802..e45acba010b 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h @@ -29,13 +29,13 @@ #pragma once +#include <memory> #include <pcrecpp.h> #include <utility> #include <vector> #include "mongo/db/matcher/expression.h" #include "mongo/db/matcher/expression_with_placeholder.h" -#include "mongo/stdx/memory.h" namespace mongo { @@ -94,7 +94,7 @@ public: */ struct Pattern { explicit Pattern(StringData pattern) - : rawRegex(pattern), regex(stdx::make_unique<pcrecpp::RE>(pattern.toString())) {} + : rawRegex(pattern), regex(std::make_unique<pcrecpp::RE>(pattern.toString())) {} StringData rawRegex; std::unique_ptr<pcrecpp::RE> regex; diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_cond_test.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_cond_test.cpp index a9ad241694d..5d8e82b3d7c 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_cond_test.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_cond_test.cpp @@ -56,7 +56,7 @@ std::unique_ptr<InternalSchemaCondMatchExpression> createCondMatchExpression(BSO std::move(thenBranchExpr.getValue()), std::move(elseBranchExpr.getValue())}}; - auto cond = stdx::make_unique<InternalSchemaCondMatchExpression>(std::move(expressions)); + auto cond = std::make_unique<InternalSchemaCondMatchExpression>(std::move(expressions)); return cond; } diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp index c28eb69e4fb..d8a5f27f789 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp @@ -83,7 +83,7 @@ bool InternalSchemaEqMatchExpression::equivalent(const MatchExpression* other) c } std::unique_ptr<MatchExpression> InternalSchemaEqMatchExpression::shallowClone() const { - auto clone = stdx::make_unique<InternalSchemaEqMatchExpression>(path(), _rhsElem); + auto clone = std::make_unique<InternalSchemaEqMatchExpression>(path(), _rhsElem); if (getTag()) { clone->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h b/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h index 201ec23f70e..5e99274e069 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h @@ -43,7 +43,7 @@ public: std::unique_ptr<MatchExpression> shallowClone() const final { std::unique_ptr<InternalSchemaFmodMatchExpression> m = - stdx::make_unique<InternalSchemaFmodMatchExpression>(path(), _divisor, _remainder); + std::make_unique<InternalSchemaFmodMatchExpression>(path(), _divisor, _remainder); if (getTag()) { m->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp index f4264c5d1ef..6d5d2ed2ed5 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp @@ -86,7 +86,7 @@ BSONObj InternalSchemaMatchArrayIndexMatchExpression::getSerializedRightHandSide std::unique_ptr<MatchExpression> InternalSchemaMatchArrayIndexMatchExpression::shallowClone() const { - auto clone = stdx::make_unique<InternalSchemaMatchArrayIndexMatchExpression>( + auto clone = std::make_unique<InternalSchemaMatchArrayIndexMatchExpression>( path(), _index, _expression->shallowClone()); if (getTag()) { clone->setTag(getTag()->clone()); diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h index 9a0bb8675b7..54682da09d4 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h @@ -29,9 +29,10 @@ #pragma once +#include <memory> + #include "mongo/db/matcher/expression_array.h" #include "mongo/db/matcher/expression_with_placeholder.h" -#include "mongo/stdx/memory.h" namespace mongo { diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_max_items.h b/src/mongo/db/matcher/schema/expression_internal_schema_max_items.h index 6edcde839c7..e133c67e02e 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_max_items.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_max_items.h @@ -50,7 +50,7 @@ public: std::unique_ptr<MatchExpression> shallowClone() const final { std::unique_ptr<InternalSchemaMaxItemsMatchExpression> maxItems = - stdx::make_unique<InternalSchemaMaxItemsMatchExpression>(path(), numItems()); + std::make_unique<InternalSchemaMaxItemsMatchExpression>(path(), numItems()); if (getTag()) { maxItems->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_max_length.h b/src/mongo/db/matcher/schema/expression_internal_schema_max_length.h index 69b524f18f4..342f958679b 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_max_length.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_max_length.h @@ -50,7 +50,7 @@ public: std::unique_ptr<MatchExpression> shallowClone() const final { std::unique_ptr<InternalSchemaMaxLengthMatchExpression> maxLen = - stdx::make_unique<InternalSchemaMaxLengthMatchExpression>(path(), strLen()); + std::make_unique<InternalSchemaMaxLengthMatchExpression>(path(), strLen()); if (getTag()) { maxLen->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_max_properties.h b/src/mongo/db/matcher/schema/expression_internal_schema_max_properties.h index 0aab4243248..3e5e05ea849 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_max_properties.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_max_properties.h @@ -60,7 +60,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const final { auto maxProperties = - stdx::make_unique<InternalSchemaMaxPropertiesMatchExpression>(numProperties()); + std::make_unique<InternalSchemaMaxPropertiesMatchExpression>(numProperties()); if (getTag()) { maxProperties->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_min_items.h b/src/mongo/db/matcher/schema/expression_internal_schema_min_items.h index 68f0df7dfc6..2a5978d0326 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_min_items.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_min_items.h @@ -50,7 +50,7 @@ public: std::unique_ptr<MatchExpression> shallowClone() const final { std::unique_ptr<InternalSchemaMinItemsMatchExpression> minItems = - stdx::make_unique<InternalSchemaMinItemsMatchExpression>(path(), numItems()); + std::make_unique<InternalSchemaMinItemsMatchExpression>(path(), numItems()); if (getTag()) { minItems->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_min_length.h b/src/mongo/db/matcher/schema/expression_internal_schema_min_length.h index f3128007500..0c379a61b23 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_min_length.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_min_length.h @@ -50,7 +50,7 @@ public: std::unique_ptr<MatchExpression> shallowClone() const final { std::unique_ptr<InternalSchemaMinLengthMatchExpression> minLen = - stdx::make_unique<InternalSchemaMinLengthMatchExpression>(path(), strLen()); + std::make_unique<InternalSchemaMinLengthMatchExpression>(path(), strLen()); if (getTag()) { minLen->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_min_properties.h b/src/mongo/db/matcher/schema/expression_internal_schema_min_properties.h index f05f1cef785..0e9741a281f 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_min_properties.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_min_properties.h @@ -60,7 +60,7 @@ public: virtual std::unique_ptr<MatchExpression> shallowClone() const final { auto minProperties = - stdx::make_unique<InternalSchemaMinPropertiesMatchExpression>(numProperties()); + std::make_unique<InternalSchemaMinPropertiesMatchExpression>(numProperties()); if (getTag()) { minProperties->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp index 36a921a4380..b6ca5118644 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp @@ -76,7 +76,7 @@ bool InternalSchemaObjectMatchExpression::equivalent(const MatchExpression* othe std::unique_ptr<MatchExpression> InternalSchemaObjectMatchExpression::shallowClone() const { auto clone = - stdx::make_unique<InternalSchemaObjectMatchExpression>(path(), _sub->shallowClone()); + std::make_unique<InternalSchemaObjectMatchExpression>(path(), _sub->shallowClone()); if (getTag()) { clone->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp index 1b1fc6ae29f..24ba5b22afa 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp @@ -70,7 +70,7 @@ bool InternalSchemaRootDocEqMatchExpression::equivalent(const MatchExpression* o } std::unique_ptr<MatchExpression> InternalSchemaRootDocEqMatchExpression::shallowClone() const { - auto clone = stdx::make_unique<InternalSchemaRootDocEqMatchExpression>(_rhsObj.copy()); + auto clone = std::make_unique<InternalSchemaRootDocEqMatchExpression>(_rhsObj.copy()); if (getTag()) { clone->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp index afb0a39cbe4..6d132badf27 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp +++ b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp @@ -66,7 +66,7 @@ BSONObj InternalSchemaUniqueItemsMatchExpression::getSerializedRightHandSide() c } std::unique_ptr<MatchExpression> InternalSchemaUniqueItemsMatchExpression::shallowClone() const { - auto clone = stdx::make_unique<InternalSchemaUniqueItemsMatchExpression>(path()); + auto clone = std::make_unique<InternalSchemaUniqueItemsMatchExpression>(path()); if (getTag()) { clone->setTag(getTag()->clone()); } diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_xor.h b/src/mongo/db/matcher/schema/expression_internal_schema_xor.h index b11d1641a33..9aebb07d68d 100644 --- a/src/mongo/db/matcher/schema/expression_internal_schema_xor.h +++ b/src/mongo/db/matcher/schema/expression_internal_schema_xor.h @@ -48,7 +48,7 @@ public: bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final; virtual std::unique_ptr<MatchExpression> shallowClone() const { - auto xorCopy = stdx::make_unique<InternalSchemaXorMatchExpression>(); + auto xorCopy = std::make_unique<InternalSchemaXorMatchExpression>(); for (size_t i = 0; i < numChildren(); ++i) { xorCopy->add(getChild(i)->shallowClone().release()); } diff --git a/src/mongo/db/matcher/schema/json_schema_parser.cpp b/src/mongo/db/matcher/schema/json_schema_parser.cpp index 6f0d6e6c947..cd1ac4a4e47 100644 --- a/src/mongo/db/matcher/schema/json_schema_parser.cpp +++ b/src/mongo/db/matcher/schema/json_schema_parser.cpp @@ -33,6 +33,8 @@ #include "mongo/db/matcher/schema/json_schema_parser.h" +#include <memory> + #include "mongo/bson/bsontypes.h" #include "mongo/bson/unordered_fields_bsonelement_comparator.h" #include "mongo/db/commands/feature_compatibility_version_documentation.h" @@ -58,7 +60,6 @@ #include "mongo/db/matcher/schema/expression_internal_schema_xor.h" #include "mongo/db/matcher/schema/json_pointer.h" #include "mongo/logger/log_component_settings.h" -#include "mongo/stdx/memory.h" #include "mongo/util/log.h" #include "mongo/util/string_map.h" @@ -123,7 +124,7 @@ std::unique_ptr<MatchExpression> makeRestriction(const MatcherTypeSet& restricti } else { // This restriction doesn't take any effect, since the type of the schema is different // from the type to which this retriction applies. - return stdx::make_unique<AlwaysTrueMatchExpression>(); + return std::make_unique<AlwaysTrueMatchExpression>(); } } @@ -133,11 +134,11 @@ std::unique_ptr<MatchExpression> makeRestriction(const MatcherTypeSet& restricti // // We need to do this because restriction keywords do not apply when a field is either not // present or of a different type. - auto typeExpr = stdx::make_unique<InternalSchemaTypeExpression>(path, restrictionType); + auto typeExpr = std::make_unique<InternalSchemaTypeExpression>(path, restrictionType); - auto notExpr = stdx::make_unique<NotMatchExpression>(typeExpr.release()); + auto notExpr = std::make_unique<NotMatchExpression>(typeExpr.release()); - auto orExpr = stdx::make_unique<OrMatchExpression>(); + auto orExpr = std::make_unique<OrMatchExpression>(); orExpr->add(notExpr.release()); orExpr->add(restrictionExpr.release()); @@ -162,7 +163,7 @@ StatusWith<std::unique_ptr<InternalSchemaTypeExpression>> parseType( } auto typeExpr = - stdx::make_unique<InternalSchemaTypeExpression>(path, std::move(typeSet.getValue())); + std::make_unique<InternalSchemaTypeExpression>(path, std::move(typeSet.getValue())); return {std::move(typeExpr)}; } @@ -180,14 +181,14 @@ StatusWithMatchExpression parseMaximum(StringData path, if (path.empty()) { // This restriction has no effect in a top-level schema, since we only store objects. - return {stdx::make_unique<AlwaysTrueMatchExpression>()}; + return {std::make_unique<AlwaysTrueMatchExpression>()}; } std::unique_ptr<ComparisonMatchExpression> expr; if (isExclusiveMaximum) { - expr = stdx::make_unique<LTMatchExpression>(path, maximum); + expr = std::make_unique<LTMatchExpression>(path, maximum); } else { - expr = stdx::make_unique<LTEMatchExpression>(path, maximum); + expr = std::make_unique<LTEMatchExpression>(path, maximum); } MatcherTypeSet restrictionType; @@ -208,14 +209,14 @@ StatusWithMatchExpression parseMinimum(StringData path, if (path.empty()) { // This restriction has no effect in a top-level schema, since we only store objects. - return {stdx::make_unique<AlwaysTrueMatchExpression>()}; + return {std::make_unique<AlwaysTrueMatchExpression>()}; } std::unique_ptr<ComparisonMatchExpression> expr; if (isExclusiveMinimum) { - expr = stdx::make_unique<GTMatchExpression>(path, minimum); + expr = std::make_unique<GTMatchExpression>(path, minimum); } else { - expr = stdx::make_unique<GTEMatchExpression>(path, minimum); + expr = std::make_unique<GTEMatchExpression>(path, minimum); } MatcherTypeSet restrictionType; @@ -237,10 +238,10 @@ StatusWithMatchExpression parseLength(StringData path, } if (path.empty()) { - return {stdx::make_unique<AlwaysTrueMatchExpression>()}; + return {std::make_unique<AlwaysTrueMatchExpression>()}; } - auto expr = stdx::make_unique<T>(path, parsedLength.getValue()); + auto expr = std::make_unique<T>(path, parsedLength.getValue()); return makeRestriction(restrictionType, path, std::move(expr), typeExpr); } @@ -255,13 +256,12 @@ StatusWithMatchExpression parsePattern(StringData path, } if (path.empty()) { - return {stdx::make_unique<AlwaysTrueMatchExpression>()}; + return {std::make_unique<AlwaysTrueMatchExpression>()}; } // JSON Schema does not allow regex flags to be specified. constexpr auto emptyFlags = ""; - auto expr = - stdx::make_unique<RegexMatchExpression>(path, pattern.valueStringData(), emptyFlags); + auto expr = std::make_unique<RegexMatchExpression>(path, pattern.valueStringData(), emptyFlags); return makeRestriction(BSONType::String, path, std::move(expr), typeExpr); } @@ -283,10 +283,10 @@ StatusWithMatchExpression parseMultipleOf(StringData path, << "' must have a positive value")}; } if (path.empty()) { - return {stdx::make_unique<AlwaysTrueMatchExpression>()}; + return {std::make_unique<AlwaysTrueMatchExpression>()}; } - auto expr = stdx::make_unique<InternalSchemaFmodMatchExpression>( + auto expr = std::make_unique<InternalSchemaFmodMatchExpression>( path, multipleOf.numberDecimal(), Decimal128(0)); MatcherTypeSet restrictionType; @@ -312,7 +312,7 @@ StatusWithMatchExpression parseLogicalKeyword(const boost::intrusive_ptr<Express << "' must be a non-empty array"}; } - std::unique_ptr<T> listOfExpr = stdx::make_unique<T>(); + std::unique_ptr<T> listOfExpr = std::make_unique<T>(); for (const auto& elem : logicalElementObj) { if (elem.type() != BSONType::Object) { return {ErrorCodes::TypeMismatch, @@ -347,7 +347,7 @@ StatusWithMatchExpression parseEnum(StringData path, BSONElement enumElement) { << "' cannot be an empty array"}; } - auto orExpr = stdx::make_unique<OrMatchExpression>(); + auto orExpr = std::make_unique<OrMatchExpression>(); UnorderedFieldsBSONElementComparator eltComp; BSONEltSet eqSet = eltComp.makeBSONEltSet(); for (auto&& arrayElem : enumArray) { @@ -363,12 +363,12 @@ StatusWithMatchExpression parseEnum(StringData path, BSONElement enumElement) { // Top-level non-object enum values can be safely ignored, since MongoDB only stores // objects, not scalars or arrays. if (arrayElem.type() == BSONType::Object) { - auto rootDocEq = stdx::make_unique<InternalSchemaRootDocEqMatchExpression>( + auto rootDocEq = std::make_unique<InternalSchemaRootDocEqMatchExpression>( arrayElem.embeddedObject()); orExpr->add(rootDocEq.release()); } } else { - auto eqExpr = stdx::make_unique<InternalSchemaEqMatchExpression>(path, arrayElem); + auto eqExpr = std::make_unique<InternalSchemaEqMatchExpression>(path, arrayElem); orExpr->add(eqExpr.release()); } @@ -376,7 +376,7 @@ StatusWithMatchExpression parseEnum(StringData path, BSONElement enumElement) { // Make sure that the OR expression has at least 1 child. if (orExpr->numChildren() == 0) { - return {stdx::make_unique<AlwaysFalseMatchExpression>()}; + return {std::make_unique<AlwaysFalseMatchExpression>()}; } return {std::move(orExpr)}; @@ -430,7 +430,7 @@ StatusWith<StringDataSet> parseRequired(BSONElement requiredElt) { StatusWithMatchExpression translateRequired(const StringDataSet& requiredProperties, StringData path, InternalSchemaTypeExpression* typeExpr) { - auto andExpr = stdx::make_unique<AndMatchExpression>(); + auto andExpr = std::make_unique<AndMatchExpression>(); std::vector<StringData> sortedProperties(requiredProperties.begin(), requiredProperties.end()); std::sort(sortedProperties.begin(), sortedProperties.end()); @@ -445,7 +445,7 @@ StatusWithMatchExpression translateRequired(const StringDataSet& requiredPropert } auto objectMatch = - stdx::make_unique<InternalSchemaObjectMatchExpression>(path, std::move(andExpr)); + std::make_unique<InternalSchemaObjectMatchExpression>(path, std::move(andExpr)); return makeRestriction(BSONType::Object, path, std::move(objectMatch), typeExpr); } @@ -464,7 +464,7 @@ StatusWithMatchExpression parseProperties(const boost::intrusive_ptr<ExpressionC } auto propertiesObj = propertiesElt.embeddedObject(); - auto andExpr = stdx::make_unique<AndMatchExpression>(); + auto andExpr = std::make_unique<AndMatchExpression>(); for (auto&& property : propertiesObj) { if (property.type() != BSONType::Object) { return {ErrorCodes::TypeMismatch, @@ -489,11 +489,11 @@ StatusWithMatchExpression parseProperties(const boost::intrusive_ptr<ExpressionC // This property either must not exist or must match the nested schema. Therefore, we // generate the match expression (OR (NOT (EXISTS)) <nestedSchemaMatch>). auto existsExpr = - stdx::make_unique<ExistsMatchExpression>(property.fieldNameStringData()); + std::make_unique<ExistsMatchExpression>(property.fieldNameStringData()); - auto notExpr = stdx::make_unique<NotMatchExpression>(existsExpr.release()); + auto notExpr = std::make_unique<NotMatchExpression>(existsExpr.release()); - auto orExpr = stdx::make_unique<OrMatchExpression>(); + auto orExpr = std::make_unique<OrMatchExpression>(); orExpr->add(notExpr.release()); orExpr->add(nestedSchemaMatch.getValue().release()); @@ -508,7 +508,7 @@ StatusWithMatchExpression parseProperties(const boost::intrusive_ptr<ExpressionC } auto objectMatch = - stdx::make_unique<InternalSchemaObjectMatchExpression>(path, std::move(andExpr)); + std::make_unique<InternalSchemaObjectMatchExpression>(path, std::move(andExpr)); return makeRestriction(BSONType::Object, path, std::move(objectMatch), typeExpr); } @@ -547,7 +547,7 @@ StatusWith<std::vector<PatternSchema>> parsePatternProperties( return nestedSchemaMatch.getStatus(); } - auto exprWithPlaceholder = stdx::make_unique<ExpressionWithPlaceholder>( + auto exprWithPlaceholder = std::make_unique<ExpressionWithPlaceholder>( kNamePlaceholder.toString(), std::move(nestedSchemaMatch.getValue())); Pattern pattern{patternSchema.fieldNameStringData()}; patternProperties.emplace_back(std::move(pattern), std::move(exprWithPlaceholder)); @@ -563,7 +563,7 @@ StatusWithMatchExpression parseAdditionalProperties( if (!additionalPropertiesElt) { // The absence of the 'additionalProperties' keyword is identical in meaning to the presence // of 'additionalProperties' with a value of true. - return {stdx::make_unique<AlwaysTrueMatchExpression>()}; + return {std::make_unique<AlwaysTrueMatchExpression>()}; } if (additionalPropertiesElt.type() != BSONType::Bool && @@ -576,9 +576,9 @@ StatusWithMatchExpression parseAdditionalProperties( if (additionalPropertiesElt.type() == BSONType::Bool) { if (additionalPropertiesElt.boolean()) { - return {stdx::make_unique<AlwaysTrueMatchExpression>()}; + return {std::make_unique<AlwaysTrueMatchExpression>()}; } else { - return {stdx::make_unique<AlwaysFalseMatchExpression>()}; + return {std::make_unique<AlwaysFalseMatchExpression>()}; } } @@ -626,10 +626,10 @@ StatusWithMatchExpression parseAllowedProperties( if (!otherwiseExpr.isOK()) { return otherwiseExpr.getStatus(); } - auto otherwiseWithPlaceholder = stdx::make_unique<ExpressionWithPlaceholder>( + auto otherwiseWithPlaceholder = std::make_unique<ExpressionWithPlaceholder>( kNamePlaceholder.toString(), std::move(otherwiseExpr.getValue())); - auto allowedPropertiesExpr = stdx::make_unique<InternalSchemaAllowedPropertiesMatchExpression>( + auto allowedPropertiesExpr = std::make_unique<InternalSchemaAllowedPropertiesMatchExpression>( std::move(propertyNames), kNamePlaceholder, std::move(patternProperties.getValue()), @@ -641,7 +641,7 @@ StatusWithMatchExpression parseAllowedProperties( return {std::move(allowedPropertiesExpr)}; } - auto objectMatch = stdx::make_unique<InternalSchemaObjectMatchExpression>( + auto objectMatch = std::make_unique<InternalSchemaObjectMatchExpression>( path, std::move(allowedPropertiesExpr)); return makeRestriction(BSONType::Object, path, std::move(objectMatch), typeExpr); @@ -659,28 +659,27 @@ StatusWithMatchExpression parseNumProperties(StringData path, return parsedNumProps.getStatus(); } - auto expr = stdx::make_unique<T>(parsedNumProps.getValue()); + auto expr = std::make_unique<T>(parsedNumProps.getValue()); if (path.empty()) { // This is a top-level schema. return {std::move(expr)}; } - auto objectMatch = - stdx::make_unique<InternalSchemaObjectMatchExpression>(path, std::move(expr)); + auto objectMatch = std::make_unique<InternalSchemaObjectMatchExpression>(path, std::move(expr)); return makeRestriction(BSONType::Object, path, std::move(objectMatch), typeExpr); } StatusWithMatchExpression makeDependencyExistsClause(StringData path, StringData dependencyName) { - auto existsExpr = stdx::make_unique<ExistsMatchExpression>(dependencyName); + auto existsExpr = std::make_unique<ExistsMatchExpression>(dependencyName); if (path.empty()) { return {std::move(existsExpr)}; } auto objectMatch = - stdx::make_unique<InternalSchemaObjectMatchExpression>(path, std::move(existsExpr)); + std::make_unique<InternalSchemaObjectMatchExpression>(path, std::move(existsExpr)); return {std::move(objectMatch)}; } @@ -706,9 +705,9 @@ StatusWithMatchExpression translateSchemaDependency( std::array<std::unique_ptr<MatchExpression>, 3> expressions = { std::move(ifClause.getValue()), std::move(nestedSchemaMatch.getValue()), - stdx::make_unique<AlwaysTrueMatchExpression>()}; + std::make_unique<AlwaysTrueMatchExpression>()}; - auto condExpr = stdx::make_unique<InternalSchemaCondMatchExpression>(std::move(expressions)); + auto condExpr = std::make_unique<InternalSchemaCondMatchExpression>(std::move(expressions)); return {std::move(condExpr)}; } @@ -723,7 +722,7 @@ StatusWithMatchExpression translatePropertyDependency(StringData path, BSONEleme << "' cannot be an empty array"}; } - auto propertyDependencyExpr = stdx::make_unique<AndMatchExpression>(); + auto propertyDependencyExpr = std::make_unique<AndMatchExpression>(); std::set<StringData> propertyDependencyNames; for (auto&& propertyDependency : dependency.embeddedObject()) { if (propertyDependency.type() != BSONType::String) { @@ -762,9 +761,9 @@ StatusWithMatchExpression translatePropertyDependency(StringData path, BSONEleme std::array<std::unique_ptr<MatchExpression>, 3> expressions = { {std::move(ifClause.getValue()), std::move(propertyDependencyExpr), - stdx::make_unique<AlwaysTrueMatchExpression>()}}; + std::make_unique<AlwaysTrueMatchExpression>()}}; - auto condExpr = stdx::make_unique<InternalSchemaCondMatchExpression>(std::move(expressions)); + auto condExpr = std::make_unique<InternalSchemaCondMatchExpression>(std::move(expressions)); return {std::move(condExpr)}; } @@ -779,7 +778,7 @@ StatusWithMatchExpression parseDependencies(const boost::intrusive_ptr<Expressio << "' must be an object"}; } - auto andExpr = stdx::make_unique<AndMatchExpression>(); + auto andExpr = std::make_unique<AndMatchExpression>(); for (auto&& dependency : dependencies.embeddedObject()) { if (dependency.type() != BSONType::Object && dependency.type() != BSONType::Array) { return {ErrorCodes::TypeMismatch, @@ -811,13 +810,13 @@ StatusWithMatchExpression parseUniqueItems(BSONElement uniqueItemsElt, << JSONSchemaParser::kSchemaUniqueItemsKeyword << "' must be a boolean"}; } else if (path.empty()) { - return {stdx::make_unique<AlwaysTrueMatchExpression>()}; + return {std::make_unique<AlwaysTrueMatchExpression>()}; } else if (uniqueItemsElt.boolean()) { - auto uniqueItemsExpr = stdx::make_unique<InternalSchemaUniqueItemsMatchExpression>(path); + auto uniqueItemsExpr = std::make_unique<InternalSchemaUniqueItemsMatchExpression>(path); return makeRestriction(BSONType::Array, path, std::move(uniqueItemsExpr), typeExpr); } - return {stdx::make_unique<AlwaysTrueMatchExpression>()}; + return {std::make_unique<AlwaysTrueMatchExpression>()}; } /** @@ -835,7 +834,7 @@ StatusWith<boost::optional<long long>> parseItems( if (itemsElt.type() == BSONType::Array) { // When "items" is an array, generate match expressions for each subschema for each position // in the array, which are bundled together in an AndMatchExpression. - auto andExprForSubschemas = stdx::make_unique<AndMatchExpression>(); + auto andExprForSubschemas = std::make_unique<AndMatchExpression>(); auto index = 0LL; for (auto subschema : itemsElt.embeddedObject()) { if (subschema.type() != BSONType::Object) { @@ -854,9 +853,9 @@ StatusWith<boost::optional<long long>> parseItems( if (!parsedSubschema.isOK()) { return parsedSubschema.getStatus(); } - auto exprWithPlaceholder = stdx::make_unique<ExpressionWithPlaceholder>( + auto exprWithPlaceholder = std::make_unique<ExpressionWithPlaceholder>( kNamePlaceholder.toString(), std::move(parsedSubschema.getValue())); - auto matchArrayIndex = stdx::make_unique<InternalSchemaMatchArrayIndexMatchExpression>( + auto matchArrayIndex = std::make_unique<InternalSchemaMatchArrayIndexMatchExpression>( path, index, std::move(exprWithPlaceholder)); andExprForSubschemas->add(matchArrayIndex.release()); ++index; @@ -864,7 +863,7 @@ StatusWith<boost::optional<long long>> parseItems( startIndexForAdditionalItems = index; if (path.empty()) { - andExpr->add(stdx::make_unique<AlwaysTrueMatchExpression>().release()); + andExpr->add(std::make_unique<AlwaysTrueMatchExpression>().release()); } else { andExpr->add( makeRestriction(BSONType::Array, path, std::move(andExprForSubschemas), typeExpr) @@ -879,15 +878,15 @@ StatusWith<boost::optional<long long>> parseItems( if (!nestedItemsSchema.isOK()) { return nestedItemsSchema.getStatus(); } - auto exprWithPlaceholder = stdx::make_unique<ExpressionWithPlaceholder>( + auto exprWithPlaceholder = std::make_unique<ExpressionWithPlaceholder>( kNamePlaceholder.toString(), std::move(nestedItemsSchema.getValue())); if (path.empty()) { - andExpr->add(stdx::make_unique<AlwaysTrueMatchExpression>().release()); + andExpr->add(std::make_unique<AlwaysTrueMatchExpression>().release()); } else { constexpr auto startIndexForItems = 0LL; auto allElemMatch = - stdx::make_unique<InternalSchemaAllElemMatchFromIndexMatchExpression>( + std::make_unique<InternalSchemaAllElemMatchFromIndexMatchExpression>( path, startIndexForItems, std::move(exprWithPlaceholder)); andExpr->add(makeRestriction(BSONType::Array, path, std::move(allElemMatch), typeExpr) .release()); @@ -913,11 +912,11 @@ Status parseAdditionalItems(const boost::intrusive_ptr<ExpressionContext>& expCt if (additionalItemsElt.type() == BSONType::Bool) { const auto emptyPlaceholder = boost::none; if (additionalItemsElt.boolean()) { - otherwiseExpr = stdx::make_unique<ExpressionWithPlaceholder>( - emptyPlaceholder, stdx::make_unique<AlwaysTrueMatchExpression>()); + otherwiseExpr = std::make_unique<ExpressionWithPlaceholder>( + emptyPlaceholder, std::make_unique<AlwaysTrueMatchExpression>()); } else { - otherwiseExpr = stdx::make_unique<ExpressionWithPlaceholder>( - emptyPlaceholder, stdx::make_unique<AlwaysFalseMatchExpression>()); + otherwiseExpr = std::make_unique<ExpressionWithPlaceholder>( + emptyPlaceholder, std::make_unique<AlwaysFalseMatchExpression>()); } } else if (additionalItemsElt.type() == BSONType::Object) { auto parsedOtherwiseExpr = _parse( @@ -925,7 +924,7 @@ Status parseAdditionalItems(const boost::intrusive_ptr<ExpressionContext>& expCt if (!parsedOtherwiseExpr.isOK()) { return parsedOtherwiseExpr.getStatus(); } - otherwiseExpr = stdx::make_unique<ExpressionWithPlaceholder>( + otherwiseExpr = std::make_unique<ExpressionWithPlaceholder>( kNamePlaceholder.toString(), std::move(parsedOtherwiseExpr.getValue())); } else { return {ErrorCodes::TypeMismatch, @@ -938,10 +937,10 @@ Status parseAdditionalItems(const boost::intrusive_ptr<ExpressionContext>& expCt // Only generate a match expression if needed. if (startIndexForAdditionalItems) { if (path.empty()) { - andExpr->add(stdx::make_unique<AlwaysTrueMatchExpression>().release()); + andExpr->add(std::make_unique<AlwaysTrueMatchExpression>().release()); } else { auto allElemMatch = - stdx::make_unique<InternalSchemaAllElemMatchFromIndexMatchExpression>( + std::make_unique<InternalSchemaAllElemMatchFromIndexMatchExpression>( path, *startIndexForAdditionalItems, std::move(otherwiseExpr)); andExpr->add(makeRestriction(BSONType::Array, path, std::move(allElemMatch), typeExpr) .release()); @@ -1033,7 +1032,7 @@ Status translateLogicalKeywords(StringMap<BSONElement>& keywordMap, return parsedExpr.getStatus(); } - auto notMatchExpr = stdx::make_unique<NotMatchExpression>(parsedExpr.getValue().release()); + auto notMatchExpr = std::make_unique<NotMatchExpression>(parsedExpr.getValue().release()); andExpr->add(notMatchExpr.release()); } @@ -1525,11 +1524,11 @@ StatusWithMatchExpression _parse(const boost::intrusive_ptr<ExpressionContext>& } else if (encryptElem) { // The presence of the encrypt keyword implies the restriction that the field must be // of type BinData. - typeExpr = stdx::make_unique<InternalSchemaTypeExpression>( - path, MatcherTypeSet(BSONType::BinData)); + typeExpr = + std::make_unique<InternalSchemaTypeExpression>(path, MatcherTypeSet(BSONType::BinData)); } - auto andExpr = stdx::make_unique<AndMatchExpression>(); + auto andExpr = std::make_unique<AndMatchExpression>(); auto translationStatus = translateScalarKeywords(keywordMap, path, typeExpr.get(), andExpr.get()); @@ -1563,7 +1562,7 @@ StatusWithMatchExpression _parse(const boost::intrusive_ptr<ExpressionContext>& if (path.empty() && typeExpr && !typeExpr->typeSet().hasType(BSONType::Object)) { // This is a top-level schema which requires that the type is something other than // "object". Since we only know how to store objects, this schema matches nothing. - return {stdx::make_unique<AlwaysFalseMatchExpression>()}; + return {std::make_unique<AlwaysFalseMatchExpression>()}; } if (!path.empty() && typeExpr) { |