0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-28 07:59:02 +01:00

SERVER-17655 polyfill make_unique in stdx

This commit is contained in:
Adam Midvidy 2015-03-19 11:06:58 -04:00
parent b9b1c95520
commit f97a60f882
3 changed files with 80 additions and 1 deletions

View File

@ -1770,6 +1770,29 @@ def doConfigure(myenv):
myenv = conf.Finish()
def CheckCXX14MakeUnique(context):
test_body = """
#include <memory>
int main(int argc, char **argv) {
auto foo = std::make_unique<int>(5);
return 0;
}
"""
context.Message('Checking for C++14 std::make_unique support... ')
ret = context.TryCompile(textwrap.dedent(test_body), '.cpp')
context.Result(ret)
return ret
# Check for std::make_unique support without using the __cplusplus macro
conf = Configure(myenv, help=False, custom_tests = {
'CheckCXX14MakeUnique': CheckCXX14MakeUnique,
})
if conf.CheckCXX14MakeUnique():
conf.env.Append(CPPDEFINES=['MONGO_HAVE_STD_MAKE_UNIQUE'])
myenv = conf.Finish()
def CheckBoostMinVersion(context):
compile_test_body = textwrap.dedent("""
#include <boost/version.hpp>

View File

@ -93,6 +93,7 @@
#include "mongo/db/ttl.h"
#include "mongo/platform/process_id.h"
#include "mongo/scripting/engine.h"
#include "mongo/stdx/memory.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/cmdline_utils/censor_cmdline.h"
#include "mongo/util/concurrency/task.h"
@ -477,7 +478,7 @@ namespace mongo {
}
getGlobalEnvironment()->setGlobalStorageEngine(storageGlobalParams.engine);
getGlobalEnvironment()->setOpObserver(std::unique_ptr<OpObserver>(new OpObserver));
getGlobalEnvironment()->setOpObserver(stdx::make_unique<OpObserver>());
const repl::ReplSettings& replSettings =
repl::getGlobalReplicationCoordinator()->getSettings();

55
src/mongo/stdx/memory.h Normal file
View File

@ -0,0 +1,55 @@
/**
* Copyright (C) 2015 MongoDB Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, the copyright holders give permission to link the
* code of portions of this program with the OpenSSL library under certain
* conditions as described in each individual source file and distribute
* linked combinations including the program with the OpenSSL library. You
* must comply with the GNU Affero General Public License in all respects for
* all of the code used other than as permitted herein. If you modify file(s)
* with this exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do so,
* delete this exception statement from your version. If you delete this
* exception statement from all source files in the program, then also delete
* it in the license file.
*/
#pragma once
#if defined(MONGO_HAVE_STD_MAKE_UNIQUE)
#include <memory>
namespace mongo {
namespace stdx {
using ::std::make_unique;
} // namespace stdx
} // namespace mongo
#else
#include <boost/smart_ptr/make_unique.hpp>
namespace mongo {
namespace stdx {
using boost::make_unique;
} // namespace stdx
} // namespace mongo
#endif