From a9b6612f5322f916298c19a6728817a1034c6aab Mon Sep 17 00:00:00 2001 From: Andrew Morrow Date: Wed, 10 Jun 2015 17:43:13 -0400 Subject: SERVER-17309 Replace std::auto_ptr with std::unique_ptr --- src/mongo/db/auth/authorization_manager.cpp | 8 +- src/mongo/db/auth/authorization_manager.h | 2 +- src/mongo/db/auth/user.cpp | 2 +- src/mongo/db/catalog/database.cpp | 6 +- src/mongo/db/catalog/index_catalog.cpp | 8 +- src/mongo/db/clientcursor.h | 2 +- src/mongo/db/cloner.cpp | 6 +- src/mongo/db/cloner.h | 2 +- src/mongo/db/commands/clone_collection.cpp | 4 +- src/mongo/db/commands/dbhash.cpp | 4 +- src/mongo/db/commands/distinct.cpp | 4 +- .../db/commands/index_filter_commands_test.cpp | 6 +- src/mongo/db/commands/list_collections.cpp | 6 +- src/mongo/db/commands/list_indexes.cpp | 6 +- src/mongo/db/commands/mr.cpp | 14 ++-- src/mongo/db/commands/parallel_collection_scan.cpp | 4 +- src/mongo/db/commands/pipeline_command.cpp | 8 +- src/mongo/db/commands/plan_cache_commands_test.cpp | 20 ++--- src/mongo/db/commands/repair_cursor.cpp | 6 +- .../db/commands/write_commands/batch_executor.cpp | 6 +- src/mongo/db/db.cpp | 4 +- src/mongo/db/dbcommands.cpp | 8 +- src/mongo/db/dbdirectclient.cpp | 4 +- src/mongo/db/dbdirectclient.h | 2 +- src/mongo/db/dbhelpers.cpp | 12 +-- src/mongo/db/exec/and_hash.cpp | 4 +- src/mongo/db/exec/and_sorted.cpp | 4 +- src/mongo/db/exec/collection_scan.cpp | 4 +- src/mongo/db/exec/count.cpp | 4 +- src/mongo/db/exec/count_scan.cpp | 4 +- src/mongo/db/exec/delete.cpp | 4 +- src/mongo/db/exec/distinct_scan.cpp | 4 +- src/mongo/db/exec/fetch.cpp | 4 +- src/mongo/db/exec/geo_near.cpp | 8 +- src/mongo/db/exec/group.cpp | 4 +- src/mongo/db/exec/group.h | 2 +- src/mongo/db/exec/idhack.cpp | 4 +- src/mongo/db/exec/keep_mutations.cpp | 4 +- src/mongo/db/exec/limit.cpp | 4 +- src/mongo/db/exec/merge_sort.cpp | 4 +- src/mongo/db/exec/multi_plan.cpp | 6 +- src/mongo/db/exec/or.cpp | 4 +- src/mongo/db/exec/projection.cpp | 4 +- src/mongo/db/exec/projection_exec_test.cpp | 4 +- src/mongo/db/exec/queued_data_stage.cpp | 4 +- src/mongo/db/exec/queued_data_stage_test.cpp | 10 +-- src/mongo/db/exec/shard_filter.cpp | 4 +- src/mongo/db/exec/skip.cpp | 4 +- src/mongo/db/exec/sort.cpp | 6 +- src/mongo/db/exec/stagedebug_cmd.cpp | 12 +-- src/mongo/db/exec/subplan.cpp | 8 +- src/mongo/db/exec/text.cpp | 4 +- src/mongo/db/exec/update.cpp | 4 +- src/mongo/db/exec/working_set.h | 2 +- src/mongo/db/field_parser-inl.h | 12 +-- src/mongo/db/geo/big_polygon.cpp | 4 +- src/mongo/db/geo/big_polygon_test.cpp | 2 +- src/mongo/db/geo/geoparser.cpp | 4 +- src/mongo/db/geo/r2_region_coverer_test.cpp | 6 +- src/mongo/db/instance.cpp | 4 +- src/mongo/db/matcher/expression_array_test.cpp | 72 ++++++++-------- src/mongo/db/matcher/expression_parser.cpp | 50 +++++------ src/mongo/db/matcher/expression_parser_geo.cpp | 10 +-- src/mongo/db/matcher/expression_parser_text.cpp | 4 +- src/mongo/db/matcher/expression_parser_tree.cpp | 6 +- src/mongo/db/matcher/expression_tree.h | 2 +- src/mongo/db/matcher/expression_tree_test.cpp | 98 +++++++++++----------- src/mongo/db/matcher/expression_where.cpp | 6 +- src/mongo/db/matcher/expression_where_noop.cpp | 4 +- src/mongo/db/operation_context_impl.h | 2 +- src/mongo/db/operation_context_noop.h | 2 +- src/mongo/db/ops/modifier_table_test.cpp | 4 +- src/mongo/db/ops/parsed_delete.h | 2 +- src/mongo/db/ops/parsed_update.h | 2 +- src/mongo/db/ops/path_support_test.cpp | 56 ++++++------- src/mongo/db/ops/update_driver.cpp | 6 +- src/mongo/db/query/canonical_query.cpp | 10 +-- src/mongo/db/query/canonical_query_test.cpp | 50 +++++------ src/mongo/db/query/explain.cpp | 4 +- src/mongo/db/query/find.cpp | 4 +- src/mongo/db/query/get_executor.cpp | 26 +++--- src/mongo/db/query/get_executor_test.cpp | 6 +- src/mongo/db/query/index_bounds_builder_test.cpp | 78 ++++++++--------- src/mongo/db/query/lite_parsed_query.cpp | 8 +- src/mongo/db/query/lru_key_value.h | 10 +-- src/mongo/db/query/lru_key_value_test.cpp | 8 +- src/mongo/db/query/parsed_projection.cpp | 4 +- src/mongo/db/query/parsed_projection_test.cpp | 24 +++--- src/mongo/db/query/plan_cache.cpp | 4 +- src/mongo/db/query/plan_cache_test.cpp | 48 +++++------ src/mongo/db/query/plan_enumerator.cpp | 4 +- src/mongo/db/query/plan_executor.cpp | 2 +- src/mongo/db/query/planner_access.cpp | 10 +-- src/mongo/db/query/planner_access.h | 10 +-- src/mongo/db/query/planner_analysis.cpp | 4 +- src/mongo/db/query/planner_ixselect_test.cpp | 6 +- src/mongo/db/query/query_planner.cpp | 6 +- src/mongo/db/query/stage_builder.cpp | 10 +-- src/mongo/db/range_deleter.cpp | 4 +- src/mongo/db/repl/master_slave.cpp | 6 +- .../db/repl/repl_set_heartbeat_response_test.cpp | 2 +- src/mongo/db/repl/replication_info.cpp | 4 +- src/mongo/db/repl/rs_rollback.cpp | 2 +- src/mongo/db/restapi.cpp | 4 +- src/mongo/db/stats/snapshots.cpp | 2 +- .../storage/mmap_v1/btree/btree_interface_test.cpp | 2 +- src/mongo/db/storage/mmap_v1/btree/btree_logic.cpp | 6 +- src/mongo/db/storage/mmap_v1/btree/btree_logic.h | 2 +- .../db/storage/mmap_v1/btree/btree_logic_test.cpp | 4 +- src/mongo/db/storage/mmap_v1/dur_recover.cpp | 12 +-- .../mmap_v1/mmap_v1_database_catalog_entry.cpp | 6 +- .../db/storage/mmap_v1/mmap_v1_extent_manager.cpp | 8 +- 112 files changed, 525 insertions(+), 525 deletions(-) (limited to 'src/mongo/db') diff --git a/src/mongo/db/auth/authorization_manager.cpp b/src/mongo/db/auth/authorization_manager.cpp index 9d8235663ec..d9f9fa6660c 100644 --- a/src/mongo/db/auth/authorization_manager.cpp +++ b/src/mongo/db/auth/authorization_manager.cpp @@ -464,7 +464,7 @@ namespace mongo { return Status::OK(); } - std::auto_ptr user; + std::unique_ptr user; int authzVersion = _version; guard.beginFetchPhase(); @@ -530,16 +530,16 @@ namespace mongo { Status AuthorizationManager::_fetchUserV2(OperationContext* txn, const UserName& userName, - std::auto_ptr* acquiredUser) { + std::unique_ptr* acquiredUser) { BSONObj userObj; Status status = getUserDescription(txn, userName, &userObj); if (!status.isOK()) { return status; } - // Put the new user into an auto_ptr temporarily in case there's an error while + // Put the new user into an unique_ptr temporarily in case there's an error while // initializing the user. - std::auto_ptr user(new User(userName)); + std::unique_ptr user(new User(userName)); status = _initializeUserFromPrivilegeDocument(user.get(), userObj); if (!status.isOK()) { diff --git a/src/mongo/db/auth/authorization_manager.h b/src/mongo/db/auth/authorization_manager.h index 78e1e17ff82..009f8e8130b 100644 --- a/src/mongo/db/auth/authorization_manager.h +++ b/src/mongo/db/auth/authorization_manager.h @@ -344,7 +344,7 @@ namespace mongo { */ Status _fetchUserV2(OperationContext* txn, const UserName& userName, - std::auto_ptr* acquiredUser); + std::unique_ptr* acquiredUser); /** * True if access control enforcement is enabled in this AuthorizationManager. diff --git a/src/mongo/db/auth/user.cpp b/src/mongo/db/auth/user.cpp index 4fcfaf883cb..a2afa97a4e3 100644 --- a/src/mongo/db/auth/user.cpp +++ b/src/mongo/db/auth/user.cpp @@ -87,7 +87,7 @@ namespace mongo { } User* User::clone() const { - std::auto_ptr result(new User(_name)); + std::unique_ptr result(new User(_name)); result->_privileges = _privileges; result->_roles = _roles; result->_credentials = _credentials; diff --git a/src/mongo/db/catalog/database.cpp b/src/mongo/db/catalog/database.cpp index 1ac2e3f1c58..7753235fa8f 100644 --- a/src/mongo/db/catalog/database.cpp +++ b/src/mongo/db/catalog/database.cpp @@ -65,7 +65,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::list; using std::set; @@ -181,10 +181,10 @@ namespace mongo { return collection; } - auto_ptr cce( _dbEntry->getCollectionCatalogEntry( fullns ) ); + unique_ptr cce( _dbEntry->getCollectionCatalogEntry( fullns ) ); invariant( cce.get() ); - auto_ptr rs( _dbEntry->getRecordStore( fullns ) ); + unique_ptr rs( _dbEntry->getRecordStore( fullns ) ); invariant( rs.get() ); // if cce exists, so should this // Not registering AddCollectionChange since this is for collections that already exist. diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp index 9e20c50656c..734c6c6e412 100644 --- a/src/mongo/db/catalog/index_catalog.cpp +++ b/src/mongo/db/catalog/index_catalog.cpp @@ -65,7 +65,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::string; using std::vector; @@ -164,9 +164,9 @@ namespace { IndexCatalogEntry* IndexCatalog::_setupInMemoryStructures(OperationContext* txn, IndexDescriptor* descriptor, bool initFromDisk) { - auto_ptr descriptorCleanup( descriptor ); + unique_ptr descriptorCleanup( descriptor ); - auto_ptr entry( new IndexCatalogEntry( _collection->ns().ns(), + unique_ptr entry( new IndexCatalogEntry( _collection->ns().ns(), _collection->getCatalogEntry(), descriptorCleanup.release(), _collection->infoCache() ) ); @@ -385,7 +385,7 @@ namespace { IndexDescriptor* descriptor = new IndexDescriptor( _collection, IndexNames::findPluginName(keyPattern), _spec ); - auto_ptr descriptorCleaner( descriptor ); + unique_ptr descriptorCleaner( descriptor ); _indexName = descriptor->indexName(); _indexNamespace = descriptor->indexNamespace(); diff --git a/src/mongo/db/clientcursor.h b/src/mongo/db/clientcursor.h index 18e64a4c0fe..b2afdd56e10 100644 --- a/src/mongo/db/clientcursor.h +++ b/src/mongo/db/clientcursor.h @@ -264,7 +264,7 @@ namespace mongo { // Only one of these is not-NULL. RecoveryUnit* _unownedRU; - std::auto_ptr _ownedRU; + std::unique_ptr _ownedRU; // NOTE: _ownedRU must come before _exec, because _ownedRU must outlive _exec. // The storage engine can have resources in the PlanExecutor that rely on // the RecoveryUnit being alive. diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp index 52aa4babaa1..8ed98728c83 100644 --- a/src/mongo/db/cloner.cpp +++ b/src/mongo/db/cloner.cpp @@ -68,7 +68,7 @@ namespace mongo { using boost::scoped_ptr; - using std::auto_ptr; + using std::unique_ptr; using std::list; using std::set; using std::endl; @@ -467,7 +467,7 @@ namespace mongo { } else if ( !masterSameProcess ) { std::string errmsg; - auto_ptr con( cs.connect( errmsg )); + unique_ptr con( cs.connect( errmsg )); if (!con.get()) { return Status(ErrorCodes::HostUnreachable, errmsg); } @@ -479,7 +479,7 @@ namespace mongo { "Unable to authenticate as internal user"); } - _conn = con; + _conn = std::move(con); } else { _conn.reset(new DBDirectClient(txn)); diff --git a/src/mongo/db/cloner.h b/src/mongo/db/cloner.h index d537932dc83..2009d971869 100644 --- a/src/mongo/db/cloner.h +++ b/src/mongo/db/cloner.h @@ -88,7 +88,7 @@ namespace mongo { bool mayBeInterrupted); struct Fun; - std::auto_ptr _conn; + std::unique_ptr _conn; }; /** diff --git a/src/mongo/db/commands/clone_collection.cpp b/src/mongo/db/commands/clone_collection.cpp index a532a1e402f..2ef62f8b090 100644 --- a/src/mongo/db/commands/clone_collection.cpp +++ b/src/mongo/db/commands/clone_collection.cpp @@ -57,7 +57,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::string; using std::stringstream; using std::endl; @@ -146,7 +146,7 @@ namespace mongo { << " query: " << query << " " << ( copyIndexes ? "" : ", not copying indexes" ) << endl; Cloner cloner; - auto_ptr myconn; + unique_ptr myconn; myconn.reset( new DBClientConnection() ); if ( ! myconn->connect( HostAndPort(fromhost) , errmsg ) ) return false; diff --git a/src/mongo/db/commands/dbhash.cpp b/src/mongo/db/commands/dbhash.cpp index b99d8305a40..e96fb4b6288 100644 --- a/src/mongo/db/commands/dbhash.cpp +++ b/src/mongo/db/commands/dbhash.cpp @@ -48,7 +48,7 @@ namespace mongo { using boost::scoped_ptr; - using std::auto_ptr; + using std::unique_ptr; using std::list; using std::endl; using std::set; @@ -97,7 +97,7 @@ namespace mongo { IndexDescriptor* desc = collection->getIndexCatalog()->findIdIndex( opCtx ); - auto_ptr exec; + unique_ptr exec; if ( desc ) { exec.reset(InternalPlanner::indexScan(opCtx, collection, diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp index 778bfdd723d..ceae947fc52 100644 --- a/src/mongo/db/commands/distinct.cpp +++ b/src/mongo/db/commands/distinct.cpp @@ -47,7 +47,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::string; using std::stringstream; @@ -131,7 +131,7 @@ namespace mongo { return 0; } - auto_ptr exec(rawExec); + unique_ptr exec(rawExec); BSONObj obj; PlanExecutor::ExecState state; diff --git a/src/mongo/db/commands/index_filter_commands_test.cpp b/src/mongo/db/commands/index_filter_commands_test.cpp index aaa54f054be..a1781f2b5bd 100644 --- a/src/mongo/db/commands/index_filter_commands_test.cpp +++ b/src/mongo/db/commands/index_filter_commands_test.cpp @@ -45,7 +45,7 @@ using namespace mongo; namespace { using boost::scoped_ptr; - using std::auto_ptr; + using std::unique_ptr; using std::string; using std::vector; @@ -97,10 +97,10 @@ namespace { * Utility function to create a PlanRankingDecision */ PlanRankingDecision* createDecision(size_t numPlans) { - auto_ptr why(new PlanRankingDecision()); + unique_ptr why(new PlanRankingDecision()); for (size_t i = 0; i < numPlans; ++i) { CommonStats common("COLLSCAN"); - auto_ptr stats(new PlanStageStats(common, STAGE_COLLSCAN)); + unique_ptr stats(new PlanStageStats(common, STAGE_COLLSCAN)); stats->specific.reset(new CollectionScanStats()); why->stats.mutableVector().push_back(stats.release()); why->scores.push_back(0U); diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp index 7773b0f0eed..a9fd6daea3b 100644 --- a/src/mongo/db/commands/list_collections.cpp +++ b/src/mongo/db/commands/list_collections.cpp @@ -130,8 +130,8 @@ namespace mongo { names.sort(); } - std::auto_ptr ws(new WorkingSet()); - std::auto_ptr root(new QueuedDataStage(ws.get())); + std::unique_ptr ws(new WorkingSet()); + std::unique_ptr root(new QueuedDataStage(ws.get())); for (std::list::const_iterator i = names.begin(); i != names.end(); @@ -174,7 +174,7 @@ namespace mongo { cursorNamespace, PlanExecutor::YIELD_MANUAL, &rawExec); - std::auto_ptr exec(rawExec); + std::unique_ptr exec(rawExec); if (!makeStatus.isOK()) { return appendCommandStatus( result, makeStatus ); } diff --git a/src/mongo/db/commands/list_indexes.cpp b/src/mongo/db/commands/list_indexes.cpp index d84e605c21f..6cdee4785fd 100644 --- a/src/mongo/db/commands/list_indexes.cpp +++ b/src/mongo/db/commands/list_indexes.cpp @@ -136,8 +136,8 @@ namespace mongo { cce->getAllIndexes( txn, &indexNames ); } MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "listIndexes", ns.ns()); - std::auto_ptr ws(new WorkingSet()); - std::auto_ptr root(new QueuedDataStage(ws.get())); + std::unique_ptr ws(new WorkingSet()); + std::unique_ptr root(new QueuedDataStage(ws.get())); for ( size_t i = 0; i < indexNames.size(); i++ ) { BSONObj indexSpec; @@ -166,7 +166,7 @@ namespace mongo { cursorNamespace, PlanExecutor::YIELD_MANUAL, &rawExec); - std::auto_ptr exec(rawExec); + std::unique_ptr exec(rawExec); if (!makeStatus.isOK()) { return appendCommandStatus( result, makeStatus ); } diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index 3fbd4460493..099be62e3bc 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -74,7 +74,7 @@ namespace mongo { using boost::scoped_ptr; using boost::shared_ptr; - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::set; using std::string; @@ -626,7 +626,7 @@ namespace mongo { "M/R Merge Post Processing Progress", count); } - auto_ptr cursor = _db.query(_config.tempNamespace , BSONObj()); + unique_ptr cursor = _db.query(_config.tempNamespace , BSONObj()); while (cursor->more()) { ScopedTransaction scopedXact(_txn, MODE_IX); Lock::DBLock lock(_txn->lockState(), @@ -650,7 +650,7 @@ namespace mongo { "M/R Reduce Post Processing Progress", count); } - auto_ptr cursor = _db.query( _config.tempNamespace , BSONObj() ); + unique_ptr cursor = _db.query( _config.tempNamespace , BSONObj() ); while ( cursor->more() ) { ScopedTransaction transaction(txn, MODE_X); Lock::GlobalWrite lock(txn->lockState()); // TODO(erh) why global? @@ -1048,7 +1048,7 @@ namespace mongo { BSONObj(), &cqRaw, whereCallback).isOK()); - std::auto_ptr cq(cqRaw); + std::unique_ptr cq(cqRaw); Collection* coll = getCollectionOrUassert(ctx->getDb(), _config.incLong); invariant(coll); @@ -1120,7 +1120,7 @@ namespace mongo { return; } - auto_ptr n( new InMemory() ); // for new data + unique_ptr n( new InMemory() ); // for new data long nSize = 0; _dupCount = 0; @@ -1327,7 +1327,7 @@ namespace mongo { CollectionMetadataPtr collMetadata; // Prevent sharding state from changing during the MR. - auto_ptr rangePreserver; + unique_ptr rangePreserver; { AutoGetCollectionForRead ctx(txn, config.ns); @@ -1416,7 +1416,7 @@ namespace mongo { uasserted(17238, "Can't canonicalize query " + config.filter.toString()); return 0; } - std::auto_ptr cq(cqRaw); + std::unique_ptr cq(cqRaw); Database* db = scopedAutoDb->getDb(); Collection* coll = state.getCollectionOrUassert(db, config.ns); diff --git a/src/mongo/db/commands/parallel_collection_scan.cpp b/src/mongo/db/commands/parallel_collection_scan.cpp index 08b760825d6..36acc5d9bb8 100644 --- a/src/mongo/db/commands/parallel_collection_scan.cpp +++ b/src/mongo/db/commands/parallel_collection_scan.cpp @@ -41,7 +41,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::string; class ParallelCollectionScanCmd : public Command { @@ -115,7 +115,7 @@ namespace mongo { Status execStatus = PlanExecutor::make(txn, ws, mis, collection, PlanExecutor::YIELD_AUTO, &rawExec); invariant(execStatus.isOK()); - auto_ptr curExec(rawExec); + unique_ptr curExec(rawExec); // The PlanExecutor was registered on construction due to the YIELD_AUTO policy. // We have to deregister it, as it will be registered with ClientCursor. diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp index 792442914ed..34c0c2e5976 100644 --- a/src/mongo/db/commands/pipeline_command.cpp +++ b/src/mongo/db/commands/pipeline_command.cpp @@ -59,7 +59,7 @@ namespace mongo { using boost::intrusive_ptr; using boost::scoped_ptr; using boost::shared_ptr; - using std::auto_ptr; + using std::unique_ptr; using std::string; using std::stringstream; using std::endl; @@ -219,7 +219,7 @@ namespace mongo { PlanExecutor* exec = NULL; scoped_ptr pin; // either this OR the execHolder will be non-null - auto_ptr execHolder; + unique_ptr execHolder; { // This will throw if the sharding version for this connection is out of date. The // lock must be held continuously from now until we have we created both the output @@ -242,8 +242,8 @@ namespace mongo { // Create the PlanExecutor which returns results from the pipeline. The WorkingSet // ('ws') and the PipelineProxyStage ('proxy') will be owned by the created // PlanExecutor. - auto_ptr ws(new WorkingSet()); - auto_ptr proxy( + unique_ptr ws(new WorkingSet()); + unique_ptr proxy( new PipelineProxyStage(pPipeline, input, ws.get())); Status execStatus = Status::OK(); if (NULL == collection) { diff --git a/src/mongo/db/commands/plan_cache_commands_test.cpp b/src/mongo/db/commands/plan_cache_commands_test.cpp index dd2c0333288..69a9c461a76 100644 --- a/src/mongo/db/commands/plan_cache_commands_test.cpp +++ b/src/mongo/db/commands/plan_cache_commands_test.cpp @@ -47,7 +47,7 @@ using namespace mongo; namespace { using boost::scoped_ptr; - using std::auto_ptr; + using std::unique_ptr; using std::string; using std::vector; @@ -98,7 +98,7 @@ namespace { * Utility function to create a SolutionCacheData */ SolutionCacheData* createSolutionCacheData() { - auto_ptr scd(new SolutionCacheData()); + unique_ptr scd(new SolutionCacheData()); scd->tree.reset(new PlanCacheIndexTree()); return scd.release(); } @@ -107,10 +107,10 @@ namespace { * Utility function to create a PlanRankingDecision */ PlanRankingDecision* createDecision(size_t numPlans) { - auto_ptr why(new PlanRankingDecision()); + unique_ptr why(new PlanRankingDecision()); for (size_t i = 0; i < numPlans; ++i) { CommonStats common("COLLSCAN"); - auto_ptr stats(new PlanStageStats(common, STAGE_COLLSCAN)); + unique_ptr stats(new PlanStageStats(common, STAGE_COLLSCAN)); stats->specific.reset(new CollectionScanStats()); why->stats.mutableVector().push_back(stats.release()); why->scores.push_back(0U); @@ -129,7 +129,7 @@ namespace { // Create a canonical query CanonicalQuery* cqRaw; ASSERT_OK(CanonicalQuery::canonicalize(ns, fromjson("{a: 1}"), &cqRaw)); - auto_ptr cq(cqRaw); + unique_ptr cq(cqRaw); // Plan cache with one entry PlanCache planCache; @@ -154,7 +154,7 @@ namespace { // Create a canonical query CanonicalQuery* cqRaw; ASSERT_OK(CanonicalQuery::canonicalize(ns, fromjson("{a: 1}"), &cqRaw)); - auto_ptr cq(cqRaw); + unique_ptr cq(cqRaw); // Plan cache with one entry PlanCache planCache; @@ -261,9 +261,9 @@ namespace { // Create 2 canonical queries. CanonicalQuery* cqRaw; ASSERT_OK(CanonicalQuery::canonicalize(ns, fromjson("{a: 1}"), &cqRaw)); - auto_ptr cqA(cqRaw); + unique_ptr cqA(cqRaw); ASSERT_OK(CanonicalQuery::canonicalize(ns, fromjson("{b: 1}"), &cqRaw)); - auto_ptr cqB(cqRaw); + unique_ptr cqB(cqRaw); // Create plan cache with 2 entries. PlanCache planCache; @@ -378,7 +378,7 @@ namespace { // Create a canonical query CanonicalQuery* cqRaw; ASSERT_OK(CanonicalQuery::canonicalize(ns, fromjson("{a: 1}"), &cqRaw)); - auto_ptr cq(cqRaw); + unique_ptr cq(cqRaw); // Plan cache with one entry PlanCache planCache; @@ -397,7 +397,7 @@ namespace { // Create a canonical query CanonicalQuery* cqRaw; ASSERT_OK(CanonicalQuery::canonicalize(ns, fromjson("{a: 1}"), &cqRaw)); - auto_ptr cq(cqRaw); + unique_ptr cq(cqRaw); // Plan cache with one entry PlanCache planCache; diff --git a/src/mongo/db/commands/repair_cursor.cpp b/src/mongo/db/commands/repair_cursor.cpp index 8828bdcdae0..0598b67b9c3 100644 --- a/src/mongo/db/commands/repair_cursor.cpp +++ b/src/mongo/db/commands/repair_cursor.cpp @@ -87,8 +87,8 @@ namespace mongo { "repair iterator not supported")); } - std::auto_ptr ws(new WorkingSet()); - std::auto_ptr stage(new MultiIteratorStage(txn, ws.get(), + std::unique_ptr ws(new WorkingSet()); + std::unique_ptr stage(new MultiIteratorStage(txn, ws.get(), collection)); stage->addIterator(std::move(cursor)); @@ -100,7 +100,7 @@ namespace mongo { PlanExecutor::YIELD_AUTO, &rawExec); invariant(execStatus.isOK()); - std::auto_ptr exec(rawExec); + std::unique_ptr exec(rawExec); // 'exec' will be used in getMore(). It was automatically registered on construction // due to the auto yield policy, so it could yield during plan selection. We deregister diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp index 68150b76c81..f13689c1bf1 100644 --- a/src/mongo/db/commands/write_commands/batch_executor.cpp +++ b/src/mongo/db/commands/write_commands/batch_executor.cpp @@ -85,7 +85,7 @@ namespace mongo { using boost::scoped_ptr; - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::string; using std::vector; @@ -108,7 +108,7 @@ namespace mongo { private: WriteOpStats _stats; - std::auto_ptr _error; + std::unique_ptr _error; }; } // namespace @@ -247,7 +247,7 @@ namespace mongo { // OR if something succeeded and we're unordered. // - auto_ptr wcError; + unique_ptr wcError; bool needToEnforceWC = writeErrors.empty() || ( !request.getOrdered() && writeErrors.size() < request.sizeWriteOps() ); diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp index e5555bdd33e..66c45f76dff 100644 --- a/src/mongo/db/db.cpp +++ b/src/mongo/db/db.cpp @@ -124,7 +124,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::cout; using std::cerr; using std::endl; @@ -351,7 +351,7 @@ namespace mongo { const string systemIndexes = db->name() + ".system.indexes"; Collection* coll = db->getCollection( systemIndexes ); - auto_ptr exec( + unique_ptr exec( InternalPlanner::collectionScan(&txn, systemIndexes, coll)); BSONObj index; diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp index 8d26dc191fb..af49eb9d779 100644 --- a/src/mongo/db/dbcommands.cpp +++ b/src/mongo/db/dbcommands.cpp @@ -110,7 +110,7 @@ namespace mongo { using boost::scoped_ptr; - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::ostringstream; using std::string; @@ -598,7 +598,7 @@ namespace mongo { return 0; } - auto_ptr exec(rawExec); + unique_ptr exec(rawExec); // Process notifications when the lock is released/reacquired in the loop below exec->registerExec(); @@ -665,7 +665,7 @@ namespace mongo { DBDirectClient client(txn); Query q(query); q.sort(sort); - auto_ptr c = client.query(ns, q); + unique_ptr c = client.query(ns, q); while(c->more()) PRINT(c->nextSafe()); } @@ -729,7 +729,7 @@ namespace mongo { result.appendBool( "estimate" , estimate ); - auto_ptr exec; + unique_ptr exec; if ( min.isEmpty() && max.isEmpty() ) { if ( estimate ) { result.appendNumber( "size" , static_cast(collection->dataSize(txn)) ); diff --git a/src/mongo/db/dbdirectclient.cpp b/src/mongo/db/dbdirectclient.cpp index f0107baf9ce..6f297520379 100644 --- a/src/mongo/db/dbdirectclient.cpp +++ b/src/mongo/db/dbdirectclient.cpp @@ -39,7 +39,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::string; @@ -146,7 +146,7 @@ namespace mongo { assembleResponse(_txn, toSend, dbResponse, dummyHost); } - auto_ptr DBDirectClient::query(const string& ns, + unique_ptr DBDirectClient::query(const string& ns, Query query, int nToReturn, int nToSkip, diff --git a/src/mongo/db/dbdirectclient.h b/src/mongo/db/dbdirectclient.h index 0a8b5122dd0..835b63eab46 100644 --- a/src/mongo/db/dbdirectclient.h +++ b/src/mongo/db/dbdirectclient.h @@ -58,7 +58,7 @@ namespace mongo { // XXX: is this valid or useful? void setOpCtx(OperationContext* txn); - virtual std::auto_ptr query(const std::string &ns, + virtual std::unique_ptr query(const std::string &ns, Query query, int nToReturn = 0, int nToSkip = 0, diff --git a/src/mongo/db/dbhelpers.cpp b/src/mongo/db/dbhelpers.cpp index 93dd0b05dde..ae5444b8c1a 100644 --- a/src/mongo/db/dbhelpers.cpp +++ b/src/mongo/db/dbhelpers.cpp @@ -68,7 +68,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::ios_base; using std::ofstream; @@ -145,7 +145,7 @@ namespace mongo { &rawExec, options).isOK()); - auto_ptr exec(rawExec); + unique_ptr exec(rawExec); PlanExecutor::ExecState state; RecordId loc; if (PlanExecutor::ADVANCED == (state = exec->getNext(NULL, &loc))) { @@ -200,7 +200,7 @@ namespace mongo { bool Helpers::getSingleton(OperationContext* txn, const char *ns, BSONObj& result) { AutoGetCollectionForRead ctx(txn, ns); - auto_ptr exec(InternalPlanner::collectionScan(txn, ns, ctx.getCollection())); + unique_ptr exec(InternalPlanner::collectionScan(txn, ns, ctx.getCollection())); PlanExecutor::ExecState state = exec->getNext(&result, NULL); CurOp::get(txn)->done(); @@ -214,7 +214,7 @@ namespace mongo { bool Helpers::getLast(OperationContext* txn, const char *ns, BSONObj& result) { AutoGetCollectionForRead autoColl(txn, ns); - auto_ptr exec(InternalPlanner::collectionScan(txn, + unique_ptr exec(InternalPlanner::collectionScan(txn, ns, autoColl.getCollection(), InternalPlanner::BACKWARD)); @@ -366,7 +366,7 @@ namespace mongo { collection->getIndexCatalog()->findIndexByKeyPattern( txn, indexKeyPattern.toBSON() ); - auto_ptr exec(InternalPlanner::indexScan(txn, collection, desc, + unique_ptr exec(InternalPlanner::indexScan(txn, collection, desc, min, max, maxInclusive, InternalPlanner::FORWARD, @@ -539,7 +539,7 @@ namespace mongo { bool isLargeChunk = false; long long docCount = 0; - auto_ptr exec( + unique_ptr exec( InternalPlanner::indexScan(txn, collection, idx, min, max, false)); // we can afford to yield here because any change to the base data that we might miss is // already being queued and will be migrated in the 'transferMods' stage diff --git a/src/mongo/db/exec/and_hash.cpp b/src/mongo/db/exec/and_hash.cpp index 8374c9740ca..adc24c42394 100644 --- a/src/mongo/db/exec/and_hash.cpp +++ b/src/mongo/db/exec/and_hash.cpp @@ -45,7 +45,7 @@ namespace { namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; const size_t AndHashStage::kLookAheadWorks = 10; @@ -535,7 +535,7 @@ namespace mongo { _commonStats.filter = bob.obj(); } - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_AND_HASH)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_AND_HASH)); ret->specific.reset(new AndHashStats(_specificStats)); for (size_t i = 0; i < _children.size(); ++i) { ret->children.push_back(_children[i]->getStats()); diff --git a/src/mongo/db/exec/and_sorted.cpp b/src/mongo/db/exec/and_sorted.cpp index 813895fc619..c201a7633aa 100644 --- a/src/mongo/db/exec/and_sorted.cpp +++ b/src/mongo/db/exec/and_sorted.cpp @@ -36,7 +36,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::numeric_limits; using std::vector; @@ -326,7 +326,7 @@ namespace mongo { _commonStats.filter = bob.obj(); } - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_AND_SORTED)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_AND_SORTED)); ret->specific.reset(new AndSortedStats(_specificStats)); for (size_t i = 0; i < _children.size(); ++i) { ret->children.push_back(_children[i]->getStats()); diff --git a/src/mongo/db/exec/collection_scan.cpp b/src/mongo/db/exec/collection_scan.cpp index fb8bdf4a311..1a0c16c6b55 100644 --- a/src/mongo/db/exec/collection_scan.cpp +++ b/src/mongo/db/exec/collection_scan.cpp @@ -46,7 +46,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; // static @@ -250,7 +250,7 @@ namespace mongo { _commonStats.filter = bob.obj(); } - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_COLLSCAN)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_COLLSCAN)); ret->specific.reset(new CollectionScanStats(_specificStats)); return ret.release(); } diff --git a/src/mongo/db/exec/count.cpp b/src/mongo/db/exec/count.cpp index 5b3eb904647..9d747c31aca 100644 --- a/src/mongo/db/exec/count.cpp +++ b/src/mongo/db/exec/count.cpp @@ -36,7 +36,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; // static @@ -200,7 +200,7 @@ namespace mongo { PlanStageStats* CountStage::getStats() { _commonStats.isEOF = isEOF(); - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_COUNT)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_COUNT)); CountStats* countStats = new CountStats(_specificStats); ret->specific.reset(countStats); if (_child.get()) { diff --git a/src/mongo/db/exec/count_scan.cpp b/src/mongo/db/exec/count_scan.cpp index 1a801c82566..668313367d9 100644 --- a/src/mongo/db/exec/count_scan.cpp +++ b/src/mongo/db/exec/count_scan.cpp @@ -34,7 +34,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; // static @@ -159,7 +159,7 @@ namespace mongo { } PlanStageStats* CountScan::getStats() { - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_COUNT_SCAN)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_COUNT_SCAN)); CountScanStats* countStats = new CountScanStats(_specificStats); countStats->keyPattern = _specificStats.keyPattern.getOwned(); diff --git a/src/mongo/db/exec/delete.cpp b/src/mongo/db/exec/delete.cpp index b034df535fc..787f3f244bf 100644 --- a/src/mongo/db/exec/delete.cpp +++ b/src/mongo/db/exec/delete.cpp @@ -45,7 +45,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; // static @@ -291,7 +291,7 @@ namespace mongo { PlanStageStats* DeleteStage::getStats() { _commonStats.isEOF = isEOF(); - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_DELETE)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_DELETE)); ret->specific.reset(new DeleteStats(_specificStats)); ret->children.push_back(_child->getStats()); return ret.release(); diff --git a/src/mongo/db/exec/distinct_scan.cpp b/src/mongo/db/exec/distinct_scan.cpp index 4185877064c..24dcc36019a 100644 --- a/src/mongo/db/exec/distinct_scan.cpp +++ b/src/mongo/db/exec/distinct_scan.cpp @@ -37,7 +37,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; // static @@ -149,7 +149,7 @@ namespace mongo { } PlanStageStats* DistinctScan::getStats() { - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_DISTINCT_SCAN)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_DISTINCT_SCAN)); ret->specific.reset(new DistinctScanStats(_specificStats)); return ret.release(); } diff --git a/src/mongo/db/exec/fetch.cpp b/src/mongo/db/exec/fetch.cpp index 481640cc971..817bc72fc8d 100644 --- a/src/mongo/db/exec/fetch.cpp +++ b/src/mongo/db/exec/fetch.cpp @@ -41,7 +41,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; // static @@ -239,7 +239,7 @@ namespace mongo { _commonStats.filter = bob.obj(); } - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_FETCH)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_FETCH)); ret->specific.reset(new FetchStats(_specificStats)); ret->children.push_back(_child->getStats()); return ret.release(); diff --git a/src/mongo/db/exec/geo_near.cpp b/src/mongo/db/exec/geo_near.cpp index dd284e71f0b..3755af02bb3 100644 --- a/src/mongo/db/exec/geo_near.cpp +++ b/src/mongo/db/exec/geo_near.cpp @@ -54,7 +54,7 @@ namespace mongo { using boost::scoped_ptr; using std::abs; - using std::auto_ptr; + using std::unique_ptr; // // Shared GeoNear search functionality @@ -79,7 +79,7 @@ namespace mongo { if (!element.isABSONObj()) return NULL; - auto_ptr stored(new StoredGeometry); + unique_ptr stored(new StoredGeometry); if (!stored->geometry.parseFromStorage(element).isOK()) return NULL; stored->element = element; @@ -106,7 +106,7 @@ namespace mongo { for (BSONElementSet::iterator it = geomElements.begin(); it != geomElements.end(); ++it) { const BSONElement& el = *it; - auto_ptr stored(StoredGeometry::parseFrom(el)); + unique_ptr stored(StoredGeometry::parseFrom(el)); if (stored.get()) { // Valid geometry element @@ -746,7 +746,7 @@ namespace mongo { const CRS queryCRS = _nearParams.nearQuery->centroid->crs; - auto_ptr coverRegion; + unique_ptr coverRegion; if (FLAT == queryCRS) { diff --git a/src/mongo/db/exec/group.cpp b/src/mongo/db/exec/group.cpp index d5d3688d4c5..68b21928b62 100644 --- a/src/mongo/db/exec/group.cpp +++ b/src/mongo/db/exec/group.cpp @@ -38,7 +38,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; namespace { @@ -285,7 +285,7 @@ namespace mongo { PlanStageStats* GroupStage::getStats() { _commonStats.isEOF = isEOF(); - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_GROUP)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_GROUP)); GroupStats* groupStats = new GroupStats(_specificStats); ret->specific.reset(groupStats); ret->children.push_back(_child->getStats()); diff --git a/src/mongo/db/exec/group.h b/src/mongo/db/exec/group.h index dcf96570cbe..2b2e5bb3d04 100644 --- a/src/mongo/db/exec/group.h +++ b/src/mongo/db/exec/group.h @@ -151,7 +151,7 @@ namespace mongo { // The Scope object that all script operations for this group stage will use. Initialized // by initGroupScripting(). Owned here. - std::auto_ptr _scope; + std::unique_ptr _scope; // The reduce function for the group operation. Initialized by initGroupScripting(). Owned // by _scope. diff --git a/src/mongo/db/exec/idhack.cpp b/src/mongo/db/exec/idhack.cpp index 149d20e3509..73a950e4dc2 100644 --- a/src/mongo/db/exec/idhack.cpp +++ b/src/mongo/db/exec/idhack.cpp @@ -42,7 +42,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; // static @@ -240,7 +240,7 @@ namespace mongo { PlanStageStats* IDHackStage::getStats() { _commonStats.isEOF = isEOF(); - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_IDHACK)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_IDHACK)); ret->specific.reset(new IDHackStats(_specificStats)); return ret.release(); } diff --git a/src/mongo/db/exec/keep_mutations.cpp b/src/mongo/db/exec/keep_mutations.cpp index a58c979f02a..7c88a59fde5 100644 --- a/src/mongo/db/exec/keep_mutations.cpp +++ b/src/mongo/db/exec/keep_mutations.cpp @@ -33,7 +33,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; // static @@ -142,7 +142,7 @@ namespace mongo { PlanStageStats* KeepMutationsStage::getStats() { _commonStats.isEOF = isEOF(); - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_KEEP_MUTATIONS)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_KEEP_MUTATIONS)); // Takes ownership of the object returned from _child->getStats(). ret->children.push_back(_child->getStats()); return ret.release(); diff --git a/src/mongo/db/exec/limit.cpp b/src/mongo/db/exec/limit.cpp index 9853cde3e57..c766d07c650 100644 --- a/src/mongo/db/exec/limit.cpp +++ b/src/mongo/db/exec/limit.cpp @@ -34,7 +34,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; // static @@ -119,7 +119,7 @@ namespace mongo { PlanStageStats* LimitStage::getStats() { _commonStats.isEOF = isEOF(); - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_LIMIT)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_LIMIT)); ret->specific.reset(new LimitStats(_specificStats)); ret->children.push_back(_child->getStats()); return ret.release(); diff --git a/src/mongo/db/exec/merge_sort.cpp b/src/mongo/db/exec/merge_sort.cpp index 6d394ba00d6..37c8269a502 100644 --- a/src/mongo/db/exec/merge_sort.cpp +++ b/src/mongo/db/exec/merge_sort.cpp @@ -35,7 +35,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::list; using std::string; using std::vector; @@ -270,7 +270,7 @@ namespace mongo { _specificStats.sortPattern = _pattern; - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_SORT_MERGE)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_SORT_MERGE)); ret->specific.reset(new MergeSortStats(_specificStats)); for (size_t i = 0; i < _children.size(); ++i) { ret->children.push_back(_children[i]->getStats()); diff --git a/src/mongo/db/exec/multi_plan.cpp b/src/mongo/db/exec/multi_plan.cpp index 3258ab719b0..8bc98d109bd 100644 --- a/src/mongo/db/exec/multi_plan.cpp +++ b/src/mongo/db/exec/multi_plan.cpp @@ -51,7 +51,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::list; using std::vector; @@ -245,7 +245,7 @@ namespace mongo { // After picking best plan, ranking will own plan stats from // candidate solutions (winner and losers). - std::auto_ptr ranking(new PlanRankingDecision); + std::unique_ptr ranking(new PlanRankingDecision); _bestPlanIdx = PlanRanker::pickBestPlan(_candidates, ranking.get()); verify(_bestPlanIdx >= 0 && _bestPlanIdx < static_cast(_candidates.size())); @@ -500,7 +500,7 @@ namespace mongo { } _commonStats.isEOF = isEOF(); - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_MULTI_PLAN)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_MULTI_PLAN)); return ret.release(); } diff --git a/src/mongo/db/exec/or.cpp b/src/mongo/db/exec/or.cpp index c27c1a1598f..a7d370c41fa 100644 --- a/src/mongo/db/exec/or.cpp +++ b/src/mongo/db/exec/or.cpp @@ -35,7 +35,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; // static @@ -185,7 +185,7 @@ namespace mongo { _commonStats.filter = bob.obj(); } - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_OR)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_OR)); ret->specific.reset(new OrStats(_specificStats)); for (size_t i = 0; i < _children.size(); ++i) { ret->children.push_back(_children[i]->getStats()); diff --git a/src/mongo/db/exec/projection.cpp b/src/mongo/db/exec/projection.cpp index 7e4f513e4b7..15d06963b31 100644 --- a/src/mongo/db/exec/projection.cpp +++ b/src/mongo/db/exec/projection.cpp @@ -41,7 +41,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::vector; @@ -275,7 +275,7 @@ namespace mongo { PlanStageStats* ProjectionStage::getStats() { _commonStats.isEOF = isEOF(); - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_PROJECTION)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_PROJECTION)); ProjectionStats* projStats = new ProjectionStats(_specificStats); projStats->projObj = _projObj; diff --git a/src/mongo/db/exec/projection_exec_test.cpp b/src/mongo/db/exec/projection_exec_test.cpp index 2ad9fd3b4e0..56d9cbc5be2 100644 --- a/src/mongo/db/exec/projection_exec_test.cpp +++ b/src/mongo/db/exec/projection_exec_test.cpp @@ -42,7 +42,7 @@ using namespace mongo; namespace { - using std::auto_ptr; + using std::unique_ptr; /** * Utility function to create MatchExpression @@ -77,7 +77,7 @@ namespace { // Create projection exec object. BSONObj spec = fromjson(specStr); BSONObj query = fromjson(queryStr); - auto_ptr queryExpression(parseMatchExpression(query)); + unique_ptr queryExpression(parseMatchExpression(query)); ProjectionExec exec(spec, queryExpression.get()); // Create working set member. diff --git a/src/mongo/db/exec/queued_data_stage.cpp b/src/mongo/db/exec/queued_data_stage.cpp index b353cb6026d..740f3084740 100644 --- a/src/mongo/db/exec/queued_data_stage.cpp +++ b/src/mongo/db/exec/queued_data_stage.cpp @@ -33,7 +33,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; const char* QueuedDataStage::kStageType = "QUEUED_DATA"; @@ -84,7 +84,7 @@ namespace mongo { PlanStageStats* QueuedDataStage::getStats() { _commonStats.isEOF = isEOF(); - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_QUEUED_DATA)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_QUEUED_DATA)); ret->specific.reset(new MockStats(_specificStats)); return ret.release(); } diff --git a/src/mongo/db/exec/queued_data_stage_test.cpp b/src/mongo/db/exec/queued_data_stage_test.cpp index 26bc5962a8a..ef823c04cfb 100644 --- a/src/mongo/db/exec/queued_data_stage_test.cpp +++ b/src/mongo/db/exec/queued_data_stage_test.cpp @@ -38,19 +38,19 @@ using namespace mongo; namespace { - using std::auto_ptr; + using std::unique_ptr; // // Basic test that we get out valid stats objects. // TEST(QueuedDataStageTest, getValidStats) { WorkingSet ws; - auto_ptr mock(new QueuedDataStage(&ws)); + unique_ptr mock(new QueuedDataStage(&ws)); const CommonStats* commonStats = mock->getCommonStats(); ASSERT_EQUALS(commonStats->works, static_cast(0)); const SpecificStats* specificStats = mock->getSpecificStats(); ASSERT(specificStats); - auto_ptr allStats(mock->getStats()); + unique_ptr allStats(mock->getStats()); ASSERT_EQUALS(allStats->stageType, mock->stageType()); } @@ -60,7 +60,7 @@ namespace { TEST(QueuedDataStageTest, validateStats) { WorkingSet ws; WorkingSetID wsID; - auto_ptr mock(new QueuedDataStage(&ws)); + unique_ptr mock(new QueuedDataStage(&ws)); // make sure that we're at all zero const CommonStats* stats = mock->getCommonStats(); @@ -101,7 +101,7 @@ namespace { // and now we are d1U, but must trigger EOF with getStats() ASSERT_FALSE(stats->isEOF); - auto_ptr allStats(mock->getStats()); + unique_ptr allStats(mock->getStats()); ASSERT_TRUE(stats->isEOF); } } diff --git a/src/mongo/db/exec/shard_filter.cpp b/src/mongo/db/exec/shard_filter.cpp index 26f546ec836..2727b1c99f8 100644 --- a/src/mongo/db/exec/shard_filter.cpp +++ b/src/mongo/db/exec/shard_filter.cpp @@ -38,7 +38,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; // static @@ -150,7 +150,7 @@ namespace mongo { PlanStageStats* ShardFilterStage::getStats() { _commonStats.isEOF = isEOF(); - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_SHARDING_FILTER)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_SHARDING_FILTER)); ret->children.push_back(_child->getStats()); ret->specific.reset(new ShardingFilterStats(_specificStats)); return ret.release(); diff --git a/src/mongo/db/exec/skip.cpp b/src/mongo/db/exec/skip.cpp index be2284bca0c..979e952b1d7 100644 --- a/src/mongo/db/exec/skip.cpp +++ b/src/mongo/db/exec/skip.cpp @@ -33,7 +33,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; // static @@ -118,7 +118,7 @@ namespace mongo { PlanStageStats* SkipStage::getStats() { _commonStats.isEOF = isEOF(); _specificStats.skip = _toSkip; - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_SKIP)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_SKIP)); ret->specific.reset(new SkipStats(_specificStats)); ret->children.push_back(_child->getStats()); return ret.release(); diff --git a/src/mongo/db/exec/sort.cpp b/src/mongo/db/exec/sort.cpp index 3f2e8be89ad..61dd09e1dbc 100644 --- a/src/mongo/db/exec/sort.cpp +++ b/src/mongo/db/exec/sort.cpp @@ -45,7 +45,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::vector; @@ -238,7 +238,7 @@ namespace mongo { CanonicalQuery* rawQueryForSort; verify(CanonicalQuery::canonicalize( "fake_ns", queryObj, &rawQueryForSort, WhereCallbackNoop()).isOK()); - auto_ptr queryForSort(rawQueryForSort); + unique_ptr queryForSort(rawQueryForSort); vector solns; LOG(5) << "Sort stage: Planning to obtain bounds for sort." << endl; @@ -477,7 +477,7 @@ namespace mongo { _specificStats.limit = _limit; _specificStats.sortPattern = _pattern.getOwned(); - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_SORT)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_SORT)); ret->specific.reset(new SortStats(_specificStats)); ret->children.push_back(_child->getStats()); return ret.release(); diff --git a/src/mongo/db/exec/stagedebug_cmd.cpp b/src/mongo/db/exec/stagedebug_cmd.cpp index bd5c771e1a2..c3b59a84de2 100644 --- a/src/mongo/db/exec/stagedebug_cmd.cpp +++ b/src/mongo/db/exec/stagedebug_cmd.cpp @@ -59,7 +59,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::string; using std::vector; @@ -153,7 +153,7 @@ namespace mongo { // Parse the plan into these. OwnedPointerVector exprs; - auto_ptr ws(new WorkingSet()); + unique_ptr ws(new WorkingSet()); PlanStage* userRoot = parseQuery(txn, collection, planObj, ws.get(), &exprs); uassert(16911, "Couldn't parse plan from " + cmdObj.toString(), NULL != userRoot); @@ -260,7 +260,7 @@ namespace mongo { uassert(16921, "Nodes argument must be provided to AND", nodeArgs["nodes"].isABSONObj()); - auto_ptr andStage(new AndHashStage(workingSet, matcher, collection)); + unique_ptr andStage(new AndHashStage(workingSet, matcher, collection)); int nodesAdded = 0; BSONObjIterator it(nodeArgs["nodes"].Obj()); @@ -285,7 +285,7 @@ namespace mongo { uassert(16924, "Nodes argument must be provided to AND", nodeArgs["nodes"].isABSONObj()); - auto_ptr andStage(new AndSortedStage(workingSet, matcher, + unique_ptr andStage(new AndSortedStage(workingSet, matcher, collection)); int nodesAdded = 0; @@ -313,7 +313,7 @@ namespace mongo { uassert(16935, "Dedup argument must be provided to OR", !nodeArgs["dedup"].eoo()); BSONObjIterator it(nodeArgs["nodes"].Obj()); - auto_ptr orStage(new OrStage(workingSet, nodeArgs["dedup"].Bool(), + unique_ptr orStage(new OrStage(workingSet, nodeArgs["dedup"].Bool(), matcher)); while (it.more()) { BSONElement e = it.next(); @@ -404,7 +404,7 @@ namespace mongo { params.pattern = nodeArgs["pattern"].Obj(); // Dedup is true by default. - auto_ptr mergeStage(new MergeSortStage(params, workingSet, + unique_ptr mergeStage(new MergeSortStage(params, workingSet, collection)); BSONObjIterator it(nodeArgs["nodes"].Obj()); diff --git a/src/mongo/db/exec/subplan.cpp b/src/mongo/db/exec/subplan.cpp index 364c429429d..386d72eb539 100644 --- a/src/mongo/db/exec/subplan.cpp +++ b/src/mongo/db/exec/subplan.cpp @@ -45,7 +45,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::vector; @@ -238,11 +238,11 @@ namespace mongo { Status SubplanStage::choosePlanForSubqueries(PlanYieldPolicy* yieldPolicy) { // This is what we annotate with the index selections and then turn into a solution. - auto_ptr orExpr( + unique_ptr orExpr( static_cast(_query->root()->shallowClone())); // This is the skeleton of index selections that is inserted into the cache. - auto_ptr cacheData(new PlanCacheIndexTree()); + unique_ptr cacheData(new PlanCacheIndexTree()); for (size_t i = 0; i < orExpr->numChildren(); ++i) { MatchExpression* orChild = orExpr->getChild(i); @@ -537,7 +537,7 @@ namespace mongo { PlanStageStats* SubplanStage::getStats() { _commonStats.isEOF = isEOF(); - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_SUBPLAN)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_SUBPLAN)); ret->children.push_back(_child->getStats()); return ret.release(); } diff --git a/src/mongo/db/exec/text.cpp b/src/mongo/db/exec/text.cpp index 5a62fc9937d..f9db2e94be3 100644 --- a/src/mongo/db/exec/text.cpp +++ b/src/mongo/db/exec/text.cpp @@ -41,7 +41,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::string; using std::vector; @@ -184,7 +184,7 @@ namespace mongo { _commonStats.filter = bob.obj(); } - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_TEXT)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_TEXT)); ret->specific.reset(new TextStats(_specificStats)); return ret.release(); } diff --git a/src/mongo/db/exec/update.cpp b/src/mongo/db/exec/update.cpp index cf26b1ff794..8ba566cd7e0 100644 --- a/src/mongo/db/exec/update.cpp +++ b/src/mongo/db/exec/update.cpp @@ -46,7 +46,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::string; using std::vector; @@ -1060,7 +1060,7 @@ namespace mongo { PlanStageStats* UpdateStage::getStats() { _commonStats.isEOF = isEOF(); - auto_ptr ret(new PlanStageStats(_commonStats, STAGE_UPDATE)); + unique_ptr ret(new PlanStageStats(_commonStats, STAGE_UPDATE)); ret->specific.reset(new UpdateStats(_specificStats)); ret->children.push_back(_child->getStats()); return ret.release(); diff --git a/src/mongo/db/exec/working_set.h b/src/mongo/db/exec/working_set.h index 07fee7fb659..d251f95d5c4 100644 --- a/src/mongo/db/exec/working_set.h +++ b/src/mongo/db/exec/working_set.h @@ -340,7 +340,7 @@ namespace mongo { private: boost::scoped_ptr _computed[WSM_COMPUTED_NUM_TYPES]; - std::auto_ptr _fetcher; + std::unique_ptr _fetcher; }; } // namespace mongo diff --git a/src/mongo/db/field_parser-inl.h b/src/mongo/db/field_parser-inl.h index fd919a42adb..04dbccf9e2a 100644 --- a/src/mongo/db/field_parser-inl.h +++ b/src/mongo/db/field_parser-inl.h @@ -82,7 +82,7 @@ namespace mongo { BSONElement elem = doc[field.name()]; if (elem.eoo()) { if (field.hasDefault()) { - std::auto_ptr temp(new T); + std::unique_ptr temp(new T); field.getDefault()->cloneTo(temp.get()); *out = temp.release(); @@ -98,7 +98,7 @@ namespace mongo { return FIELD_INVALID; } - std::auto_ptr temp(new T); + std::unique_ptr temp(new T); if (!temp->parseBSON(elem.embeddedObject(), errMsg)) { return FIELD_INVALID; } @@ -134,7 +134,7 @@ namespace mongo { return FIELD_INVALID; } - std::auto_ptr temp(new T); + std::unique_ptr temp(new T); if (!temp->parseBSON(elem.embeddedObject(), errMsg)) { return FIELD_INVALID; } @@ -249,7 +249,7 @@ namespace mongo { return FIELD_INVALID; } - std::auto_ptr toInsert(new T); + std::unique_ptr toInsert(new T); if ( !toInsert->parseBSON( next.embeddedObject(), errMsg ) || !toInsert->isValid( errMsg ) ) { @@ -289,7 +289,7 @@ namespace mongo { return FIELD_INVALID; } - std::auto_ptr > tempVector(new std::vector); + std::unique_ptr > tempVector(new std::vector); BSONArray arr = BSONArray(elem.embeddedObject()); BSONObjIterator objIt(arr); @@ -306,7 +306,7 @@ namespace mongo { return FIELD_INVALID; } - std::auto_ptr toInsert(new T); + std::unique_ptr toInsert(new T); if (!toInsert->parseBSON(next.embeddedObject(), errMsg)) { clearOwnedVector(tempVector.get()); return FIELD_INVALID; diff --git a/src/mongo/db/geo/big_polygon.cpp b/src/mongo/db/geo/big_polygon.cpp index eb6540651cb..10241db45dc 100644 --- a/src/mongo/db/geo/big_polygon.cpp +++ b/src/mongo/db/geo/big_polygon.cpp @@ -37,7 +37,7 @@ namespace mongo { using boost::scoped_ptr; - using std::auto_ptr; + using std::unique_ptr; using std::vector; @@ -165,7 +165,7 @@ namespace mongo { if (_borderPoly) return *_borderPoly; - auto_ptr cloned(_loop->Clone()); + unique_ptr cloned(_loop->Clone()); // Any loop in polygon should be than a hemisphere (2*Pi). cloned->Normalize(); diff --git a/src/mongo/db/geo/big_polygon_test.cpp b/src/mongo/db/geo/big_polygon_test.cpp index a8cde9bc909..c0c01abdba7 100644 --- a/src/mongo/db/geo/big_polygon_test.cpp +++ b/src/mongo/db/geo/big_polygon_test.cpp @@ -35,7 +35,7 @@ namespace { using namespace mongo; - using std::auto_ptr; + using std::unique_ptr; using std::string; using std::vector; diff --git a/src/mongo/db/geo/geoparser.cpp b/src/mongo/db/geo/geoparser.cpp index 570b82454c6..95c0f33ac57 100644 --- a/src/mongo/db/geo/geoparser.cpp +++ b/src/mongo/db/geo/geoparser.cpp @@ -44,7 +44,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::stringstream; // This field must be present, and... @@ -287,7 +287,7 @@ namespace mongo { elem.toString(false)); } - auto_ptr loop(new S2Loop(exteriorVertices)); + unique_ptr loop(new S2Loop(exteriorVertices)); // Check whether this loop is valid. if (!loop->IsValid(&err)) { return BAD_VALUE("Loop is not valid: " << elem.toString(false) << " " << err); diff --git a/src/mongo/db/geo/r2_region_coverer_test.cpp b/src/mongo/db/geo/r2_region_coverer_test.cpp index 470d6208e37..e1df6edea77 100644 --- a/src/mongo/db/geo/r2_region_coverer_test.cpp +++ b/src/mongo/db/geo/r2_region_coverer_test.cpp @@ -38,7 +38,7 @@ namespace { - using std::auto_ptr; + using std::unique_ptr; using namespace mongo; using mongo::Polygon; // "windows.h" has another Polygon for Windows GDI. @@ -270,7 +270,7 @@ namespace { coverer.setMaxLevel( coverer.minLevel() + 4 ); double radius = randDouble(0.0, MAXBOUND / 2); - auto_ptr geometry(getRandomCircle(radius)); + unique_ptr geometry(getRandomCircle(radius)); const R2Region& region = geometry->getR2Region(); vector covering; @@ -293,7 +293,7 @@ namespace { // 100 * 2 ^ -32 ~= 2.3E-8 (cell edge length) double radius = randDouble(1E-15, ldexp(100.0, -32) * 10); - auto_ptr geometry(getRandomCircle(radius)); + unique_ptr geometry(getRandomCircle(radius)); const R2Region& region = geometry->getR2Region(); vector covering; diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index bdc5687ef70..8381d244727 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -112,7 +112,7 @@ namespace mongo { using boost::scoped_ptr; using logger::LogComponent; - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::hex; using std::ios; @@ -390,7 +390,7 @@ namespace { DbMessage d(m); QueryMessage q(d); - auto_ptr< Message > resp( new Message() ); + unique_ptr< Message > resp( new Message() ); CurOp& op = *CurOp::get(txn); diff --git a/src/mongo/db/matcher/expression_array_test.cpp b/src/mongo/db/matcher/expression_array_test.cpp index 96a89254a34..891d12752f6 100644 --- a/src/mongo/db/matcher/expression_array_test.cpp +++ b/src/mongo/db/matcher/expression_array_test.cpp @@ -38,13 +38,13 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; TEST( ElemMatchObjectMatchExpression, MatchesElementSingle ) { BSONObj baseOperand = BSON( "b" << 5 ); BSONObj match = BSON( "a" << BSON_ARRAY( BSON( "b" << 5.0 ) ) ); BSONObj notMatch = BSON( "a" << BSON_ARRAY( BSON( "b" << 6 ) ) ); - auto_ptr eq( new EqualityMatchExpression() ); + unique_ptr eq( new EqualityMatchExpression() ); ASSERT( eq->init( "b", baseOperand[ "b" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a", eq.release() ).isOK() ); @@ -56,7 +56,7 @@ namespace mongo { BSONObj baseOperand = BSON( "1" << 5 ); BSONObj match = BSON( "a" << BSON_ARRAY( BSON_ARRAY( 's' << 5.0 ) ) ); BSONObj notMatch = BSON( "a" << BSON_ARRAY( BSON_ARRAY( 5 << 6 ) ) ); - auto_ptr eq( new EqualityMatchExpression() ); + unique_ptr eq( new EqualityMatchExpression() ); ASSERT( eq->init( "1", baseOperand[ "1" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a", eq.release() ).isOK() ); @@ -73,14 +73,14 @@ namespace mongo { BSONObj notMatch3 = BSON( "a" << BSON_ARRAY( BSON( "b" << BSON_ARRAY( 5 << 6 ) ) ) ); BSONObj match = BSON( "a" << BSON_ARRAY( BSON( "b" << BSON_ARRAY( 5 << 6 ) << "c" << 7 ) ) ); - auto_ptr eq1( new EqualityMatchExpression() ); + unique_ptr eq1( new EqualityMatchExpression() ); ASSERT( eq1->init( "b", baseOperand1[ "b" ] ).isOK() ); - auto_ptr eq2( new EqualityMatchExpression() ); + unique_ptr eq2( new EqualityMatchExpression() ); ASSERT( eq2->init( "b", baseOperand2[ "b" ] ).isOK() ); - auto_ptr eq3( new EqualityMatchExpression() ); + unique_ptr eq3( new EqualityMatchExpression() ); ASSERT( eq3->init( "c", baseOperand3[ "c" ] ).isOK() ); - auto_ptr andOp( new AndMatchExpression() ); + unique_ptr andOp( new AndMatchExpression() ); andOp->add( eq1.release() ); andOp->add( eq2.release() ); andOp->add( eq3.release() ); @@ -95,7 +95,7 @@ namespace mongo { TEST( ElemMatchObjectMatchExpression, MatchesNonArray ) { BSONObj baseOperand = BSON( "b" << 5 ); - auto_ptr eq( new EqualityMatchExpression() ); + unique_ptr eq( new EqualityMatchExpression() ); ASSERT( eq->init( "b", baseOperand[ "b" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a", eq.release() ).isOK() ); @@ -108,7 +108,7 @@ namespace mongo { TEST( ElemMatchObjectMatchExpression, MatchesArrayObject ) { BSONObj baseOperand = BSON( "b" << 5 ); - auto_ptr eq( new EqualityMatchExpression() ); + unique_ptr eq( new EqualityMatchExpression() ); ASSERT( eq->init( "b", baseOperand[ "b" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a", eq.release() ).isOK() ); @@ -121,7 +121,7 @@ namespace mongo { TEST( ElemMatchObjectMatchExpression, MatchesMultipleNamedValues ) { BSONObj baseOperand = BSON( "c" << 5 ); - auto_ptr eq( new EqualityMatchExpression() ); + unique_ptr eq( new EqualityMatchExpression() ); ASSERT( eq->init( "c", baseOperand[ "c" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a.b", eq.release() ).isOK() ); @@ -142,7 +142,7 @@ namespace mongo { TEST( ElemMatchObjectMatchExpression, ElemMatchKey ) { BSONObj baseOperand = BSON( "c" << 6 ); - auto_ptr eq( new EqualityMatchExpression() ); + unique_ptr eq( new EqualityMatchExpression() ); ASSERT( eq->init( "c", baseOperand[ "c" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a.b", eq.release() ).isOK() ); @@ -172,7 +172,7 @@ namespace mongo { /** TEST( ElemMatchObjectMatchExpression, MatchesIndexKey ) { BSONObj baseOperand = BSON( "b" << 5 ); - auto_ptr eq( new ComparisonMatchExpression() ); + unique_ptr eq( new ComparisonMatchExpression() ); ASSERT( eq->init( "b", baseOperand[ "b" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a", eq.release() ).isOK() ); @@ -187,7 +187,7 @@ namespace mongo { BSONObj baseOperand = BSON( "$gt" << 5 ); BSONObj match = BSON( "a" << BSON_ARRAY( 6 ) ); BSONObj notMatch = BSON( "a" << BSON_ARRAY( 4 ) ); - auto_ptr gt( new GTMatchExpression() ); + unique_ptr gt( new GTMatchExpression() ); ASSERT( gt->init( "", baseOperand[ "$gt" ] ).isOK() ); ElemMatchValueMatchExpression op; ASSERT( op.init( "a", gt.release() ).isOK() ); @@ -201,9 +201,9 @@ namespace mongo { BSONObj notMatch1 = BSON( "a" << BSON_ARRAY( 0 << 1 ) ); BSONObj notMatch2 = BSON( "a" << BSON_ARRAY( 10 << 11 ) ); BSONObj match = BSON( "a" << BSON_ARRAY( 0 << 5 << 11 ) ); - auto_ptr gt( new GTMatchExpression() ); + unique_ptr gt( new GTMatchExpression() ); ASSERT( gt->init( "", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr lt( new LTMatchExpression() ); + unique_ptr lt( new LTMatchExpression() ); ASSERT( lt->init( "", baseOperand2[ "$lt" ] ).isOK() ); ElemMatchValueMatchExpression op; @@ -218,7 +218,7 @@ namespace mongo { TEST( ElemMatchValueMatchExpression, MatchesNonArray ) { BSONObj baseOperand = BSON( "$gt" << 5 ); - auto_ptr gt( new GTMatchExpression() ); + unique_ptr gt( new GTMatchExpression() ); ASSERT( gt->init( "", baseOperand[ "$gt" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a", gt.release() ).isOK() ); @@ -230,7 +230,7 @@ namespace mongo { TEST( ElemMatchValueMatchExpression, MatchesArrayScalar ) { BSONObj baseOperand = BSON( "$gt" << 5 ); - auto_ptr gt( new GTMatchExpression() ); + unique_ptr gt( new GTMatchExpression() ); ASSERT( gt->init( "", baseOperand[ "$gt" ] ).isOK() ); ElemMatchValueMatchExpression op; ASSERT( op.init( "a", gt.release() ).isOK() ); @@ -241,7 +241,7 @@ namespace mongo { TEST( ElemMatchValueMatchExpression, MatchesMultipleNamedValues ) { BSONObj baseOperand = BSON( "$gt" << 5 ); - auto_ptr gt( new GTMatchExpression() ); + unique_ptr gt( new GTMatchExpression() ); ASSERT( gt->init( "", baseOperand[ "$gt" ] ).isOK() ); ElemMatchValueMatchExpression op; ASSERT( op.init( "a.b", gt.release() ).isOK() ); @@ -254,7 +254,7 @@ namespace mongo { TEST( ElemMatchValueMatchExpression, ElemMatchKey ) { BSONObj baseOperand = BSON( "$gt" << 6 ); - auto_ptr gt( new GTMatchExpression() ); + unique_ptr gt( new GTMatchExpression() ); ASSERT( gt->init( "", baseOperand[ "$gt" ] ).isOK() ); ElemMatchValueMatchExpression op; ASSERT( op.init( "a.b", gt.release() ).isOK() ); @@ -282,7 +282,7 @@ namespace mongo { /** TEST( ElemMatchValueMatchExpression, MatchesIndexKey ) { BSONObj baseOperand = BSON( "$lt" << 5 ); - auto_ptr lt( new ComparisonMatchExpression() ); + unique_ptr lt( new ComparisonMatchExpression() ); ASSERT( lt->init( "a", baseOperand[ "$lt" ] ).isOK() ); ElemMatchValueMatchExpression op; ASSERT( op.init( "a", lt.release() ).isOK() ); @@ -297,40 +297,40 @@ namespace mongo { BSONObj baseOperanda1 = BSON( "a" << 1 ); - auto_ptr eqa1( new EqualityMatchExpression() ); + unique_ptr eqa1( new EqualityMatchExpression() ); ASSERT( eqa1->init( "a", baseOperanda1[ "a" ] ).isOK() ); BSONObj baseOperandb1 = BSON( "b" << 1 ); - auto_ptr eqb1( new EqualityMatchExpression() ); + unique_ptr eqb1( new EqualityMatchExpression() ); ASSERT( eqb1->init( "b", baseOperandb1[ "b" ] ).isOK() ); - auto_ptr and1( new AndMatchExpression() ); + unique_ptr and1( new AndMatchExpression() ); and1->add( eqa1.release() ); and1->add( eqb1.release() ); // and1 = { a : 1, b : 1 } - auto_ptr elemMatch1( new ElemMatchObjectMatchExpression() ); + unique_ptr elemMatch1( new ElemMatchObjectMatchExpression() ); elemMatch1->init( "x", and1.release() ); // elemMatch1 = { x : { $elemMatch : { a : 1, b : 1 } } } BSONObj baseOperanda2 = BSON( "a" << 2 ); - auto_ptr eqa2( new EqualityMatchExpression() ); + unique_ptr eqa2( new EqualityMatchExpression() ); ASSERT( eqa2->init( "a", baseOperanda2[ "a" ] ).isOK() ); BSONObj baseOperandb2 = BSON( "b" << 2 ); - auto_ptr eqb2( new EqualityMatchExpression() ); + unique_ptr eqb2( new EqualityMatchExpression() ); ASSERT( eqb2->init( "b", baseOperandb2[ "b" ] ).isOK() ); - auto_ptr and2( new AndMatchExpression() ); + unique_ptr and2( new AndMatchExpression() ); and2->add( eqa2.release() ); and2->add( eqb2.release() ); // and2 = { a : 2, b : 2 } - auto_ptr elemMatch2( new ElemMatchObjectMatchExpression() ); + unique_ptr elemMatch2( new ElemMatchObjectMatchExpression() ); elemMatch2->init( "x", and2.release() ); // elemMatch2 = { x : { $elemMatch : { a : 2, b : 2 } } } - auto_ptr andOfEM( new AndMatchExpression() ); + unique_ptr andOfEM( new AndMatchExpression() ); andOfEM->add( elemMatch1.release() ); andOfEM->add( elemMatch2.release() ); @@ -354,34 +354,34 @@ namespace mongo { TEST( AndOfElemMatch, Matches ) { BSONObj baseOperandgt1 = BSON( "$gt" << 1 ); - auto_ptr gt1( new GTMatchExpression() ); + unique_ptr gt1( new GTMatchExpression() ); ASSERT( gt1->init( "", baseOperandgt1[ "$gt" ] ).isOK() ); BSONObj baseOperandlt1 = BSON( "$lt" << 10 ); - auto_ptr lt1( new LTMatchExpression() ); + unique_ptr lt1( new LTMatchExpression() ); ASSERT( lt1->init( "", baseOperandlt1[ "$lt" ] ).isOK() ); - auto_ptr elemMatch1( new ElemMatchValueMatchExpression() ); + unique_ptr elemMatch1( new ElemMatchValueMatchExpression() ); elemMatch1->init( "x" ); elemMatch1->add( gt1.release() ); elemMatch1->add( lt1.release() ); // elemMatch1 = { x : { $elemMatch : { $gt : 1 , $lt : 10 } } } BSONObj baseOperandgt2 = BSON( "$gt" << 101 ); - auto_ptr gt2( new GTMatchExpression() ); + unique_ptr gt2( new GTMatchExpression() ); ASSERT( gt2->init( "", baseOperandgt2[ "$gt" ] ).isOK() ); BSONObj baseOperandlt2 = BSON( "$lt" << 110 ); - auto_ptr lt2( new LTMatchExpression() ); + unique_ptr lt2( new LTMatchExpression() ); ASSERT( lt2->init( "", baseOperandlt2[ "$lt" ] ).isOK() ); - auto_ptr elemMatch2( new ElemMatchValueMatchExpression() ); + unique_ptr elemMatch2( new ElemMatchValueMatchExpression() ); elemMatch2->init( "x" ); elemMatch2->add( gt2.release() ); elemMatch2->add( lt2.release() ); // elemMatch2 = { x : { $elemMatch : { $gt : 101 , $lt : 110 } } } - auto_ptr andOfEM( new AndMatchExpression() ); + unique_ptr andOfEM( new AndMatchExpression() ); andOfEM->add( elemMatch1.release() ); andOfEM->add( elemMatch2.release() ); diff --git a/src/mongo/db/matcher/expression_parser.cpp b/src/mongo/db/matcher/expression_parser.cpp index 3564d71a907..b2977e34117 100644 --- a/src/mongo/db/matcher/expression_parser.cpp +++ b/src/mongo/db/matcher/expression_parser.cpp @@ -67,7 +67,7 @@ namespace mongo { StatusWithMatchExpression MatchExpressionParser::_parseComparison( const char* name, ComparisonMatchExpression* cmp, const BSONElement& e ) { - std::auto_ptr temp(cmp); + std::unique_ptr temp(cmp); // Non-equality comparison match expressions cannot have // a regular expression as the argument (e.g. {a: {$gt: /b/}} is illegal). @@ -129,7 +129,7 @@ namespace mongo { StatusWithMatchExpression s = _parseComparison( name, new EqualityMatchExpression(), e ); if ( !s.isOK() ) return s; - std::auto_ptr n( new NotMatchExpression() ); + std::unique_ptr n( new NotMatchExpression() ); Status s2 = n->init( s.getValue() ); if ( !s2.isOK() ) return StatusWithMatchExpression( s2 ); @@ -141,7 +141,7 @@ namespace mongo { case BSONObj::opIN: { if ( e.type() != Array ) return StatusWithMatchExpression( ErrorCodes::BadValue, "$in needs an array" ); - std::auto_ptr temp( new InMatchExpression() ); + std::unique_ptr temp( new InMatchExpression() ); Status s = temp->init( name ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -154,7 +154,7 @@ namespace mongo { case BSONObj::NIN: { if ( e.type() != Array ) return StatusWithMatchExpression( ErrorCodes::BadValue, "$nin needs an array" ); - std::auto_ptr temp( new InMatchExpression() ); + std::unique_ptr temp( new InMatchExpression() ); Status s = temp->init( name ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -162,7 +162,7 @@ namespace mongo { if ( !s.isOK() ) return StatusWithMatchExpression( s ); - std::auto_ptr temp2( new NotMatchExpression() ); + std::unique_ptr temp2( new NotMatchExpression() ); s = temp2->init( temp.release() ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -200,7 +200,7 @@ namespace mongo { return StatusWithMatchExpression( ErrorCodes::BadValue, "$size needs a number" ); } - std::auto_ptr temp( new SizeMatchExpression() ); + std::unique_ptr temp( new SizeMatchExpression() ); Status s = temp->init( name, size ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -210,13 +210,13 @@ namespace mongo { case BSONObj::opEXISTS: { if ( e.eoo() ) return StatusWithMatchExpression( ErrorCodes::BadValue, "$exists can't be eoo" ); - std::auto_ptr temp( new ExistsMatchExpression() ); + std::unique_ptr temp( new ExistsMatchExpression() ); Status s = temp->init( name ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); if ( e.trueValue() ) return StatusWithMatchExpression( temp.release() ); - std::auto_ptr temp2( new NotMatchExpression() ); + std::unique_ptr temp2( new NotMatchExpression() ); s = temp2->init( temp.release() ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -229,7 +229,7 @@ namespace mongo { int type = e.numberInt(); if ( e.type() != NumberInt && type != e.number() ) type = -1; - std::auto_ptr temp( new TypeMatchExpression() ); + std::unique_ptr temp( new TypeMatchExpression() ); Status s = temp->init( name, type ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -281,7 +281,7 @@ namespace mongo { return StatusWithMatchExpression( ErrorCodes::BadValue, ss ); } - std::auto_ptr root( new AndMatchExpression() ); + std::unique_ptr root( new AndMatchExpression() ); bool topLevel = (level == 0); level++; @@ -298,7 +298,7 @@ namespace mongo { if ( e.type() != Array ) return StatusWithMatchExpression( ErrorCodes::BadValue, "$or needs an array" ); - std::auto_ptr temp( new OrMatchExpression() ); + std::unique_ptr temp( new OrMatchExpression() ); Status s = _parseTreeList( e.Obj(), temp.get(), level ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -308,7 +308,7 @@ namespace mongo { if ( e.type() != Array ) return StatusWithMatchExpression( ErrorCodes::BadValue, "and needs an array" ); - std::auto_ptr temp( new AndMatchExpression() ); + std::unique_ptr temp( new AndMatchExpression() ); Status s = _parseTreeList( e.Obj(), temp.get(), level ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -318,7 +318,7 @@ namespace mongo { if ( e.type() != Array ) return StatusWithMatchExpression( ErrorCodes::BadValue, "and needs an array" ); - std::auto_ptr temp( new NorMatchExpression() ); + std::unique_ptr temp( new NorMatchExpression() ); Status s = _parseTreeList( e.Obj(), temp.get(), level ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -355,7 +355,7 @@ namespace mongo { mongoutils::str::equals( "id", rest ) || mongoutils::str::equals( "db", rest ) ) { // DBRef fields. - std::auto_ptr eq( new EqualityMatchExpression() ); + std::unique_ptr eq( new EqualityMatchExpression() ); Status s = eq->init( e.fieldName(), e ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -387,7 +387,7 @@ namespace mongo { continue; } - std::auto_ptr eq( new EqualityMatchExpression() ); + std::unique_ptr eq( new EqualityMatchExpression() ); Status s = eq->init( e.fieldName(), e ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -548,7 +548,7 @@ namespace mongo { if ( i.more() ) return StatusWithMatchExpression( ErrorCodes::BadValue, "malformed mod, too many elements" ); - std::auto_ptr temp( new ModMatchExpression() ); + std::unique_ptr temp( new ModMatchExpression() ); Status s = temp->init( name, d.numberInt(), r.numberInt() ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -560,7 +560,7 @@ namespace mongo { if ( e.type() != RegEx ) return StatusWithMatchExpression( ErrorCodes::BadValue, "not a regex" ); - std::auto_ptr temp( new RegexMatchExpression() ); + std::unique_ptr temp( new RegexMatchExpression() ); Status s = temp->init( name, e.regex(), e.regexFlags() ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -602,7 +602,7 @@ namespace mongo { } - std::auto_ptr temp( new RegexMatchExpression() ); + std::unique_ptr temp( new RegexMatchExpression() ); Status s = temp->init( name, regex, regexOptions ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -623,7 +623,7 @@ namespace mongo { } if ( e.type() == RegEx ) { - std::auto_ptr r( new RegexMatchExpression() ); + std::unique_ptr r( new RegexMatchExpression() ); Status s = r->init( "", e ); if ( !s.isOK() ) return s; @@ -677,7 +677,7 @@ namespace mongo { if ( !s.isOK() ) return StatusWithMatchExpression( s ); - std::auto_ptr temp( new ElemMatchValueMatchExpression() ); + std::unique_ptr temp( new ElemMatchValueMatchExpression() ); s = temp->init( name ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -699,7 +699,7 @@ namespace mongo { StatusWithMatchExpression subRaw = _parse( obj, level ); if ( !subRaw.isOK() ) return subRaw; - std::auto_ptr sub( subRaw.getValue() ); + std::unique_ptr sub( subRaw.getValue() ); // $where is not supported under $elemMatch because $where // applies to top-level document, not array elements in a field. @@ -708,7 +708,7 @@ namespace mongo { "$elemMatch cannot contain $where expression" ); } - std::auto_ptr temp( new ElemMatchObjectMatchExpression() ); + std::unique_ptr temp( new ElemMatchObjectMatchExpression() ); Status status = temp->init( name, sub.release() ); if ( !status.isOK() ) return StatusWithMatchExpression( status ); @@ -723,7 +723,7 @@ namespace mongo { return StatusWithMatchExpression( ErrorCodes::BadValue, "$all needs an array" ); BSONObj arr = e.Obj(); - std::auto_ptr myAnd( new AndMatchExpression() ); + std::unique_ptr myAnd( new AndMatchExpression() ); BSONObjIterator i( arr ); if ( arr.firstElement().type() == Object && @@ -762,7 +762,7 @@ namespace mongo { BSONElement e = i.next(); if ( e.type() == RegEx ) { - std::auto_ptr r( new RegexMatchExpression() ); + std::unique_ptr r( new RegexMatchExpression() ); Status s = r->init( name, e ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -772,7 +772,7 @@ namespace mongo { return StatusWithMatchExpression( ErrorCodes::BadValue, "no $ expressions in $all" ); } else { - std::auto_ptr x( new EqualityMatchExpression() ); + std::unique_ptr x( new EqualityMatchExpression() ); Status s = x->init( name, e ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); diff --git a/src/mongo/db/matcher/expression_parser_geo.cpp b/src/mongo/db/matcher/expression_parser_geo.cpp index 72145c029b1..837d61b448c 100644 --- a/src/mongo/db/matcher/expression_parser_geo.cpp +++ b/src/mongo/db/matcher/expression_parser_geo.cpp @@ -37,18 +37,18 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; StatusWithMatchExpression expressionParserGeoCallbackReal( const char* name, int type, const BSONObj& section ) { if (BSONObj::opWITHIN == type || BSONObj::opGEO_INTERSECTS == type) { - auto_ptr gq(new GeoExpression(name)); + unique_ptr gq(new GeoExpression(name)); Status parseStatus = gq->parseFrom(section); if (!parseStatus.isOK()) return StatusWithMatchExpression(parseStatus); - auto_ptr e( new GeoMatchExpression() ); + unique_ptr e( new GeoMatchExpression() ); // Until the index layer accepts non-BSON predicates, or special indices are moved into // stages, we have to clean up the raw object so it can be passed down to the index @@ -62,12 +62,12 @@ namespace mongo { } else { verify(BSONObj::opNEAR == type); - auto_ptr nq(new GeoNearExpression(name)); + unique_ptr nq(new GeoNearExpression(name)); Status s = nq->parseFrom( section ); if ( !s.isOK() ) { return StatusWithMatchExpression( s ); } - auto_ptr e( new GeoNearMatchExpression() ); + unique_ptr e( new GeoNearMatchExpression() ); // Until the index layer accepts non-BSON predicates, or special indices are moved into // stages, we have to clean up the raw object so it can be passed down to the index // layer. diff --git a/src/mongo/db/matcher/expression_parser_text.cpp b/src/mongo/db/matcher/expression_parser_text.cpp index 0a7cb0b01ab..f8b40a1823b 100644 --- a/src/mongo/db/matcher/expression_parser_text.cpp +++ b/src/mongo/db/matcher/expression_parser_text.cpp @@ -37,7 +37,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::string; StatusWithMatchExpression expressionParserTextCallbackReal( const BSONObj& queryObj ) { @@ -84,7 +84,7 @@ namespace mongo { return StatusWithMatchExpression( ErrorCodes::BadValue, "extra fields in $text" ); } - auto_ptr e( new TextMatchExpression() ); + unique_ptr e( new TextMatchExpression() ); Status s = e->init( query, language, caseSensitive ); if ( !s.isOK() ) { return StatusWithMatchExpression( s ); diff --git a/src/mongo/db/matcher/expression_parser_tree.cpp b/src/mongo/db/matcher/expression_parser_tree.cpp index 8e2582e52e0..7c5359e6318 100644 --- a/src/mongo/db/matcher/expression_parser_tree.cpp +++ b/src/mongo/db/matcher/expression_parser_tree.cpp @@ -73,7 +73,7 @@ namespace mongo { StatusWithMatchExpression s = _parseRegexElement( name, e ); if ( !s.isOK() ) return s; - std::auto_ptr n( new NotMatchExpression() ); + std::unique_ptr n( new NotMatchExpression() ); Status s2 = n->init( s.getValue() ); if ( !s2.isOK() ) return StatusWithMatchExpression( s2 ); @@ -87,7 +87,7 @@ namespace mongo { if ( notObject.isEmpty() ) return StatusWithMatchExpression( ErrorCodes::BadValue, "$not cannot be empty" ); - std::auto_ptr theAnd( new AndMatchExpression() ); + std::unique_ptr theAnd( new AndMatchExpression() ); Status s = _parseSub( name, notObject, theAnd.get(), level ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -98,7 +98,7 @@ namespace mongo { if ( theAnd->getChild(i)->matchType() == MatchExpression::REGEX ) return StatusWithMatchExpression( ErrorCodes::BadValue, "$not cannot have a regex" ); - std::auto_ptr theNot( new NotMatchExpression() ); + std::unique_ptr theNot( new NotMatchExpression() ); s = theNot->init( theAnd.release() ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); diff --git a/src/mongo/db/matcher/expression_tree.h b/src/mongo/db/matcher/expression_tree.h index b0caebd1e71..b6441e70f57 100644 --- a/src/mongo/db/matcher/expression_tree.h +++ b/src/mongo/db/matcher/expression_tree.h @@ -190,7 +190,7 @@ namespace mongo { void resetChild( MatchExpression* newChild) { _exp.reset(newChild); } private: - std::auto_ptr _exp; + std::unique_ptr _exp; }; } diff --git a/src/mongo/db/matcher/expression_tree_test.cpp b/src/mongo/db/matcher/expression_tree_test.cpp index 27516ff4344..72e9766404a 100644 --- a/src/mongo/db/matcher/expression_tree_test.cpp +++ b/src/mongo/db/matcher/expression_tree_test.cpp @@ -38,11 +38,11 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; TEST( NotMatchExpression, MatchesScalar ) { BSONObj baseOperand = BSON( "$lt" << 5 ); - auto_ptr lt( new LTMatchExpression() ); + unique_ptr lt( new LTMatchExpression() ); ASSERT( lt->init( "a", baseOperand[ "$lt" ] ).isOK() ); NotMatchExpression notOp; ASSERT( notOp.init( lt.release() ).isOK() ); @@ -52,7 +52,7 @@ namespace mongo { TEST( NotMatchExpression, MatchesArray ) { BSONObj baseOperand = BSON( "$lt" << 5 ); - auto_ptr lt( new LTMatchExpression() ); + unique_ptr lt( new LTMatchExpression() ); ASSERT( lt->init( "a", baseOperand[ "$lt" ] ).isOK() ); NotMatchExpression notOp; ASSERT( notOp.init( lt.release() ).isOK() ); @@ -64,7 +64,7 @@ namespace mongo { TEST( NotMatchExpression, ElemMatchKey ) { BSONObj baseOperand = BSON( "$lt" << 5 ); - auto_ptr lt( new LTMatchExpression() ); + unique_ptr lt( new LTMatchExpression() ); ASSERT( lt->init( "a", baseOperand[ "$lt" ] ).isOK() ); NotMatchExpression notOp; ASSERT( notOp.init( lt.release() ).isOK() ); @@ -81,7 +81,7 @@ namespace mongo { /* TEST( NotMatchExpression, MatchesIndexKey ) { BSONObj baseOperand = BSON( "$lt" << 5 ); - auto_ptr lt( new ComparisonMatchExpression() ); + unique_ptr lt( new ComparisonMatchExpression() ); ASSERT( lt->init( "a", baseOperand[ "$lt" ] ).isOK() ); NotMatchExpression notOp; ASSERT( notOp.init( lt.release() ).isOK() ); @@ -97,7 +97,7 @@ namespace mongo { BSONObj baseOperand = BSON( "$lt" << 5 ); BSONObj match = BSON( "a" << 4 ); BSONObj notMatch = BSON( "a" << 5 ); - auto_ptr lt( new ComparisonMatchExpression() ); + unique_ptr lt( new ComparisonMatchExpression() ); ASSERT( lt->init( "", baseOperand[ "$lt" ] ).isOK() ); OwnedPointerVector subMatchExpressions; subMatchExpressions.mutableVector().push_back( lt.release() ); @@ -121,11 +121,11 @@ namespace mongo { BSONObj notMatch2 = BSON( "a" << "a1" ); BSONObj notMatch3 = BSON( "a" << "r" ); - auto_ptr sub1( new LTMatchExpression() ); + unique_ptr sub1( new LTMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$lt" ] ).isOK() ); - auto_ptr sub2( new GTMatchExpression() ); + unique_ptr sub2( new GTMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$gt" ] ).isOK() ); - auto_ptr sub3( new RegexMatchExpression() ); + unique_ptr sub3( new RegexMatchExpression() ); ASSERT( sub3->init( "a", "1", "" ).isOK() ); AndMatchExpression andOp; @@ -141,9 +141,9 @@ namespace mongo { TEST( AndOp, MatchesSingleClause ) { BSONObj baseOperand = BSON( "$ne" << 5 ); - auto_ptr eq( new EqualityMatchExpression() ); + unique_ptr eq( new EqualityMatchExpression() ); ASSERT( eq->init( "a", baseOperand[ "$ne" ] ).isOK() ); - auto_ptr ne( new NotMatchExpression() ); + unique_ptr ne( new NotMatchExpression() ); ASSERT( ne->init( eq.release() ).isOK() ); AndMatchExpression andOp; @@ -160,13 +160,13 @@ namespace mongo { BSONObj baseOperand2 = BSON( "$lt" << 10 ); BSONObj baseOperand3 = BSON( "$lt" << 100 ); - auto_ptr sub1( new GTMatchExpression() ); + unique_ptr sub1( new GTMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr sub2( new LTMatchExpression() ); + unique_ptr sub2( new LTMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$lt" ] ).isOK() ); - auto_ptr sub3( new LTMatchExpression() ); + unique_ptr sub3( new LTMatchExpression() ); ASSERT( sub3->init( "b", baseOperand3[ "$lt" ] ).isOK() ); AndMatchExpression andOp; @@ -185,10 +185,10 @@ namespace mongo { BSONObj baseOperand1 = BSON( "a" << 1 ); BSONObj baseOperand2 = BSON( "b" << 2 ); - auto_ptr sub1( new EqualityMatchExpression() ); + unique_ptr sub1( new EqualityMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "a" ] ).isOK() ); - auto_ptr sub2( new EqualityMatchExpression() ); + unique_ptr sub2( new EqualityMatchExpression() ); ASSERT( sub2->init( "b", baseOperand2[ "b" ] ).isOK() ); AndMatchExpression andOp; @@ -212,9 +212,9 @@ namespace mongo { TEST( AndOp, MatchesIndexKeyWithoutUnknown ) { BSONObj baseOperand1 = BSON( "$gt" << 1 ); BSONObj baseOperand2 = BSON( "$lt" << 5 ); - auto_ptr sub1( new ComparisonMatchExpression() ); + unique_ptr sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr sub2( new ComparisonMatchExpression() ); + unique_ptr sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$lt" ] ).isOK() ); OwnedPointerVector subMatchExpressions; subMatchExpressions.mutableVector().push_back( sub1.release() ); @@ -235,11 +235,11 @@ namespace mongo { BSONObj baseOperand2 = BSON( "$lt" << 5 ); // This part will return PartialMatchResult_Unknown. BSONObj baseOperand3 = BSON( "$ne" << 5 ); - auto_ptr sub1( new ComparisonMatchExpression() ); + unique_ptr sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr sub2( new ComparisonMatchExpression() ); + unique_ptr sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$lt" ] ).isOK() ); - auto_ptr sub3( new NeOp() ); + unique_ptr sub3( new NeOp() ); ASSERT( sub3->init( "a", baseOperand3[ "$ne" ] ).isOK() ); OwnedPointerVector subMatchExpressions; subMatchExpressions.mutableVector().push_back( sub1.release() ); @@ -262,7 +262,7 @@ namespace mongo { BSONObj baseOperand = BSON( "$lt" << 5 ); BSONObj match = BSON( "a" << 4 ); BSONObj notMatch = BSON( "a" << 5 ); - auto_ptr lt( new ComparisonMatchExpression() ); + unique_ptr lt( new ComparisonMatchExpression() ); ASSERT( lt->init( "a", baseOperand[ "$lt" ] ).isOK() ); OwnedPointerVector subMatchExpressions; subMatchExpressions.mutableVector().push_back( lt.release() ); @@ -286,11 +286,11 @@ namespace mongo { BSONObj match2 = BSON( "a" << 11 ); BSONObj match3 = BSON( "a" << 5 ); BSONObj notMatch = BSON( "a" << "6" ); - auto_ptr sub1( new ComparisonMatchExpression() ); + unique_ptr sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$lt" ] ).isOK() ); - auto_ptr sub2( new ComparisonMatchExpression() ); + unique_ptr sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$gt" ] ).isOK() ); - auto_ptr sub3( new ComparisonMatchExpression() ); + unique_ptr sub3( new ComparisonMatchExpression() ); ASSERT( sub3->init( "a", baseOperand3[ "a" ] ).isOK() ); OwnedPointerVector subMatchExpressions; subMatchExpressions.mutableVector().push_back( sub1.release() ); @@ -306,9 +306,9 @@ namespace mongo { */ TEST( OrOp, MatchesSingleClause ) { BSONObj baseOperand = BSON( "$ne" << 5 ); - auto_ptr eq( new EqualityMatchExpression() ); + unique_ptr eq( new EqualityMatchExpression() ); ASSERT( eq->init( "a", baseOperand[ "$ne" ] ).isOK() ); - auto_ptr ne( new NotMatchExpression() ); + unique_ptr ne( new NotMatchExpression() ); ASSERT( ne->init( eq.release() ).isOK() ); OrMatchExpression orOp; @@ -324,11 +324,11 @@ namespace mongo { BSONObj baseOperand1 = BSON( "$gt" << 10 ); BSONObj baseOperand2 = BSON( "$lt" << 0 ); BSONObj baseOperand3 = BSON( "b" << 100 ); - auto_ptr sub1( new GTMatchExpression() ); + unique_ptr sub1( new GTMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr sub2( new LTMatchExpression() ); + unique_ptr sub2( new LTMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$lt" ] ).isOK() ); - auto_ptr sub3( new EqualityMatchExpression() ); + unique_ptr sub3( new EqualityMatchExpression() ); ASSERT( sub3->init( "b", baseOperand3[ "b" ] ).isOK() ); OrMatchExpression orOp; @@ -348,9 +348,9 @@ namespace mongo { TEST( OrOp, ElemMatchKey ) { BSONObj baseOperand1 = BSON( "a" << 1 ); BSONObj baseOperand2 = BSON( "b" << 2 ); - auto_ptr sub1( new EqualityMatchExpression() ); + unique_ptr sub1( new EqualityMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "a" ] ).isOK() ); - auto_ptr sub2( new EqualityMatchExpression() ); + unique_ptr sub2( new EqualityMatchExpression() ); ASSERT( sub2->init( "b", baseOperand2[ "b" ] ).isOK() ); OrMatchExpression orOp; @@ -374,9 +374,9 @@ namespace mongo { TEST( OrOp, MatchesIndexKeyWithoutUnknown ) { BSONObj baseOperand1 = BSON( "$gt" << 5 ); BSONObj baseOperand2 = BSON( "$lt" << 1 ); - auto_ptr sub1( new ComparisonMatchExpression() ); + unique_ptr sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr sub2( new ComparisonMatchExpression() ); + unique_ptr sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$lt" ] ).isOK() ); OwnedPointerVector subMatchExpressions; subMatchExpressions.mutableVector().push_back( sub1.release() ); @@ -397,11 +397,11 @@ namespace mongo { BSONObj baseOperand2 = BSON( "$lt" << 1 ); // This part will return PartialMatchResult_Unknown. BSONObj baseOperand3 = BSON( "$ne" << 5 ); - auto_ptr sub1( new ComparisonMatchExpression() ); + unique_ptr sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr sub2( new ComparisonMatchExpression() ); + unique_ptr sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$lt" ] ).isOK() ); - auto_ptr sub3( new NeOp() ); + unique_ptr sub3( new NeOp() ); ASSERT( sub3->init( "a", baseOperand3[ "$ne" ] ).isOK() ); OwnedPointerVector subMatchExpressions; subMatchExpressions.mutableVector().push_back( sub1.release() ); @@ -424,7 +424,7 @@ namespace mongo { BSONObj baseOperand = BSON( "$lt" << 5 ); BSONObj match = BSON( "a" << 5 ); BSONObj notMatch = BSON( "a" << 4 ); - auto_ptr lt( new ComparisonMatchExpression() ); + unique_ptr lt( new ComparisonMatchExpression() ); ASSERT( lt->init( "a", baseOperand[ "$lt" ] ).isOK() ); OwnedPointerVector subMatchExpressions; subMatchExpressions.mutableVector().push_back( lt.release() ); @@ -448,11 +448,11 @@ namespace mongo { BSONObj notMatch2 = BSON( "a" << 11 ); BSONObj notMatch3 = BSON( "a" << 5 ); BSONObj match = BSON( "a" << "6" ); - auto_ptr sub1( new ComparisonMatchExpression() ); + unique_ptr sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$lt" ] ).isOK() ); - auto_ptr sub2( new ComparisonMatchExpression() ); + unique_ptr sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$gt" ] ).isOK() ); - auto_ptr sub3( new ComparisonMatchExpression() ); + unique_ptr sub3( new ComparisonMatchExpression() ); ASSERT( sub3->init( "a", baseOperand3[ "a" ] ).isOK() ); OwnedPointerVector subMatchExpressions; subMatchExpressions.mutableVector().push_back( sub1.release() ); @@ -469,9 +469,9 @@ namespace mongo { TEST( NorOp, MatchesSingleClause ) { BSONObj baseOperand = BSON( "$ne" << 5 ); - auto_ptr eq( new EqualityMatchExpression() ); + unique_ptr eq( new EqualityMatchExpression() ); ASSERT( eq->init( "a", baseOperand[ "$ne" ] ).isOK() ); - auto_ptr ne( new NotMatchExpression() ); + unique_ptr ne( new NotMatchExpression() ); ASSERT( ne->init( eq.release() ).isOK() ); NorMatchExpression norOp; @@ -488,11 +488,11 @@ namespace mongo { BSONObj baseOperand2 = BSON( "$lt" << 0 ); BSONObj baseOperand3 = BSON( "b" << 100 ); - auto_ptr sub1( new GTMatchExpression() ); + unique_ptr sub1( new GTMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr sub2( new LTMatchExpression() ); + unique_ptr sub2( new LTMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$lt" ] ).isOK() ); - auto_ptr sub3( new EqualityMatchExpression() ); + unique_ptr sub3( new EqualityMatchExpression() ); ASSERT( sub3->init( "b", baseOperand3[ "b" ] ).isOK() ); NorMatchExpression norOp; @@ -512,9 +512,9 @@ namespace mongo { TEST( NorOp, ElemMatchKey ) { BSONObj baseOperand1 = BSON( "a" << 1 ); BSONObj baseOperand2 = BSON( "b" << 2 ); - auto_ptr sub1( new EqualityMatchExpression() ); + unique_ptr sub1( new EqualityMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "a" ] ).isOK() ); - auto_ptr sub2( new EqualityMatchExpression() ); + unique_ptr sub2( new EqualityMatchExpression() ); ASSERT( sub2->init( "b", baseOperand2[ "b" ] ).isOK() ); NorMatchExpression norOp; @@ -557,7 +557,7 @@ namespace mongo { /** TEST( NorOp, MatchesIndexKey ) { BSONObj baseOperand = BSON( "a" << 5 ); - auto_ptr eq( new ComparisonMatchExpression() ); + unique_ptr eq( new ComparisonMatchExpression() ); ASSERT( eq->init( "a", baseOperand[ "a" ] ).isOK() ); OwnedPointerVector subMatchExpressions; subMatchExpressions.mutableVector().push_back( eq.release() ); diff --git a/src/mongo/db/matcher/expression_where.cpp b/src/mongo/db/matcher/expression_where.cpp index c2e95e2dd50..290b2bc3071 100644 --- a/src/mongo/db/matcher/expression_where.cpp +++ b/src/mongo/db/matcher/expression_where.cpp @@ -42,7 +42,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::string; using std::stringstream; @@ -91,7 +91,7 @@ namespace mongo { string _code; BSONObj _userScope; - auto_ptr _scope; + unique_ptr _scope; ScriptingFunction _func; // Not owned. See comments insde WhereCallbackReal for the lifetime of this pointer. @@ -191,7 +191,7 @@ namespace mongo { return StatusWithMatchExpression(ErrorCodes::BadValue, "no globalScriptEngine in $where parsing"); - auto_ptr exp(new WhereMatchExpression(_txn)); + unique_ptr exp(new WhereMatchExpression(_txn)); if (where.type() == String || where.type() == Code) { Status s = exp->init(_dbName, where.valuestr(), BSONObj()); if (!s.isOK()) diff --git a/src/mongo/db/matcher/expression_where_noop.cpp b/src/mongo/db/matcher/expression_where_noop.cpp index dfb6a694c28..d7f5a3c74e1 100644 --- a/src/mongo/db/matcher/expression_where_noop.cpp +++ b/src/mongo/db/matcher/expression_where_noop.cpp @@ -35,7 +35,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::string; /** @@ -118,7 +118,7 @@ namespace mongo { StatusWithMatchExpression WhereCallbackNoop::parseWhere(const BSONElement& where) const { - auto_ptr exp( new WhereNoOpMatchExpression() ); + unique_ptr exp( new WhereNoOpMatchExpression() ); if ( where.type() == String || where.type() == Code ) { Status s = exp->init( where.valuestr() ); if ( !s.isOK() ) diff --git a/src/mongo/db/operation_context_impl.h b/src/mongo/db/operation_context_impl.h index 39fbd95e43f..163bff53295 100644 --- a/src/mongo/db/operation_context_impl.h +++ b/src/mongo/db/operation_context_impl.h @@ -65,7 +65,7 @@ namespace mongo { virtual bool writesAreReplicated() const override; private: - std::auto_ptr _recovery; + std::unique_ptr _recovery; bool _writesAreReplicated; }; diff --git a/src/mongo/db/operation_context_noop.h b/src/mongo/db/operation_context_noop.h index 0ee7c2001ca..055c83d690c 100644 --- a/src/mongo/db/operation_context_noop.h +++ b/src/mongo/db/operation_context_noop.h @@ -112,7 +112,7 @@ namespace mongo { } private: - std::auto_ptr _recoveryUnit; + std::unique_ptr _recoveryUnit; boost::scoped_ptr _locker; ProgressMeter _pm; }; diff --git a/src/mongo/db/ops/modifier_table_test.cpp b/src/mongo/db/ops/modifier_table_test.cpp index 23f568b1981..239f9eb5a34 100644 --- a/src/mongo/db/ops/modifier_table_test.cpp +++ b/src/mongo/db/ops/modifier_table_test.cpp @@ -38,7 +38,7 @@ namespace { using namespace mongo::modifiertable; using mongo::ModifierInterface; - using std::auto_ptr; + using std::unique_ptr; TEST(getType, Normal) { ASSERT_EQUALS(getType("$set"), MOD_SET); @@ -47,7 +47,7 @@ namespace { } TEST(makeUpdateMod, Normal) { - auto_ptr mod; + unique_ptr mod; mod.reset(makeUpdateMod(MOD_SET)); ASSERT_NOT_EQUALS(mod.get(), static_cast(0)); diff --git a/src/mongo/db/ops/parsed_delete.h b/src/mongo/db/ops/parsed_delete.h index ad473d35e91..c65f0da69e9 100644 --- a/src/mongo/db/ops/parsed_delete.h +++ b/src/mongo/db/ops/parsed_delete.h @@ -111,7 +111,7 @@ namespace mongo { const DeleteRequest* const _request; // Parsed query object, or NULL if the query proves to be an id hack query. - std::auto_ptr _canonicalQuery; + std::unique_ptr _canonicalQuery; }; diff --git a/src/mongo/db/ops/parsed_update.h b/src/mongo/db/ops/parsed_update.h index 98472eba377..d109904d1bd 100644 --- a/src/mongo/db/ops/parsed_update.h +++ b/src/mongo/db/ops/parsed_update.h @@ -129,7 +129,7 @@ namespace mongo { UpdateDriver _driver; // Parsed query object, or NULL if the query proves to be an id hack query. - std::auto_ptr _canonicalQuery; + std::unique_ptr _canonicalQuery; }; } // namespace mongo diff --git a/src/mongo/db/ops/path_support_test.cpp b/src/mongo/db/ops/path_support_test.cpp index 7a93d73c269..a502a39a0c3 100644 --- a/src/mongo/db/ops/path_support_test.cpp +++ b/src/mongo/db/ops/path_support_test.cpp @@ -53,7 +53,7 @@ namespace { using namespace mutablebson; using namespace pathsupport; using mongoutils::str::stream; - using std::auto_ptr; + using std::unique_ptr; using std::string; class EmptyDoc : public mongo::unittest::Test { @@ -487,7 +487,7 @@ namespace { TEST(ExtractEqualities, Basic) { BSONObj exprBSON = fromjson("{a:1}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -497,7 +497,7 @@ namespace { TEST(ExtractEqualities, Multiple) { BSONObj exprBSON = fromjson("{a:1, b:2}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -508,7 +508,7 @@ namespace { TEST(ExtractEqualities, EqOperator) { BSONObj exprBSON = fromjson("{a:{$eq:1}}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -518,7 +518,7 @@ namespace { TEST(ExtractEqualities, AndOperator) { BSONObj exprBSON = fromjson("{$and:[{a:{$eq:1}},{b:2}]}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -529,7 +529,7 @@ namespace { TEST(ExtractEqualities, NestedAndOperator) { BSONObj exprBSON = fromjson("{$and:[{$and:[{a:{$eq:1}},{b:2}]},{c:3}]}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -541,7 +541,7 @@ namespace { TEST(ExtractEqualities, NestedPaths) { BSONObj exprBSON = fromjson("{'a.a':1}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -551,7 +551,7 @@ namespace { TEST(ExtractEqualities, SiblingPaths) { BSONObj exprBSON = fromjson("{'a.a':1,'a.b':{$eq:2}}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -562,7 +562,7 @@ namespace { TEST(ExtractEqualities, NestedAndNestedPaths) { BSONObj exprBSON = fromjson("{$and:[{$and:[{'a.a':{$eq:1}},{'a.b':2}]},{'c.c.c':3}]}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -574,7 +574,7 @@ namespace { TEST(ExtractEqualities, IdOnly) { BSONObj exprBSON = fromjson("{_id:1}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -607,7 +607,7 @@ namespace { TEST(ExtractEqualities, IdOnlyMulti) { BSONObj exprBSON = fromjson("{_id:{$eq:1},a:1}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); ImmutablePaths immutablePaths; immutablePaths.addPath("_id"); @@ -620,7 +620,7 @@ namespace { TEST(ExtractEqualities, IdOnlyIgnoreConflict) { BSONObj exprBSON = fromjson("{_id:1,a:1,'a.b':1}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); ImmutablePaths immutablePaths; immutablePaths.addPath("_id"); @@ -633,7 +633,7 @@ namespace { TEST(ExtractEqualities, IdOnlyNested) { BSONObj exprBSON = fromjson("{'_id.a':1,'_id.b':{$eq:2},c:3}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); ImmutablePaths immutablePaths; immutablePaths.addPath("_id"); @@ -645,7 +645,7 @@ namespace { TEST(ExtractEqualities, IdAndOtherImmutable) { BSONObj exprBSON = fromjson("{_id:1,a:1,b:2}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); ImmutablePaths immutablePaths; immutablePaths.addPath("_id"); @@ -660,7 +660,7 @@ namespace { TEST(ExtractEqualities, IdAndNestedImmutable) { BSONObj exprBSON = fromjson("{_id:1,a:1,'c.d':3}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); ImmutablePaths immutablePaths; immutablePaths.addPath("_id"); @@ -677,7 +677,7 @@ namespace { TEST(ExtractEqualities, NonFullImmutable) { BSONObj exprBSON = fromjson("{'a.b':1}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); ImmutablePaths immutablePaths; immutablePaths.addPath("a"); @@ -689,7 +689,7 @@ namespace { TEST(ExtractEqualities, Empty) { BSONObj exprBSON = fromjson("{'':0}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -699,7 +699,7 @@ namespace { TEST(ExtractEqualities, EmptyMulti) { BSONObj exprBSON = fromjson("{'':0,a:{$eq:1}}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -710,7 +710,7 @@ namespace { TEST(ExtractEqualities, EqConflict) { BSONObj exprBSON = fromjson("{a:1,a:1}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_EQUALS(extractEqualityMatches(*expr, &equalities).code(), @@ -719,7 +719,7 @@ namespace { TEST(ExtractEqualities, PrefixConflict) { BSONObj exprBSON = fromjson("{a:1,'a.b':{$eq:1}}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_EQUALS(extractEqualityMatches(*expr, &equalities).code(), @@ -728,7 +728,7 @@ namespace { TEST(ExtractEqualities, AndPrefixConflict) { BSONObj exprBSON = fromjson("{$and:[{a:1},{'a.b':{$eq:1}}]}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_EQUALS(extractEqualityMatches(*expr, &equalities).code(), @@ -737,7 +737,7 @@ namespace { TEST(ExtractEqualities, EmptyConflict) { BSONObj exprBSON = fromjson("{'':0,'':{$eq:0}}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_EQUALS(extractEqualityMatches(*expr, &equalities).code(), @@ -803,7 +803,7 @@ namespace { TEST(FindParentEquality, Basic) { BSONObj exprBSON = fromjson("{a:1}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -815,7 +815,7 @@ namespace { TEST(FindParentEquality, Multi) { BSONObj exprBSON = fromjson("{a:1,b:2}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -829,7 +829,7 @@ namespace { TEST(FindParentEquality, Nested) { BSONObj exprBSON = fromjson("{'a.a':1}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -842,7 +842,7 @@ namespace { TEST(FindParentEquality, NestedMulti) { BSONObj exprBSON = fromjson("{'a.a':1,'a.b':2,'c.c':3}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -860,7 +860,7 @@ namespace { TEST(FindParentEquality, Empty) { BSONObj exprBSON = fromjson("{'':0}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); @@ -870,7 +870,7 @@ namespace { TEST(FindParentEquality, EmptyMulti) { BSONObj exprBSON = fromjson("{'':0,a:1}"); - auto_ptr expr(makeExpr(exprBSON)); + unique_ptr expr(makeExpr(exprBSON)); EqualityMatches equalities; ASSERT_OK(extractEqualityMatches(*expr, &equalities)); diff --git a/src/mongo/db/ops/update_driver.cpp b/src/mongo/db/ops/update_driver.cpp index c1235c8b93e..b5737419dad 100644 --- a/src/mongo/db/ops/update_driver.cpp +++ b/src/mongo/db/ops/update_driver.cpp @@ -49,7 +49,7 @@ namespace mongo { namespace mb = mongo::mutablebson; using boost::scoped_ptr; - using std::auto_ptr; + using std::unique_ptr; using std::vector; using pathsupport::EqualityMatches; @@ -81,7 +81,7 @@ namespace mongo { // definition, an object. We wrap the 'updateExpr' as the mod is expecting. Note // that the wrapper is temporary so the object replace mod should make a copy of // the object. - auto_ptr mod(new ModifierObjectReplace); + unique_ptr mod(new ModifierObjectReplace); BSONObj wrapper = BSON( "dummy" << updateExpr ); Status status = mod->init(wrapper.firstElement(), _modOptions); if (!status.isOK()) { @@ -153,7 +153,7 @@ namespace mongo { << " which is not allowed for any $" << type << " mod."); } - auto_ptr mod(modifiertable::makeUpdateMod(type)); + unique_ptr mod(modifiertable::makeUpdateMod(type)); dassert(mod.get()); bool positional = false; diff --git a/src/mongo/db/query/canonical_query.cpp b/src/mongo/db/query/canonical_query.cpp index fa8a407fa20..d50b46ae087 100644 --- a/src/mongo/db/query/canonical_query.cpp +++ b/src/mongo/db/query/canonical_query.cpp @@ -211,7 +211,7 @@ namespace { Status CanonicalQuery::canonicalize(LiteParsedQuery* lpq, CanonicalQuery** out, const MatchExpressionParser::WhereCallback& whereCallback) { - std::auto_ptr autoLpq(lpq); + std::unique_ptr autoLpq(lpq); // Make MatchExpression. StatusWithMatchExpression swme = MatchExpressionParser::parse(autoLpq->getFilter(), @@ -221,7 +221,7 @@ namespace { } // Make the CQ we'll hopefully return. - std::auto_ptr cq(new CanonicalQuery()); + std::unique_ptr cq(new CanonicalQuery()); // Takes ownership of lpq and the MatchExpression* in swme. Status initStatus = cq->init(autoLpq.release(), whereCallback, swme.getValue()); @@ -254,7 +254,7 @@ namespace { } // Make the CQ we'll hopefully return. - std::auto_ptr cq(new CanonicalQuery()); + std::unique_ptr cq(new CanonicalQuery()); Status initStatus = cq->init(lpq, whereCallback, root->shallowClone()); if (!initStatus.isOK()) { return initStatus; } @@ -285,7 +285,7 @@ namespace { if (!parseStatus.isOK()) { return parseStatus; } - std::auto_ptr lpq(lpqRaw); + std::unique_ptr lpq(lpqRaw); // Build a parse tree from the BSONObj in the parsed query. StatusWithMatchExpression swme = @@ -295,7 +295,7 @@ namespace { } // Make the CQ we'll hopefully return. - std::auto_ptr cq(new CanonicalQuery()); + std::unique_ptr cq(new CanonicalQuery()); // Takes ownership of lpq and the MatchExpression* in swme. Status initStatus = cq->init(lpq.release(), whereCallback, swme.getValue()); diff --git a/src/mongo/db/query/canonical_query_test.cpp b/src/mongo/db/query/canonical_query_test.cpp index de2675940c7..13f5f60299c 100644 --- a/src/mongo/db/query/canonical_query_test.cpp +++ b/src/mongo/db/query/canonical_query_test.cpp @@ -35,7 +35,7 @@ using namespace mongo; namespace { - using std::auto_ptr; + using std::unique_ptr; using std::string; using std::unique_ptr; @@ -104,9 +104,9 @@ namespace { false, // snapshot false, // explain &lpqRaw)); - auto_ptr lpq(lpqRaw); + unique_ptr lpq(lpqRaw); - auto_ptr me; + unique_ptr me; // Valid: regular TEXT. auto swme = parseNormalize("{$text: {$search: 's'}}"); @@ -190,9 +190,9 @@ namespace { false, // snapshot false, // explain &lpqRaw)); - auto_ptr lpq(lpqRaw); + unique_ptr lpq(lpqRaw); - auto_ptr me; + unique_ptr me; // Valid: regular GEO_NEAR. auto swme = parseNormalize("{a: {$near: [0, 0]}}"); @@ -286,9 +286,9 @@ namespace { false, // snapshot false, // explain &lpqRaw)); - auto_ptr lpq(lpqRaw); + unique_ptr lpq(lpqRaw); - auto_ptr me; + unique_ptr me; // Invalid: TEXT and GEO_NEAR. auto swme = parseNormalize("{$text: {$search: 's'}, a: {$near: [0, 0]}}"); @@ -326,9 +326,9 @@ namespace { false, // snapshot false, // explain &lpqRaw)); - auto_ptr lpq(lpqRaw); + unique_ptr lpq(lpqRaw); - auto_ptr me; + unique_ptr me; // Invalid: TEXT and {$natural: 1} sort order. auto swme = parseNormalize("{$text: {$search: 's'}}"); @@ -348,9 +348,9 @@ namespace { false, // snapshot false, // explain &lpqRaw)); - auto_ptr lpq(lpqRaw); + unique_ptr lpq(lpqRaw); - auto_ptr me; + unique_ptr me; // Invalid: TEXT and {$natural: -1} sort order. auto swme = parseNormalize("{$text: {$search: 's'}}"); @@ -370,9 +370,9 @@ namespace { false, // snapshot false, // explain &lpqRaw)); - auto_ptr lpq(lpqRaw); + unique_ptr lpq(lpqRaw); - auto_ptr me; + unique_ptr me; // Invalid: TEXT and {$natural: -1} sort order. auto swme = parseNormalize("{$text: {$search: 's'}}"); @@ -393,9 +393,9 @@ namespace { false, // snapshot false, // explain &lpqRaw)); - auto_ptr lpq(lpqRaw); + unique_ptr lpq(lpqRaw); - auto_ptr me; + unique_ptr me; // Invalid: GEO_NEAR and {$natural: 1} sort order. auto swme = parseNormalize("{a: {$near: {$geometry: {type: 'Point', coordinates: [0, 0]}}}}"); @@ -416,9 +416,9 @@ namespace { false, // snapshot false, // explain &lpqRaw)); - auto_ptr lpq(lpqRaw); + unique_ptr lpq(lpqRaw); - auto_ptr me; + unique_ptr me; // Invalid: GEO_NEAR and {$natural: 1} hint. auto swme = parseNormalize("{a: {$near: {$geometry: {type: 'Point', coordinates: [0, 0]}}}}"); @@ -438,9 +438,9 @@ namespace { snapshot, false, // explain &lpqRaw)); - auto_ptr lpq(lpqRaw); + unique_ptr lpq(lpqRaw); - auto_ptr me; + unique_ptr me; // Invalid: TEXT and snapshot. auto swme = parseNormalize("{$text: {$search: 's'}}"); @@ -537,8 +537,8 @@ namespace { TEST(CanonicalQueryTest, RewriteNoDoubleOr) { string queryStr = "{$or:[{a:1}, {b:1}], $or:[{c:1}, {d:1}], e:1}"; BSONObj queryObj = fromjson(queryStr); - auto_ptr base(parseMatchExpression(queryObj)); - auto_ptr rewrite(CanonicalQuery::logicalRewrite(base->shallowClone())); + unique_ptr base(parseMatchExpression(queryObj)); + unique_ptr rewrite(CanonicalQuery::logicalRewrite(base->shallowClone())); assertEquivalent(queryStr.c_str(), base.get(), rewrite.get()); } @@ -547,12 +547,12 @@ namespace { // Rewrite of this... string queryStr = "{$or:[{a:1}, {b:1}], e:1}"; BSONObj queryObj = fromjson(queryStr); - auto_ptr rewrite(CanonicalQuery::logicalRewrite(parseMatchExpression(queryObj))); + unique_ptr rewrite(CanonicalQuery::logicalRewrite(parseMatchExpression(queryObj))); // Should look like this. string rewriteStr = "{$or:[{a:1, e:1}, {b:1, e:1}]}"; BSONObj rewriteObj = fromjson(rewriteStr); - auto_ptr base(parseMatchExpression(rewriteObj)); + unique_ptr base(parseMatchExpression(rewriteObj)); assertEquivalent(queryStr.c_str(), base.get(), rewrite.get()); } @@ -560,10 +560,10 @@ namespace { * Test function for CanonicalQuery::normalize. */ void testNormalizeQuery(const char* queryStr, const char* expectedExprStr) { - auto_ptr cq(canonicalize(queryStr)); + unique_ptr cq(canonicalize(queryStr)); MatchExpression* me = cq->root(); BSONObj expectedExprObj = fromjson(expectedExprStr); - auto_ptr expectedExpr(parseMatchExpression(expectedExprObj)); + unique_ptr expectedExpr(parseMatchExpression(expectedExprObj)); assertEquivalent(queryStr, expectedExpr.get(), me); } diff --git a/src/mongo/db/query/explain.cpp b/src/mongo/db/query/explain.cpp index 7630bbd4c94..e67bb343dfb 100644 --- a/src/mongo/db/query/explain.cpp +++ b/src/mongo/db/query/explain.cpp @@ -49,7 +49,7 @@ namespace { using namespace mongo; using boost::scoped_ptr; - using std::auto_ptr; + using std::unique_ptr; using std::string; using std::vector; @@ -595,7 +595,7 @@ namespace mongo { // Get stats of the winning plan from the trial period, if the verbosity level // is high enough and there was a runoff between multiple plans. - auto_ptr winningStatsTrial; + unique_ptr winningStatsTrial; if (verbosity >= ExplainCommon::EXEC_ALL_PLANS && NULL != mps) { winningStatsTrial.reset(exec->getStats()); invariant(winningStatsTrial.get()); diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp index 4ba5a9bcf42..a722ceb05b8 100644 --- a/src/mongo/db/query/find.cpp +++ b/src/mongo/db/query/find.cpp @@ -63,7 +63,7 @@ #include "mongo/util/mongoutils/str.h" using boost::scoped_ptr; -using std::auto_ptr; +using std::unique_ptr; using std::endl; namespace mongo { @@ -530,7 +530,7 @@ namespace mongo { beginQueryOp(txn, nss, q.query, q.ntoreturn, q.ntoskip); // Parse the qm into a CanonicalQuery. - std::auto_ptr cq; + std::unique_ptr cq; { CanonicalQuery* cqRaw; Status canonStatus = CanonicalQuery::canonicalize(q, diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp index 9825a5ad224..74d0d42051a 100644 --- a/src/mongo/db/query/get_executor.cpp +++ b/src/mongo/db/query/get_executor.cpp @@ -80,7 +80,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::string; using std::vector; @@ -445,8 +445,8 @@ namespace mongo { PlanExecutor::YieldPolicy yieldPolicy, PlanExecutor** out, size_t plannerOptions) { - auto_ptr canonicalQuery(rawCanonicalQuery); - auto_ptr ws(new WorkingSet()); + unique_ptr canonicalQuery(rawCanonicalQuery); + unique_ptr ws(new WorkingSet()); PlanStage* root; QuerySolution* querySolution; Status status = prepareExecution(txn, collection, ws.get(), canonicalQuery.get(), @@ -534,7 +534,7 @@ namespace { PlanExecutor** execOut) { invariant(collection); invariant(cq); - auto_ptr autoCq(cq); + unique_ptr autoCq(cq); // A query can only do oplog start finding if it has a top-level $gt or $gte predicate over // the "ts" field (the operation's timestamp). Find that predicate and pass it to @@ -724,7 +724,7 @@ namespace { deleteStageParams.isExplain = request->isExplain(); deleteStageParams.returnDeleted = request->shouldReturnDeleted(); - auto_ptr ws(new WorkingSet()); + unique_ptr ws(new WorkingSet()); PlanExecutor::YieldPolicy policy = parsedDelete->canYield() ? PlanExecutor::YIELD_AUTO : PlanExecutor::YIELD_MANUAL; @@ -769,7 +769,7 @@ namespace { } // This is the regular path for when we have a CanonicalQuery. - std::auto_ptr cq(parsedDelete->releaseParsedQuery()); + std::unique_ptr cq(parsedDelete->releaseParsedQuery()); PlanStage* rawRoot; QuerySolution* rawQuerySolution; @@ -882,7 +882,7 @@ namespace { PlanExecutor::YieldPolicy policy = parsedUpdate->canYield() ? PlanExecutor::YIELD_AUTO : PlanExecutor::YIELD_MANUAL; - auto_ptr ws(new WorkingSet()); + unique_ptr ws(new WorkingSet()); UpdateStageParams updateStageParams(request, driver, opDebug); if (!parsedUpdate->hasParsedQuery()) { @@ -926,7 +926,7 @@ namespace { } // This is the regular path for when we have a CanonicalQuery. - std::auto_ptr cq(parsedUpdate->releaseParsedQuery()); + std::unique_ptr cq(parsedUpdate->releaseParsedQuery()); PlanStage* rawRoot; QuerySolution* rawQuerySolution; @@ -988,7 +988,7 @@ namespace { return Status(ErrorCodes::BadValue, "server-side JavaScript execution is disabled"); } - auto_ptr ws(new WorkingSet()); + unique_ptr ws(new WorkingSet()); PlanStage* root; QuerySolution* querySolution; @@ -1011,7 +1011,7 @@ namespace { if (!canonicalizeStatus.isOK()) { return canonicalizeStatus; } - auto_ptr canonicalQuery(rawCanonicalQuery); + unique_ptr canonicalQuery(rawCanonicalQuery); const size_t defaultPlannerOptions = 0; Status status = prepareExecution(txn, collection, ws.get(), canonicalQuery.get(), @@ -1216,7 +1216,7 @@ namespace { bool explain, PlanExecutor::YieldPolicy yieldPolicy, PlanExecutor** execOut) { - auto_ptr ws(new WorkingSet()); + unique_ptr ws(new WorkingSet()); PlanStage* root; QuerySolution* querySolution; @@ -1231,7 +1231,7 @@ namespace { return PlanExecutor::make(txn, ws.release(), root, request.ns, yieldPolicy, execOut); } - auto_ptr cq; + unique_ptr cq; if (!request.query.isEmpty() || !request.hint.isEmpty()) { // If query or hint is not empty, canonicalize the query before working with collection. typedef MatchExpressionParser::WhereCallback WhereCallback; @@ -1422,7 +1422,7 @@ namespace { return status; } - auto_ptr autoCq(cq); + unique_ptr autoCq(cq); // If there's no query, we can just distinct-scan one of the indices. // Not every index in plannerParams.indices may be suitable. Refer to diff --git a/src/mongo/db/query/get_executor_test.cpp b/src/mongo/db/query/get_executor_test.cpp index 85d97d3f1f7..7ec251bb6ee 100644 --- a/src/mongo/db/query/get_executor_test.cpp +++ b/src/mongo/db/query/get_executor_test.cpp @@ -41,7 +41,7 @@ using namespace mongo; namespace { - using std::auto_ptr; + using std::unique_ptr; static const char* ns = "somebogusns"; @@ -80,7 +80,7 @@ namespace { AllowedIndices *allowedIndicesRaw; // getAllowedIndices should return false when query shape is not yet in query settings. - auto_ptr cq(canonicalize("{a: 1}", "{}", "{}")); + unique_ptr cq(canonicalize("{a: 1}", "{}", "{}")); PlanCacheKey key = planCache.computeKey(*cq); ASSERT_FALSE(querySettings.getAllowedIndices(key, &allowedIndicesRaw)); @@ -95,7 +95,7 @@ namespace { ASSERT_TRUE(querySettings.getAllowedIndices(key, &allowedIndicesRaw)); ASSERT_FALSE(key.empty()); ASSERT(NULL != allowedIndicesRaw); - auto_ptr allowedIndices(allowedIndicesRaw); + unique_ptr allowedIndices(allowedIndicesRaw); // Indexes from index catalog. std::vector indexEntries; diff --git a/src/mongo/db/query/index_bounds_builder_test.cpp b/src/mongo/db/query/index_bounds_builder_test.cpp index 35bb4304c21..1b349b0515a 100644 --- a/src/mongo/db/query/index_bounds_builder_test.cpp +++ b/src/mongo/db/query/index_bounds_builder_test.cpp @@ -42,7 +42,7 @@ using namespace mongo; namespace { - using std::auto_ptr; + using std::unique_ptr; using std::numeric_limits; using std::string; using std::vector; @@ -74,7 +74,7 @@ namespace { for (vector::const_iterator it = toUnion.begin(); it != toUnion.end(); ++it) { - auto_ptr expr(parseMatchExpression(*it)); + unique_ptr expr(parseMatchExpression(*it)); BSONElement elt = it->firstElement(); if (toUnion.begin() == it) { IndexBoundsBuilder::translate(expr.get(), elt, testIndex, oilOut, tightnessOut); @@ -97,7 +97,7 @@ namespace { for (vector::const_iterator it = toIntersect.begin(); it != toIntersect.end(); ++it) { - auto_ptr expr(parseMatchExpression(*it)); + unique_ptr expr(parseMatchExpression(*it)); BSONElement elt = it->firstElement(); if (toIntersect.begin() == it) { IndexBoundsBuilder::translate(expr.get(), elt, testIndex, oilOut, tightnessOut); @@ -126,7 +126,7 @@ namespace { ++it) { BSONObj obj = it->first; bool isIntersect = it->second; - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); if (constraints.begin() == it) { IndexBoundsBuilder::translate(expr.get(), elt, testIndex, oilOut, tightnessOut); @@ -165,7 +165,7 @@ namespace { // Bounds generated should be the same as the embedded expression // except for the tightness. BSONObj obj = fromjson("{a: {$elemMatch: {$gt: 2}}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -184,7 +184,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateLteNumber) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$lte: 1}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -199,7 +199,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateLteNumberMin) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = BSON("a" << BSON("$lte" << numberMin)); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -214,7 +214,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateLteNegativeInfinity) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$lte: -Infinity}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -229,7 +229,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateLtNumber) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$lt: 1}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -244,7 +244,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateLtNumberMin) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = BSON("a" << BSON("$lt" << numberMin)); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -259,7 +259,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateLtNegativeInfinity) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$lt: -Infinity}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -272,7 +272,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateLtDate) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = BSON("a" << LT << Date_t::fromMillisSinceEpoch(5000)); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -287,7 +287,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateGtNumber) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$gt: 1}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -302,7 +302,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateGtNumberMax) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = BSON("a" << BSON("$gt" << numberMax)); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -317,7 +317,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateGtPositiveInfinity) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$gt: Infinity}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -330,7 +330,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateGteNumber) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$gte: 1}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -345,7 +345,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateGteNumberMax) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = BSON("a" << BSON("$gte" << numberMax)); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -360,7 +360,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateGtePositiveInfinity) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$gte: Infinity}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -375,7 +375,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateGtString) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$gt: 'abc'}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -390,7 +390,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateEqualNan) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: NaN}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -405,7 +405,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateLtNan) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$lt: NaN}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -418,7 +418,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateLteNan) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$lte: NaN}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -433,7 +433,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateGtNan) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$gt: NaN}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -446,7 +446,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateGteNan) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$gte: NaN}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -461,7 +461,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateEqual) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = BSON("a" << 4); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -476,7 +476,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateArrayEqualBasic) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: [1, 2, 3]}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -493,7 +493,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateIn) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$in: [8, 44, -1, -3]}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -514,7 +514,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateInArray) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$in: [[1], 2]}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -609,7 +609,7 @@ namespace { TEST(IndexBoundsBuilderTest, ExistsTrue) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$exists: true}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -624,7 +624,7 @@ namespace { TEST(IndexBoundsBuilderTest, ExistsFalse) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$exists: false}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -645,7 +645,7 @@ namespace { nullptr, // filterExpr BSONObj()); BSONObj obj = fromjson("{a: {$exists: true}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -839,7 +839,7 @@ namespace { TEST(IndexBoundsBuilderTest, TranslateMod) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$mod: [2, 0]}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -1017,7 +1017,7 @@ namespace { TEST(IndexBoundsBuilderTest, SimpleNonPrefixRegex) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: /foo/}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -1033,7 +1033,7 @@ namespace { TEST(IndexBoundsBuilderTest, NonSimpleRegexWithPipe) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: /^foo.*|bar/}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -1049,7 +1049,7 @@ namespace { TEST(IndexBoundsBuilderTest, SimpleRegexSingleLineMode) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: /^foo/s}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -1065,7 +1065,7 @@ namespace { TEST(IndexBoundsBuilderTest, SimplePrefixRegex) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: /^foo/}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -1294,7 +1294,7 @@ namespace { TEST(IndexBoundsBuilderTest, SimpleNE) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = BSON("a" << BSON("$ne" << 3)); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; IndexBoundsBuilder::BoundsTightness tightness; @@ -1345,7 +1345,7 @@ namespace { TEST(IndexBoundsBuilderTest, CodeTypeBounds) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$type: 13}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; @@ -1370,7 +1370,7 @@ namespace { TEST(IndexBoundsBuilderTest, CodeWithScopeTypeBounds) { IndexEntry testIndex = IndexEntry(BSONObj()); BSONObj obj = fromjson("{a: {$type: 15}}"); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); BSONElement elt = obj.firstElement(); OrderedIntervalList oil; diff --git a/src/mongo/db/query/lite_parsed_query.cpp b/src/mongo/db/query/lite_parsed_query.cpp index 747d62d3f60..c24e5271112 100644 --- a/src/mongo/db/query/lite_parsed_query.cpp +++ b/src/mongo/db/query/lite_parsed_query.cpp @@ -37,7 +37,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::string; const string LiteParsedQuery::cmdOptionMaxTimeMS("maxTimeMS"); @@ -72,7 +72,7 @@ namespace mongo { const BSONObj& cmdObj, bool isExplain, LiteParsedQuery** out) { - auto_ptr pq(new LiteParsedQuery()); + unique_ptr pq(new LiteParsedQuery()); pq->_ns = fullns; pq->_fromCommand = true; pq->_explain = isExplain; @@ -566,7 +566,7 @@ namespace mongo { // static Status LiteParsedQuery::make(const QueryMessage& qm, LiteParsedQuery** out) { - auto_ptr pq(new LiteParsedQuery()); + unique_ptr pq(new LiteParsedQuery()); Status status = pq->init(qm.ns, qm.ntoskip, qm.ntoreturn, qm.queryOptions, qm.query, qm.fields, true); @@ -582,7 +582,7 @@ namespace mongo { bool snapshot, bool explain, LiteParsedQuery** out) { - auto_ptr pq(new LiteParsedQuery()); + unique_ptr pq(new LiteParsedQuery()); pq->_sort = sort.getOwned(); pq->_hint = hint.getOwned(); pq->_min = minObj.getOwned(); diff --git a/src/mongo/db/query/lru_key_value.h b/src/mongo/db/query/lru_key_value.h index 808e0584662..8215c029375 100644 --- a/src/mongo/db/query/lru_key_value.h +++ b/src/mongo/db/query/lru_key_value.h @@ -88,9 +88,9 @@ namespace mongo { * kv-store is full prior to the add() operation. * * If an entry is evicted, it will be returned in - * an auto_ptr for the caller to use before disposing. + * an unique_ptr for the caller to use before disposing. */ - std::auto_ptr add(const K& key, V* entry) { + std::unique_ptr add(const K& key, V* entry) { // If the key already exists, delete it first. KVMapConstIt i = _kvMap.find(key); if (i != _kvMap.end()) { @@ -117,11 +117,11 @@ namespace mongo { invariant(_currentSize == _maxSize); // Pass ownership of evicted entry to caller. - // If caller chooses to ignore this auto_ptr, + // If caller chooses to ignore this unique_ptr, // the evicted entry will be deleted automatically. - return std::auto_ptr(evictedEntry); + return std::unique_ptr(evictedEntry); } - return std::auto_ptr(); + return std::unique_ptr(); } /** diff --git a/src/mongo/db/query/lru_key_value_test.cpp b/src/mongo/db/query/lru_key_value_test.cpp index 28cc2147dda..da9c9c73f34 100644 --- a/src/mongo/db/query/lru_key_value_test.cpp +++ b/src/mongo/db/query/lru_key_value_test.cpp @@ -97,7 +97,7 @@ namespace { int maxSize = 10; LRUKeyValue cache(maxSize); for (int i = 0; i < maxSize; ++i) { - std::auto_ptr evicted = cache.add(i, new int(i)); + std::unique_ptr evicted = cache.add(i, new int(i)); ASSERT(NULL == evicted.get()); } ASSERT_EQUALS(cache.size(), (size_t)maxSize); @@ -110,7 +110,7 @@ namespace { } // Adding another entry causes an eviction. - std::auto_ptr evicted = cache.add(maxSize + 1, new int(maxSize + 1)); + std::unique_ptr evicted = cache.add(maxSize + 1, new int(maxSize + 1)); ASSERT_EQUALS(cache.size(), (size_t)maxSize); ASSERT(NULL != evicted.get()); ASSERT_EQUALS(*evicted, evictKey); @@ -136,7 +136,7 @@ namespace { int maxSize = 10; LRUKeyValue cache(maxSize); for (int i = 0; i < maxSize; ++i) { - std::auto_ptr evicted = cache.add(i, new int(i)); + std::unique_ptr evicted = cache.add(i, new int(i)); ASSERT(NULL == evicted.get()); } ASSERT_EQUALS(cache.size(), (size_t)maxSize); @@ -147,7 +147,7 @@ namespace { // Evict all but one of the original entries. for (int i = maxSize; i < (maxSize + maxSize - 1); ++i) { - std::auto_ptr evicted = cache.add(i, new int(i)); + std::unique_ptr evicted = cache.add(i, new int(i)); ASSERT(NULL != evicted.get()); } ASSERT_EQUALS(cache.size(), (size_t)maxSize); diff --git a/src/mongo/db/query/parsed_projection.cpp b/src/mongo/db/query/parsed_projection.cpp index 4c20c13acf6..7552475d5f1 100644 --- a/src/mongo/db/query/parsed_projection.cpp +++ b/src/mongo/db/query/parsed_projection.cpp @@ -32,7 +32,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::string; /** @@ -238,7 +238,7 @@ namespace mongo { } // Fill out the returned obj. - auto_ptr pp(new ParsedProjection()); + unique_ptr pp(new ParsedProjection()); // The positional operator uses the MatchDetails from the query // expression to know which array element was matched. diff --git a/src/mongo/db/query/parsed_projection_test.cpp b/src/mongo/db/query/parsed_projection_test.cpp index df36aef927b..4507da17a1d 100644 --- a/src/mongo/db/query/parsed_projection_test.cpp +++ b/src/mongo/db/query/parsed_projection_test.cpp @@ -35,7 +35,7 @@ namespace { - using std::auto_ptr; + using std::unique_ptr; using std::string; using std::vector; @@ -45,7 +45,7 @@ namespace { // creation function // - auto_ptr createParsedProjection(const BSONObj& query, const BSONObj& projObj) { + unique_ptr createParsedProjection(const BSONObj& query, const BSONObj& projObj) { StatusWithMatchExpression swme = MatchExpressionParser::parse(query); ASSERT(swme.isOK()); boost::scoped_ptr queryMatchExpr(swme.getValue()); @@ -56,10 +56,10 @@ namespace { << " (query: " << query << "): " << status.toString()); } ASSERT(out); - return auto_ptr(out); + return unique_ptr(out); } - auto_ptr createParsedProjection(const char* queryStr, const char* projStr) { + unique_ptr createParsedProjection(const char* queryStr, const char* projStr) { BSONObj query = fromjson(queryStr); BSONObj projObj = fromjson(projStr); return createParsedProjection(query, projObj); @@ -85,17 +85,17 @@ namespace { // the projection spec is non-empty. This test case is included for // completeness and do not reflect actual usage. TEST(ParsedProjectionTest, MakeId) { - auto_ptr parsedProj(createParsedProjection("{}", "{}")); + unique_ptr parsedProj(createParsedProjection("{}", "{}")); ASSERT(parsedProj->requiresDocument()); } TEST(ParsedProjectionTest, MakeEmpty) { - auto_ptr parsedProj(createParsedProjection("{}", "{_id: 0}")); + unique_ptr parsedProj(createParsedProjection("{}", "{_id: 0}")); ASSERT(parsedProj->requiresDocument()); } TEST(ParsedProjectionTest, MakeSingleField) { - auto_ptr parsedProj(createParsedProjection("{}", "{a: 1}")); + unique_ptr parsedProj(createParsedProjection("{}", "{a: 1}")); ASSERT(!parsedProj->requiresDocument()); const vector& fields = parsedProj->getRequiredFields(); ASSERT_EQUALS(fields.size(), 2U); @@ -104,7 +104,7 @@ namespace { } TEST(ParsedProjectionTest, MakeSingleFieldCovered) { - auto_ptr parsedProj(createParsedProjection("{}", "{_id: 0, a: 1}")); + unique_ptr parsedProj(createParsedProjection("{}", "{_id: 0, a: 1}")); ASSERT(!parsedProj->requiresDocument()); const vector& fields = parsedProj->getRequiredFields(); ASSERT_EQUALS(fields.size(), 1U); @@ -112,7 +112,7 @@ namespace { } TEST(ParsedProjectionTest, MakeSingleFieldIDCovered) { - auto_ptr parsedProj(createParsedProjection("{}", "{_id: 1}")); + unique_ptr parsedProj(createParsedProjection("{}", "{_id: 1}")); ASSERT(!parsedProj->requiresDocument()); const vector& fields = parsedProj->getRequiredFields(); ASSERT_EQUALS(fields.size(), 1U); @@ -121,7 +121,7 @@ namespace { // boolean support is undocumented TEST(ParsedProjectionTest, MakeSingleFieldCoveredBoolean) { - auto_ptr parsedProj(createParsedProjection("{}", "{_id: 0, a: true}")); + unique_ptr parsedProj(createParsedProjection("{}", "{_id: 0, a: true}")); ASSERT(!parsedProj->requiresDocument()); const vector& fields = parsedProj->getRequiredFields(); ASSERT_EQUALS(fields.size(), 1U); @@ -130,7 +130,7 @@ namespace { // boolean support is undocumented TEST(ParsedProjectionTest, MakeSingleFieldCoveredIdBoolean) { - auto_ptr parsedProj(createParsedProjection("{}", "{_id: false, a: 1}")); + unique_ptr parsedProj(createParsedProjection("{}", "{_id: false, a: 1}")); ASSERT(!parsedProj->requiresDocument()); const vector& fields = parsedProj->getRequiredFields(); ASSERT_EQUALS(fields.size(), 1U); @@ -177,7 +177,7 @@ namespace { // to achieve the same effect. // Projection parser should handle this the same way as an empty path. TEST(ParsedProjectionTest, InvalidPositionalProjectionDefaultPathMatchExpression) { - auto_ptr queryMatchExpr(new FalseMatchExpression()); + unique_ptr queryMatchExpr(new FalseMatchExpression()); ASSERT(NULL == queryMatchExpr->path().rawData()); ParsedProjection* out = NULL; diff --git a/src/mongo/db/query/plan_cache.cpp b/src/mongo/db/query/plan_cache.cpp index c1de9f0e891..0f2871e2f29 100644 --- a/src/mongo/db/query/plan_cache.cpp +++ b/src/mongo/db/query/plan_cache.cpp @@ -582,7 +582,7 @@ namespace { entry->projection = pq.getProj().getOwned(); boost::lock_guard cacheLock(_cacheMutex); - std::auto_ptr evictedEntry = _cache.add(computeKey(query), entry); + std::unique_ptr evictedEntry = _cache.add(computeKey(query), entry); if (NULL != evictedEntry.get()) { LOG(1) << _ns << ": plan cache maximum size exceeded - " @@ -614,7 +614,7 @@ namespace { if (NULL == feedback) { return Status(ErrorCodes::BadValue, "feedback is NULL"); } - std::auto_ptr autoFeedback(feedback); + std::unique_ptr autoFeedback(feedback); PlanCacheKey ck = computeKey(cq); boost::lock_guard cacheLock(_cacheMutex); diff --git a/src/mongo/db/query/plan_cache_test.cpp b/src/mongo/db/query/plan_cache_test.cpp index a5353cbfcbe..55554315376 100644 --- a/src/mongo/db/query/plan_cache_test.cpp +++ b/src/mongo/db/query/plan_cache_test.cpp @@ -52,7 +52,7 @@ using namespace mongo; namespace { using boost::scoped_ptr; - using std::auto_ptr; + using std::unique_ptr; using std::string; using std::unique_ptr; using std::vector; @@ -173,7 +173,7 @@ namespace { */ struct GenerateQuerySolution { QuerySolution* operator()() const { - auto_ptr qs(new QuerySolution()); + unique_ptr qs(new QuerySolution()); qs->cacheData.reset(new SolutionCacheData()); qs->cacheData->solnType = SolutionCacheData::COLLSCAN_SOLN; qs->cacheData->tree.reset(new PlanCacheIndexTree()); @@ -185,10 +185,10 @@ namespace { * Utility function to create a PlanRankingDecision */ PlanRankingDecision* createDecision(size_t numPlans) { - auto_ptr why(new PlanRankingDecision()); + unique_ptr why(new PlanRankingDecision()); for (size_t i = 0; i < numPlans; ++i) { CommonStats common("COLLSCAN"); - auto_ptr stats(new PlanStageStats(common, STAGE_COLLSCAN)); + unique_ptr stats(new PlanStageStats(common, STAGE_COLLSCAN)); stats->specific.reset(new CollectionScanStats()); why->stats.mutableVector().push_back(stats.release()); why->scores.push_back(0U); @@ -222,12 +222,12 @@ namespace { } void assertShouldNotCacheQuery(const BSONObj& query) { - auto_ptr cq(canonicalize(query)); + unique_ptr cq(canonicalize(query)); assertShouldNotCacheQuery(*cq); } void assertShouldNotCacheQuery(const char* queryStr) { - auto_ptr cq(canonicalize(queryStr)); + unique_ptr cq(canonicalize(queryStr)); assertShouldNotCacheQuery(*cq); } @@ -238,12 +238,12 @@ namespace { */ TEST(PlanCacheTest, ShouldCacheQueryBasic) { - auto_ptr cq(canonicalize("{a: 1}")); + unique_ptr cq(canonicalize("{a: 1}")); assertShouldCacheQuery(*cq); } TEST(PlanCacheTest, ShouldCacheQuerySort) { - auto_ptr cq(canonicalize("{}", "{a: -1}", "{_id: 0, a: 1}")); + unique_ptr cq(canonicalize("{}", "{a: -1}", "{_id: 0, a: 1}")); assertShouldCacheQuery(*cq); } @@ -257,7 +257,7 @@ namespace { * This should normally be handled by the IDHack runner. */ TEST(PlanCacheTest, ShouldNotCacheQueryCollectionScan) { - auto_ptr cq(canonicalize("{}")); + unique_ptr cq(canonicalize("{}")); assertShouldNotCacheQuery(*cq); } @@ -267,7 +267,7 @@ namespace { * Therefore, not much point in caching. */ TEST(PlanCacheTest, ShouldNotCacheQueryWithHint) { - auto_ptr cq(canonicalize("{a: 1}", "{}", "{}", 0, 0, "{a: 1, b: 1}", + unique_ptr cq(canonicalize("{a: 1}", "{}", "{}", 0, 0, "{a: 1, b: 1}", "{}", "{}")); assertShouldNotCacheQuery(*cq); } @@ -276,7 +276,7 @@ namespace { * Min queries are a specialized case of hinted queries */ TEST(PlanCacheTest, ShouldNotCacheQueryWithMin) { - auto_ptr cq(canonicalize("{a: 1}", "{}", "{}", 0, 0, "{}", + unique_ptr cq(canonicalize("{a: 1}", "{}", "{}", 0, 0, "{}", "{a: 100}", "{}")); assertShouldNotCacheQuery(*cq); } @@ -285,7 +285,7 @@ namespace { * Max queries are non-cacheable for the same reasons as min queries. */ TEST(PlanCacheTest, ShouldNotCacheQueryWithMax) { - auto_ptr cq(canonicalize("{a: 1}", "{}", "{}", 0, 0, "{}", + unique_ptr cq(canonicalize("{a: 1}", "{}", "{}", 0, 0, "{}", "{}", "{a: 100}")); assertShouldNotCacheQuery(*cq); } @@ -295,7 +295,7 @@ namespace { * the planner is able to come up with a cacheable solution. */ TEST(PlanCacheTest, ShouldCacheQueryWithGeoWithinLegacyCoordinates) { - auto_ptr cq(canonicalize("{a: {$geoWithin: " + unique_ptr cq(canonicalize("{a: {$geoWithin: " "{$box: [[-180, -90], [180, 90]]}}}")); assertShouldCacheQuery(*cq); } @@ -304,7 +304,7 @@ namespace { * $geoWithin queries with GeoJSON coordinates are supported by the index bounds builder. */ TEST(PlanCacheTest, ShouldCacheQueryWithGeoWithinJSONCoordinates) { - auto_ptr cq(canonicalize("{a: {$geoWithin: " + unique_ptr cq(canonicalize("{a: {$geoWithin: " "{$geometry: {type: 'Polygon', coordinates: " "[[[0, 0], [0, 90], [90, 0], [0, 0]]]}}}}")); assertShouldCacheQuery(*cq); @@ -314,7 +314,7 @@ namespace { * $geoWithin queries with both legacy and GeoJSON coordinates are cacheable. */ TEST(PlanCacheTest, ShouldCacheQueryWithGeoWithinLegacyAndJSONCoordinates) { - auto_ptr cq(canonicalize( + unique_ptr cq(canonicalize( "{$or: [{a: {$geoWithin: {$geometry: {type: 'Polygon', " "coordinates: [[[0, 0], [0, 90], " "[90, 0], [0, 0]]]}}}}," @@ -326,7 +326,7 @@ namespace { * $geoIntersects queries are always cacheable because they support GeoJSON coordinates only. */ TEST(PlanCacheTest, ShouldCacheQueryWithGeoIntersects) { - auto_ptr cq(canonicalize("{a: {$geoIntersects: " + unique_ptr cq(canonicalize("{a: {$geoIntersects: " "{$geometry: {type: 'Point', coordinates: " "[10.0, 10.0]}}}}")); assertShouldCacheQuery(*cq); @@ -337,7 +337,7 @@ namespace { * between flat and spherical queries. */ TEST(PlanCacheTest, ShouldNotCacheQueryWithGeoNear) { - auto_ptr cq(canonicalize("{a: {$geoNear: {$geometry: {type: 'Point'," + unique_ptr cq(canonicalize("{a: {$geoNear: {$geometry: {type: 'Point'," "coordinates: [0,0]}, $maxDistance:100}}}")); assertShouldCacheQuery(*cq); } @@ -348,7 +348,7 @@ namespace { * non-winning plans. */ TEST(PlanCacheTest, ShouldNotCacheQueryExplain) { - auto_ptr cq(canonicalize("{a: 1}", "{}", "{}", 0, 0, "{}", + unique_ptr cq(canonicalize("{a: 1}", "{}", "{}", 0, 0, "{}", "{}", "{}", // min, max false, // snapshot true // explain @@ -361,7 +361,7 @@ namespace { // Adding an empty vector of query solutions should fail. TEST(PlanCacheTest, AddEmptySolutions) { PlanCache planCache; - auto_ptr cq(canonicalize("{a: 1}")); + unique_ptr cq(canonicalize("{a: 1}")); std::vector solns; boost::scoped_ptr decision(createDecision(1U)); ASSERT_NOT_OK(planCache.add(*cq, solns, decision.get())); @@ -369,7 +369,7 @@ namespace { TEST(PlanCacheTest, AddValidSolution) { PlanCache planCache; - auto_ptr cq(canonicalize("{a: 1}")); + unique_ptr cq(canonicalize("{a: 1}")); QuerySolution qs; qs.cacheData.reset(new SolutionCacheData()); qs.cacheData->tree.reset(new PlanCacheIndexTree()); @@ -386,7 +386,7 @@ namespace { TEST(PlanCacheTest, NotifyOfWriteOp) { PlanCache planCache; - auto_ptr cq(canonicalize("{a: 1}")); + unique_ptr cq(canonicalize("{a: 1}")); QuerySolution qs; qs.cacheData.reset(new SolutionCacheData()); qs.cacheData->tree.reset(new PlanCacheIndexTree()); @@ -1066,7 +1066,7 @@ namespace { const char* projStr, const char *expectedStr) { PlanCache planCache; - auto_ptr cq(canonicalize(queryStr, sortStr, projStr)); + unique_ptr cq(canonicalize(queryStr, sortStr, projStr)); PlanCacheKey key = planCache.computeKey(*cq); PlanCacheKey expectedKey(expectedStr); if (key == expectedKey) { @@ -1148,10 +1148,10 @@ namespace { PlanCache planCache; // Legacy coordinates. - auto_ptr cqLegacy(canonicalize("{a: {$geoWithin: " + unique_ptr cqLegacy(canonicalize("{a: {$geoWithin: " "{$box: [[-180, -90], [180, 90]]}}}")); // GeoJSON coordinates. - auto_ptr cqNew(canonicalize("{a: {$geoWithin: " + unique_ptr cqNew(canonicalize("{a: {$geoWithin: " "{$geometry: {type: 'Polygon', coordinates: " "[[[0, 0], [0, 90], [90, 0], [0, 0]]]}}}}")); ASSERT_NOT_EQUALS(planCache.computeKey(*cqLegacy), diff --git a/src/mongo/db/query/plan_enumerator.cpp b/src/mongo/db/query/plan_enumerator.cpp index 9d889b40987..ef1f23997d0 100644 --- a/src/mongo/db/query/plan_enumerator.cpp +++ b/src/mongo/db/query/plan_enumerator.cpp @@ -39,7 +39,7 @@ namespace { using namespace mongo; - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::set; using std::string; @@ -276,7 +276,7 @@ namespace mongo { else if (Indexability::arrayUsesIndexOnChildren(node)) { // Add each of our children as a subnode. We enumerate through each subnode one at a // time until it's exhausted then we move on. - auto_ptr aa(new ArrayAssignment()); + unique_ptr aa(new ArrayAssignment()); if (MatchExpression::ELEM_MATCH_OBJECT == node->matchType()) { childContext.elemMatchExpr = node; diff --git a/src/mongo/db/query/plan_executor.cpp b/src/mongo/db/query/plan_executor.cpp index 42ca5164107..c261f1b8982 100644 --- a/src/mongo/db/query/plan_executor.cpp +++ b/src/mongo/db/query/plan_executor.cpp @@ -130,7 +130,7 @@ namespace mongo { const std::string& ns, YieldPolicy yieldPolicy, PlanExecutor** out) { - std::auto_ptr exec(new PlanExecutor(opCtx, ws, rt, qs, cq, collection, ns)); + std::unique_ptr exec(new PlanExecutor(opCtx, ws, rt, qs, cq, collection, ns)); // Perform plan selection, if necessary. Status status = exec->pickBestPlan(yieldPolicy); diff --git a/src/mongo/db/query/planner_access.cpp b/src/mongo/db/query/planner_access.cpp index 70d91540003..e0f714716b8 100644 --- a/src/mongo/db/query/planner_access.cpp +++ b/src/mongo/db/query/planner_access.cpp @@ -59,7 +59,7 @@ namespace { namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::vector; // static @@ -843,7 +843,7 @@ namespace mongo { bool inArrayOperator, const vector& indices, const QueryPlannerParams& params) { - auto_ptr autoRoot; + unique_ptr autoRoot; if (!inArrayOperator) { autoRoot.reset(root); } @@ -854,7 +854,7 @@ namespace mongo { // sure that the FETCH stage will recheck the entire predicate. // // XXX: This block is a hack to accommodate the storage layer concurrency model. - std::auto_ptr clonedRoot; + std::unique_ptr clonedRoot; if (params.options & QueryPlannerParams::CANNOT_TRIM_IXISECT) { clonedRoot.reset(root->shallowClone()); } @@ -975,7 +975,7 @@ namespace mongo { bool inArrayOperator, const vector& indices, const QueryPlannerParams& params) { - auto_ptr autoRoot; + unique_ptr autoRoot; if (!inArrayOperator) { autoRoot.reset(root); } @@ -1083,7 +1083,7 @@ namespace mongo { } } else { - auto_ptr autoRoot; + unique_ptr autoRoot; if (!inArrayOperator) { autoRoot.reset(root); } diff --git a/src/mongo/db/query/planner_access.h b/src/mongo/db/query/planner_access.h index 80dba39264c..433e2259bb6 100644 --- a/src/mongo/db/query/planner_access.h +++ b/src/mongo/db/query/planner_access.h @@ -107,12 +107,12 @@ namespace mongo { : root(theRoot), inArrayOperator(inArrayOp), indices(indexList), - currentScan(NULL), + currentScan(nullptr), curChild(0), currentIndexNumber(IndexTag::kNoIndex), ixtag(NULL), tightness(IndexBoundsBuilder::INEXACT_FETCH), - curOr(NULL), + curOr(nullptr), loosestBounds(IndexBoundsBuilder::EXACT) { } @@ -144,7 +144,7 @@ namespace mongo { // The index access node that we are currently constructing. We may merge // multiple tagged predicates into a single index scan. - std::auto_ptr currentScan; + std::unique_ptr currentScan; // An index into the child vector of 'root'. Indicates the child MatchExpression // for which we are currently either constructing a new scan or which we are about @@ -165,8 +165,8 @@ namespace mongo { // If 'root' is an $or, the child predicates which are tagged with the same index are // detached from the original root and added here. 'curOr' may be attached as a filter - // later on, or ignored and cleaned up by the auto_ptr. - std::auto_ptr curOr; + // later on, or ignored and cleaned up by the unique_ptr. + std::unique_ptr curOr; // The values of BoundsTightness range from loosest to tightest in this order: // diff --git a/src/mongo/db/query/planner_analysis.cpp b/src/mongo/db/query/planner_analysis.cpp index ef9d8abaadc..f8d1fb3ce3a 100644 --- a/src/mongo/db/query/planner_analysis.cpp +++ b/src/mongo/db/query/planner_analysis.cpp @@ -39,7 +39,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::string; using std::vector; @@ -536,7 +536,7 @@ namespace mongo { QuerySolution* QueryPlannerAnalysis::analyzeDataAccess(const CanonicalQuery& query, const QueryPlannerParams& params, QuerySolutionNode* solnRoot) { - auto_ptr soln(new QuerySolution()); + unique_ptr soln(new QuerySolution()); soln->filterData = query.getQueryObj(); soln->indexFilterApplied = params.indexFiltersApplied; diff --git a/src/mongo/db/query/planner_ixselect_test.cpp b/src/mongo/db/query/planner_ixselect_test.cpp index 041167771e8..ba1f11e93d0 100644 --- a/src/mongo/db/query/planner_ixselect_test.cpp +++ b/src/mongo/db/query/planner_ixselect_test.cpp @@ -43,7 +43,7 @@ using namespace mongo; namespace { - using std::auto_ptr; + using std::unique_ptr; using std::string; using std::vector; @@ -81,7 +81,7 @@ namespace { */ void testGetFields(const char* query, const char* prefix, const char* expectedFieldsStr) { BSONObj obj = fromjson(query); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); unordered_set fields; QueryPlannerIXSelect::getFields(expr.get(), prefix, &fields); @@ -186,7 +186,7 @@ namespace { // Parse and rate query. Some of the nodes in the rated tree // will be tagged after the rating process. BSONObj obj = fromjson(query); - auto_ptr expr(parseMatchExpression(obj)); + unique_ptr expr(parseMatchExpression(obj)); // Currently, we tag every indexable node even when no compatible // index is available. Hence, it is fine to pass an empty vector of diff --git a/src/mongo/db/query/query_planner.cpp b/src/mongo/db/query/query_planner.cpp index 43ada571f37..4cdcbff54a3 100644 --- a/src/mongo/db/query/query_planner.cpp +++ b/src/mongo/db/query/query_planner.cpp @@ -49,7 +49,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::numeric_limits; // Copied verbatim from db/index.h @@ -250,7 +250,7 @@ namespace mongo { return Status(ErrorCodes::BadValue, "Cannot produce cache data: tree is NULL."); } - auto_ptr indexTree(new PlanCacheIndexTree()); + unique_ptr indexTree(new PlanCacheIndexTree()); if (NULL != taggedTree->getTag()) { IndexTag* itag = static_cast(taggedTree->getTag()); @@ -758,7 +758,7 @@ namespace mongo { if (!indexTreeStatus.isOK()) { LOG(5) << "Query is not cachable: " << indexTreeStatus.reason() << endl; } - auto_ptr autoData(cacheData); + unique_ptr autoData(cacheData); // This can fail if enumeration makes a mistake. QuerySolutionNode* solnRoot = diff --git a/src/mongo/db/query/stage_builder.cpp b/src/mongo/db/query/stage_builder.cpp index f6c1b93da09..0268fe02277 100644 --- a/src/mongo/db/query/stage_builder.cpp +++ b/src/mongo/db/query/stage_builder.cpp @@ -55,7 +55,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; PlanStage* buildStages(OperationContext* txn, Collection* collection, @@ -152,7 +152,7 @@ namespace mongo { } else if (STAGE_AND_HASH == root->getType()) { const AndHashNode* ahn = static_cast(root); - auto_ptr ret(new AndHashStage(ws, ahn->filter.get(), collection)); + unique_ptr ret(new AndHashStage(ws, ahn->filter.get(), collection)); for (size_t i = 0; i < ahn->children.size(); ++i) { PlanStage* childStage = buildStages(txn, collection, qsol, ahn->children[i], ws); if (NULL == childStage) { return NULL; } @@ -162,7 +162,7 @@ namespace mongo { } else if (STAGE_OR == root->getType()) { const OrNode * orn = static_cast(root); - auto_ptr ret(new OrStage(ws, orn->dedup, orn->filter.get())); + unique_ptr ret(new OrStage(ws, orn->dedup, orn->filter.get())); for (size_t i = 0; i < orn->children.size(); ++i) { PlanStage* childStage = buildStages(txn, collection, qsol, orn->children[i], ws); if (NULL == childStage) { return NULL; } @@ -172,7 +172,7 @@ namespace mongo { } else if (STAGE_AND_SORTED == root->getType()) { const AndSortedNode* asn = static_cast(root); - auto_ptr ret(new AndSortedStage(ws, asn->filter.get(), collection)); + unique_ptr ret(new AndSortedStage(ws, asn->filter.get(), collection)); for (size_t i = 0; i < asn->children.size(); ++i) { PlanStage* childStage = buildStages(txn, collection, qsol, asn->children[i], ws); if (NULL == childStage) { return NULL; } @@ -185,7 +185,7 @@ namespace mongo { MergeSortStageParams params; params.dedup = msn->dedup; params.pattern = msn->sort; - auto_ptr ret(new MergeSortStage(params, ws, collection)); + unique_ptr ret(new MergeSortStage(params, ws, collection)); for (size_t i = 0; i < msn->children.size(); ++i) { PlanStage* childStage = buildStages(txn, collection, qsol, msn->children[i], ws); if (NULL == childStage) { return NULL; } diff --git a/src/mongo/db/range_deleter.cpp b/src/mongo/db/range_deleter.cpp index 6eefd436274..75b1a9c38a7 100644 --- a/src/mongo/db/range_deleter.cpp +++ b/src/mongo/db/range_deleter.cpp @@ -46,7 +46,7 @@ #include "mongo/util/time_support.h" #include "mongo/util/timer.h" -using std::auto_ptr; +using std::unique_ptr; using std::endl; using std::set; using std::pair; @@ -224,7 +224,7 @@ namespace mongo { const BSONObj& min(options.range.minKey); const BSONObj& max(options.range.maxKey); - auto_ptr toDelete( + unique_ptr toDelete( new RangeDeleteEntry(options)); toDelete->notifyDone = notifyDone; diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp index fde2c24232c..2f269b625c5 100644 --- a/src/mongo/db/repl/master_slave.cpp +++ b/src/mongo/db/repl/master_slave.cpp @@ -74,7 +74,7 @@ #include "mongo/util/log.h" using boost::scoped_ptr; -using std::auto_ptr; +using std::unique_ptr; using std::cout; using std::endl; using std::max; @@ -269,7 +269,7 @@ namespace repl { // check that no items are in sources other than that // add if missing int n = 0; - auto_ptr exec( + unique_ptr exec( InternalPlanner::collectionScan(txn, localSources, ctx.db()->getCollection(localSources))); @@ -314,7 +314,7 @@ namespace repl { } } - auto_ptr exec( + unique_ptr exec( InternalPlanner::collectionScan(txn, localSources, ctx.db()->getCollection(localSources))); diff --git a/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp b/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp index 8d53dffc062..49f9ed1e06d 100644 --- a/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp +++ b/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp @@ -39,7 +39,7 @@ namespace repl { namespace { using boost::scoped_ptr; - using std::auto_ptr; + using std::unique_ptr; bool stringContains(const std::string &haystack, const std::string& needle) { return haystack.find(needle) != std::string::npos; diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp index b33d03d7bf3..6d75a351957 100644 --- a/src/mongo/db/repl/replication_info.cpp +++ b/src/mongo/db/repl/replication_info.cpp @@ -51,7 +51,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::list; using std::string; using std::stringstream; @@ -89,7 +89,7 @@ namespace repl { { const char* localSources = "local.sources"; AutoGetCollectionForRead ctx(txn, localSources); - auto_ptr exec( + unique_ptr exec( InternalPlanner::collectionScan(txn, localSources, ctx.getCollection())); BSONObj obj; PlanExecutor::ExecState state; diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp index 395aefd4d5a..437e01f1011 100644 --- a/src/mongo/db/repl/rs_rollback.cpp +++ b/src/mongo/db/repl/rs_rollback.cpp @@ -104,7 +104,7 @@ namespace mongo { using boost::shared_ptr; - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::list; using std::map; diff --git a/src/mongo/db/restapi.cpp b/src/mongo/db/restapi.cpp index f582bf33a3b..f977e3afeef 100644 --- a/src/mongo/db/restapi.cpp +++ b/src/mongo/db/restapi.cpp @@ -54,7 +54,7 @@ namespace mongo { bool getInitialSyncCompleted(); - using std::auto_ptr; + using std::unique_ptr; using std::string; using std::stringstream; using std::endl; @@ -179,7 +179,7 @@ namespace mongo { BSONObj query = queryBuilder.obj(); DBDirectClient db(txn); - auto_ptr cursor = db.query( ns.c_str() , query, num , skip ); + unique_ptr cursor = db.query( ns.c_str() , query, num , skip ); uassert( 13085 , "query failed for dbwebserver" , cursor.get() ); if ( one ) { diff --git a/src/mongo/db/stats/snapshots.cpp b/src/mongo/db/stats/snapshots.cpp index 555c93917f0..d6ab900420f 100644 --- a/src/mongo/db/stats/snapshots.cpp +++ b/src/mongo/db/stats/snapshots.cpp @@ -45,7 +45,7 @@ */ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::endl; void SnapshotData::takeSnapshot() { diff --git a/src/mongo/db/storage/mmap_v1/btree/btree_interface_test.cpp b/src/mongo/db/storage/mmap_v1/btree/btree_interface_test.cpp index 48d9fe5319b..23f649bfcaa 100644 --- a/src/mongo/db/storage/mmap_v1/btree/btree_interface_test.cpp +++ b/src/mongo/db/storage/mmap_v1/btree/btree_interface_test.cpp @@ -35,7 +35,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; class MyHarnessHelper final : public HarnessHelper { public: diff --git a/src/mongo/db/storage/mmap_v1/btree/btree_logic.cpp b/src/mongo/db/storage/mmap_v1/btree/btree_logic.cpp index 98f1d1497e9..1afe24331cf 100644 --- a/src/mongo/db/storage/mmap_v1/btree/btree_logic.cpp +++ b/src/mongo/db/storage/mmap_v1/btree/btree_logic.cpp @@ -42,7 +42,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::dec; using std::endl; using std::hex; @@ -114,7 +114,7 @@ namespace mongo { template Status BtreeLogic::Builder::addKey(const BSONObj& keyObj, const DiskLoc& loc) { - auto_ptr key(new KeyDataOwnedType(keyObj)); + unique_ptr key(new KeyDataOwnedType(keyObj)); if (key->dataSize() > BtreeLayout::KeyMax) { string msg = str::stream() << "Btree::insert: key too large to index, failing " @@ -148,7 +148,7 @@ namespace mongo { invariant(_logic->pushBack(rightLeaf, loc, *key, DiskLoc())); } - _keyLast = key; + _keyLast = std::move(key); return Status::OK(); } diff --git a/src/mongo/db/storage/mmap_v1/btree/btree_logic.h b/src/mongo/db/storage/mmap_v1/btree/btree_logic.h index 5b4fdc8205e..48a307f3b4d 100644 --- a/src/mongo/db/storage/mmap_v1/btree/btree_logic.h +++ b/src/mongo/db/storage/mmap_v1/btree/btree_logic.h @@ -121,7 +121,7 @@ namespace mongo { DiskLoc _rightLeafLoc; // DiskLoc of right-most (highest) leaf bucket. bool _dupsAllowed; - std::auto_ptr _keyLast; + std::unique_ptr _keyLast; // Not owned. OperationContext* _txn; diff --git a/src/mongo/db/storage/mmap_v1/btree/btree_logic_test.cpp b/src/mongo/db/storage/mmap_v1/btree/btree_logic_test.cpp index 87bfd0a03db..1c0bd1c1505 100644 --- a/src/mongo/db/storage/mmap_v1/btree/btree_logic_test.cpp +++ b/src/mongo/db/storage/mmap_v1/btree/btree_logic_test.cpp @@ -2128,7 +2128,7 @@ namespace mongo { start.appendMinKey( "a" ); BSONObjBuilder end; end.appendMaxKey( "a" ); - auto_ptr< BtreeCursor > c( BtreeCursor::make( nsdetails( ns() ), + unique_ptr< BtreeCursor > c( BtreeCursor::make( nsdetails( ns() ), id(), start.done(), end.done(), @@ -2193,7 +2193,7 @@ namespace mongo { end.appendMaxKey( "a" ); BSONObj l = bt()->keyNode( 0 ).key.toBson(); string toInsert; - auto_ptr< BtreeCursor > c( BtreeCursor::make( nsdetails( ns() ), + unique_ptr< BtreeCursor > c( BtreeCursor::make( nsdetails( ns() ), id(), start.done(), end.done(), diff --git a/src/mongo/db/storage/mmap_v1/dur_recover.cpp b/src/mongo/db/storage/mmap_v1/dur_recover.cpp index b6d997d4025..5e61e39930f 100644 --- a/src/mongo/db/storage/mmap_v1/dur_recover.cpp +++ b/src/mongo/db/storage/mmap_v1/dur_recover.cpp @@ -59,7 +59,7 @@ namespace mongo { using boost::shared_ptr; - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::hex; using std::map; @@ -157,7 +157,7 @@ namespace mongo { const char *p = _uncompressed.c_str(); verify(compressedLen == _h.sectionLen() - sizeof(JSectFooter) - sizeof(JSectHeader)); - _entries = auto_ptr(new BufReader(p, _uncompressed.size())); + _entries = unique_ptr(new BufReader(p, _uncompressed.size())); } // We work with the uncompressed buffer when doing a WRITETODATAFILES (for speed) @@ -228,7 +228,7 @@ namespace mongo { private: - auto_ptr _entries; + unique_ptr _entries; const JSectHeader _h; const char *_lastDbName; // pointer into mmaped journal file const bool _doDurOps; @@ -412,12 +412,12 @@ namespace mongo { return; } - auto_ptr i; + unique_ptr i; if( _recovering ) { - i = auto_ptr(new JournalSectionIterator(*h, p, len, _recovering)); + i = unique_ptr(new JournalSectionIterator(*h, p, len, _recovering)); } else { - i = auto_ptr(new JournalSectionIterator(*h, /*after header*/p, /*w/out header*/len)); + i = unique_ptr(new JournalSectionIterator(*h, /*after header*/p, /*w/out header*/len)); } // we use a static so that we don't have to reallocate every time through. occasionally we diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp b/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp index 5045d6a23da..2d9857ce64e 100644 --- a/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp +++ b/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp @@ -57,7 +57,7 @@ namespace mongo { using boost::scoped_ptr; - using std::auto_ptr; + using std::unique_ptr; namespace { @@ -735,7 +735,7 @@ namespace { _getIndexRecordStore(), this)); - auto_ptr md(new NamespaceDetailsRSV1MetaData(ns, details)); + unique_ptr md(new NamespaceDetailsRSV1MetaData(ns, details)); const NamespaceString nss(ns); if (details->isCapped) { @@ -779,7 +779,7 @@ namespace { RecordStoreV1Base* rs = _getRecordStore(entry->descriptor()->indexNamespace()); invariant(rs); - std::auto_ptr btree( + std::unique_ptr btree( getMMAPV1Interface(entry->headManager(), rs, &rs->savedCursors, diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp b/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp index ebd298917c5..b783d92a76c 100644 --- a/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp +++ b/src/mongo/db/storage/mmap_v1/mmap_v1_extent_manager.cpp @@ -55,7 +55,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::max; using std::string; @@ -166,7 +166,7 @@ namespace mongo { } } - auto_ptr df(new DataFile(n)); + unique_ptr df(new DataFile(n)); Status s = df->openExisting(fullNameString.c_str()); if (!s.isOK()) { @@ -235,7 +235,7 @@ namespace mongo { } { - auto_ptr allocFile(new DataFile(allocFileId)); + unique_ptr allocFile(new DataFile(allocFileId)); const string allocFileName = _fileName(allocFileId).string(); Timer t; @@ -254,7 +254,7 @@ namespace mongo { // Preallocate is asynchronous if (preallocateNextFile) { - auto_ptr nextFile(new DataFile(allocFileId + 1)); + unique_ptr nextFile(new DataFile(allocFileId + 1)); const string nextFileName = _fileName(allocFileId + 1).string(); nextFile->open(txn, nextFileName.c_str(), minSize, false); -- cgit v1.2.1