Remove gmx_unique_ptr and use std::unique_ptr directly.
Change-Id: I8b1b328b492a629ec8b0b26d49faf851a577743a
find_package(Boost 1.44.0)
if(Boost_FOUND AND Boost_VERSION VERSION_LESS "104400")
set(Boost_FOUND FALSE)
+ set(Boost_Reason "Boost >= 1.44 not found.")
+ endif()
+ # clang with some older versions of boost fail to work with C++11
+ if(CMAKE_CXX_COMPILER_ID MATCHES Clang AND
+ (Boost_VERSION VERSION_EQUAL 104601 OR Boost_VERSION VERSION_EQUAL 104700))
+ set(Boost_FOUND FALSE)
+ set(Boost_Reason "Boost 1.46.1 and 1.47.0 do not work with Clang.")
endif()
# Print the notification only on first run, when determining the default
if(NOT DEFINED GMX_EXTERNAL_BOOST AND NOT Boost_FOUND)
- message("Boost >= 1.44 not found. Using minimal internal version. "
+ message("${Boost_Reason} Using minimal internal version. "
"This may cause trouble if you plan on compiling/linking other "
"software that uses Boost against GROMACS.")
endif()
endif()
+
option(GMX_EXTERNAL_BOOST "Use external Boost instead of minimal built-in version"
${Boost_FOUND})
if(GMX_EXTERNAL_BOOST AND NOT Boost_FOUND)
include(gmxTestCXX11)
gmx_test_cxx11(GMX_CXX11_SUPPORTED GMX_CXX11_FLAGS)
-include(CMakeDependentOption)
-# clang with some older versions of boost fail to work with C++11
-if(CMAKE_CXX_COMPILER_ID MATCHES Clang AND
- (Boost_VERSION VERSION_EQUAL 104601 OR Boost_VERSION VERSION_EQUAL 104700))
- set(CLANG_AND_OLD_EXTERNAL_BOOST TRUE)
-endif()
-# nvcc does not support C++11 flags, so with GPUs we prefer to skip C++11 flags
-# entirely to keep the compilation environment uniform.
-cmake_dependent_option(GMX_CXX11
- "Use C++11 features"
- ON "GMX_CXX11_SUPPORTED AND NOT GMX_GPU AND NOT CLANG_AND_OLD_EXTERNAL_BOOST" OFF)
-mark_as_advanced(GMX_CXX11)
-if(GMX_CXX11)
- set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} ${GMX_CXX11_FLAGS}")
+if(NOT GMX_CXX11_SUPPORTED)
+ message(FATAL_ERROR "This version of GROMACS requires C++11. Please use a newer compiler or use the GROMACS 5.1.x release. Note it might be sufficient to instruct the compiler to use a newer STL version. See the installation guide for details.")
endif()
+set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} ${GMX_CXX11_FLAGS}")
# Now we can test for CXX11_REGEX include file
check_include_file_cxx(regex HAVE_CXX11_REGEX)
+++ /dev/null
-#
-# This file is part of the GROMACS molecular simulation package.
-#
-# Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
-# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
-# and including many others, as listed in the AUTHORS file in the
-# top-level source directory and at http://www.gromacs.org.
-#
-# GROMACS is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1
-# of the License, or (at your option) any later version.
-#
-# GROMACS 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with GROMACS; if not, see
-# http://www.gnu.org/licenses, or write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# If you want to redistribute modifications to GROMACS, please
-# consider that scientific software is very special. Version
-# control is crucial - bugs must be traceable. We will be happy to
-# consider code for inclusion in the official distribution, but
-# derived work must not be called official GROMACS. Details are found
-# in the README & COPYING files - if they are missing, get the
-# official version at http://www.gromacs.org.
-#
-# To help us fund GROMACS development, we humbly ask that you cite
-# the research papers on the package. Check out http://www.gromacs.org.
-
-# Due to a bug, gcc 4.4.x crashes when compiling listed-forces/bonded.cpp with -O3 and
-# -fopenmp, but strangely it does not crash with -O2 + all additional options.
-# -O3 uses. Therefore, for the affected files, when compiling in release mode,
-# we override -O3 with -O2 and add the additional option.
-#
-
-# Considering compiler version and build configuration, check if the workaround
-# is needed to avoid gcc crash.
-macro(gmx_check_gcc44_bug_workaround_needed OUT_VAR)
- if(CMAKE_COMPILER_IS_GNUCC AND
- CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.3.999" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "4.4.999")
-
- set(_gcc44_workaround FALSE)
-
- # only apply the workaround if we are actually using -O3
- string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type)
- if ("${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${_build_type}}" MATCHES ".*-O3.*" AND
- GMX_OPENMP)
- if(GMX_DISABLE_GCC44_BUG_WORKAROUND)
- set(_msg "gcc ${CMAKE_C_COMPILER_VERSION} detected, using -O3, but workaround for optimization bug is disabled")
- else()
- set(_msg "gcc ${CMAKE_C_COMPILER_VERSION} detected, using -O3, will apply workaround for optimization bug (disable with GMX_DISABLE_GCC44_BUG_WORKAROUND)")
- set(_gcc44_workaround TRUE)
- endif()
- # only issues message if the value has changed
- if((NOT _gcc44_workaround AND ${OUT_VAR}) OR (_gcc44_workaround AND NOT ${OUT_VAR}))
- message(STATUS "${_msg}")
- endif()
- endif()
-
- set(${OUT_VAR} ${_gcc44_workaround} CACHE INTERNAL "Use gcc 4.4.x O3 optimization bug workaround" FORCE)
- endif()
-endmacro()
-
-# Apply workaround on the specified source file.
-#
-# This workaround does not seem to affect the performance in a measurable way.
-macro(gmx_apply_gcc44_bug_workaround FILE_NAME)
- set_source_files_properties(
- ${FILE_NAME}
- PROPERTIES
- COMPILE_FLAGS "-O2 -finline-functions -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-vectorize -fipa-cp-clone"
- )
-endmacro()
+++ /dev/null
-#
-# This file is part of the GROMACS molecular simulation package.
-#
-# Copyright (c) 2014, by the GROMACS development team, led by
-# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
-# and including many others, as listed in the AUTHORS file in the
-# top-level source directory and at http://www.gromacs.org.
-#
-# GROMACS is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1
-# of the License, or (at your option) any later version.
-#
-# GROMACS 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with GROMACS; if not, see
-# http://www.gnu.org/licenses, or write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# If you want to redistribute modifications to GROMACS, please
-# consider that scientific software is very special. Version
-# control is crucial - bugs must be traceable. We will be happy to
-# consider code for inclusion in the official distribution, but
-# derived work must not be called official GROMACS. Details are found
-# in the README & COPYING files - if they are missing, get the
-# official version at http://www.gromacs.org.
-#
-# To help us fund GROMACS development, we humbly ask that you cite
-# the research papers on the package. Check out http://www.gromacs.org.
-
-# GMock uses tuples extensively, but since it is part of tr1 we cannot
-# assume it is present - the Fujitsu compilers on K computer is one
-# example of a system where it is not, and this is likely the case for many
-# embedded systems too.
-#
-# In general, we can ask gmock to use its own internal implementation by
-# defining GTEST_USE_OWN_TR1_TUPLE=1. This is safe for Gromacs, since we do
-# not use tr1/tuple.h elsewhere. However, this workaround itself will not
-# compile on MSVC - but this is the only architecture we know where it does
-# not work. To make things even worse, on MSVC even the standard tr1/tuple
-# implementation is not fully compatible, but we can make it work by setting
-# _VARIADIC_MAX=10. This is similar to r675 of googletest, which is still not
-# present in GMock 1.7.0. See
-# https://code.google.com/p/googletest/source/detail?r=675#, but note
-# that its summary does not represent its code correctly.
-#
-# To make all this work without user intervention, we first check what compiler
-# we have, and if it is not MSVC we simply use the internal version. If we are
-# using MSVC, we rely on the compiler's version, but set the variable necessary
-# to make it compatible.
-#
-# This function should be called to get the compile definitions
-# suitable for making sure we have a tuple implementation that works with gmock.
-#
-# Returns a string of options in VARIABLE
-function(GET_GMOCK_TUPLE_WORKAROUND VARIABLE)
- set(${VARIABLE} "")
- if(MSVC OR (WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "Intel"))
- if(MSVC_VERSION VERSION_EQUAL 1700)
- # Fixes Visual Studio 2012
- set(${VARIABLE} "_VARIADIC_MAX=10")
- endif()
- # For MSVC different from 2012, or Intel on Windows, we reply on tr1/tuple working.
- else()
- # Use the built-in version on all other compilers.
- set(${VARIABLE} "GTEST_USE_OWN_TR1_TUPLE=1")
- endif()
- set(${VARIABLE} ${${VARIABLE}} PARENT_SCOPE)
-endfunction()
#
# This file is part of the GROMACS molecular simulation package.
#
-# Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+# Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
# and including many others, as listed in the AUTHORS file in the
# top-level source directory and at http://www.gromacs.org.
# versions before trying to detect OpenMP with the standard find-package-module,
# and then does some additional tests for flags afterwards.
-# First exclude compilers known to not work with OpenMP although claim to support it:
-# gcc 4.2.1 and gcc-llvm 4.2.1 (also claims to be 4.2.1) on Mac OS X
-# This fixes redmine 900 and needs to run before OpenMP flags are set below.
if(GMX_OPENMP)
- if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND
- (CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.3))
- message(STATUS "OpenMP multithreading not supported with gcc/llvm-gcc 4.2 on Mac OS X, disabled")
- set(GMX_OPENMP OFF CACHE BOOL
- "OpenMP multithreading not not supported with gcc/llvm-gcc 4.2 on Mac OS X, disabled!" FORCE)
- elseif(CMAKE_C_COMPILER_ID MATCHES "Cray" AND CMAKE_VERSION VERSION_LESS 3)
+ if(CMAKE_C_COMPILER_ID MATCHES "Cray" AND CMAKE_VERSION VERSION_LESS 3)
message(STATUS "OpenMP multithreading is not detected correctly for the Cray compiler with CMake before version 3.0 (see http://public.kitware.com/Bug/view.php?id=14567)")
set(GMX_OPENMP OFF CACHE BOOL
"OpenMP multithreading is not detected correctly for the Cray compiler with CMake before version 3.0 (see http://public.kitware.com/Bug/view.php?id=14567)" FORCE)
endif()
set(CMAKE_REQUIRED_FLAGS "${CXX11_FLAG}")
check_cxx_source_compiles(
-"#include <vector>
+"#include <map>
#include <memory>
#include <utility>
-struct A {
- A(int *i=NULL) : p(i) {} ;
- std::unique_ptr<int> p;
-};
-template <typename Head, typename... Tail>
-struct VarList {
- typedef VarList<Tail...> VarListTail;
- typedef std::pair<Head, typename VarListTail::ListType> ListType;
-};
class a { explicit operator bool() {return true;} };
int main() {
typedef std::unique_ptr<int> intPointer;
intPointer p(new int(10));
- std::vector<intPointer> v;
- v.push_back(std::move(p));
- std::vector<A> v2;
- v2.push_back(A()); //requires default move constructor
- v2.push_back(A(new int(5))); //detects bug in ICC
+ std::map<int, std::unique_ptr<int>> m;
+ m.insert(std::make_pair(5, std::move(p)));
}" ${VARIABLE})
set(CMAKE_REQUIRED_FLAGS "")
if(${VARIABLE})
message(WARNING "The versions of the C and C++ compilers do not match (${CMAKE_C_COMPILER_VERSION} and ${CMAKE_CXX_COMPILER_VERSION}, respectively). Mixing different C/C++ compilers can cause problems.")
endif()
- # gcc 4.4.x is buggy and crashes when compiling some files with O3 and OpenMP on.
- # Detect here whether applying a workaround is needed and will apply it later
- # on the affected files. This test must come after gmx_c_flags(), since we
- # only want to enable the workaround when using the -O3 flag.
- include(gmxGCC44O3BugWorkaround)
- gmx_check_gcc44_bug_workaround_needed(GMX_USE_GCC44_BUG_WORKAROUND)
-
# clang 3.0 is buggy for some unknown reason detected during adding
# the SSE2 group kernels for GROMACS 4.6. If we ever work out what
# that is, we should replace these tests with a compiler feature test,
endif()
endif()
- if(CMAKE_C_COMPILER_ID MATCHES "Intel" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "12.0.0")
- message(WARNING "Intel compilers before 12.0.0 are not routinely tested, so there may be problems. Version 11.1 with SSE4.1 is known to produce incorrect results. It is highly recommended to use a more up-to-date compiler. If you choose to use this version, make sure you run the regressiontests.")
- endif()
-
endmacro(gmx_test_compiler_problems)
dev-manual/gmxtree.rst
dev-manual/includestyle.rst
dev-manual/jenkins.rst
+ dev-manual/language-features.rst
dev-manual/naming.rst
dev-manual/overview.rst
dev-manual/relocatable-binaries.rst
.. cmake:: GMX_BUILD_SHARED_EXE
-.. cmake:: GMX_CXX11
-
- If ``ON``, some C++11 features are used internally (mainly
- ``std::unique_ptr``).
- If ``OFF``, no C++11 features are used in the code (``boost::shared_ptr`` is
- used as a replacement).
- The default is ``ON`` if the compilation environment is determined to
- support enough C++11 (GPU builds cannot for now use C++11).
- Installed headers are not affected.
-
.. cmake:: GMX_CYCLE_SUBCOUNTERS
.. cmake:: GMX_DATA_INSTALL_DIR
--- /dev/null
+Allowed language features
+=========================
+
+GROMACS uses C99 for C files and C++11 for C++ files.
+C++ has a lot of features, but to keep the source code maintainable and easy to read,
+we will avoid using some of them in Gromacs code. The basic principle is to keep things
+as simple as possible.
+For compatiblity certain work-arounds are required because not all compilers support
+these standards fully.
+
+* MSVC supports only a subset of C99 and work-arounds are required in those cases.
+* Before 7.0 (partial support in 6.5) CUDA didn't support C++11. Therefore any
+ header file which is needed (or likly will be nedded) by CUDA should not use C++11.
+* C++11 features which are not widely implemented (including in MSVC 2013 and GCC 4.6)
+ should not be used.
+
+.. TODO: Copy important points from http://www.gromacs.org/index.php?title=Developer_Zone/Programming_Guide/Allowed_C%2B%2B_Features
formatting
includestyle
naming
+ language-features
:doc:`formatting`
Guidelines for indentation and other code formatting.
Guidelines for #include style (ordering, paths to use, etc.).
:doc:`naming`
Naming conventions for files and various code constructs.
+:doc:`language-features`
+ Allowed language features.
:ref:`dev-doxygen-guidelines`
Guidelines for using Doxygen to document the source code are currently in a
section on the page on general Doxygen usage.
Compiler
--------
Technically, |Gromacs| can be compiled on any platform with an ANSI C99
-and C++98 compiler, and their respective standard C/C++ libraries.
-We use only a few C99 features, but note that the C++ compiler also needs to
-support these C99 features (notably, int64_t and related things), which are not
-part of the C++98 standard.
+and C++11 compiler, and their respective standard C/C++ libraries.
+GROMACS uses a subset of C99 and C++11. A not fully standard compliant
+compiler might be able to compile GROMACS.
Getting good performance on an OS and architecture requires choosing a
good compiler. In practice, many compilers struggle to do a good job
optimizing the |Gromacs| architecture-optimized SIMD kernels.
+C++11 support requires both support in the compiler as well as in the
+C++ library. Multiple compilers do not provide their own library
+but use the system library. It is required to select a library with
+sufficient C++11 support. Both the Intel and clang compiler on Linux use
+the libstdc++ which comes with gcc as the default C++ library. 4.6.1 of
+that library is required. Also the C++ library version has to be
+supported by the compiler. To select the C++ library version use:
+
+* For Intel: ``CXXFLAGS=-gcc-name=/path/to/gcc/binary`` or make sure
+ that the correct gcc version is first in path (e.g. by loading the gcc
+ module)
+* For clang: ``CFLAGS=--gcc-toolchain=/path/to/gcc/folder
+ CXXFLAGS=--gcc-toolchain=/path/to/gcc/folder``. This folder should
+ contain ``include/c++``.
+* On Windows with e.g. Intel: at least MSVC 2013 is required. Load the
+ enviroment with vcvarsall.bat.
+
For best performance, the |Gromacs| team strongly recommends you get the
most recent version of your preferred compiler for your platform.
There is a large amount of |Gromacs| code that depends on effective
it works because we have tested it. We do test on Linux, Windows, and
Mac with a range of compilers and libraries for a range of our
configuration options. Every commit in our git source code repository
-is currently tested on x86 with gcc versions ranging from 4.1 through
-5.1, and versions 12 through 15 of the Intel compiler as well as Clang
+is currently tested on x86 with gcc versions ranging from 4.6 through
+5.1, and versions 14 and 15 of the Intel compiler as well as Clang
version 3.4 through 3.6. For this, we use a variety of GNU/Linux
flavors and versions as well as recent versions of Mac OS X and Windows. Under
Windows we test both MSVC and the Intel compiler. For details, you can
/** Define if we are building for Cygwin */
#cmakedefine GMX_CYGWIN
-/** Define if we have sufficient C++11 support */
-#cmakedefine01 GMX_CXX11
-
/* GCC bug in AVX maskload/maskstore arguments - worked around internally */
#cmakedefine GMX_SIMD_X86_AVX_GCC_MASKLOAD_BUG
endif()
endif()
-include(gmxGetGmockTupleWorkaround)
-get_gmock_tuple_workaround(GMOCK_COMPILE_DEFINITIONS)
-
# GTest/GMock suggest linking with pthreads when available for thread safety
set(CMAKE_THREAD_PREFER_PTHREAD 1)
find_package(Threads)
set(PTHREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif()
+# Skip variadic implementation of matchers if using GCC < 4.7 due to
+# GCC Bug 35722 -[C++0x] Variadic templates expansion into non-variadic class template
+if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
+ list(APPEND GMOCK_COMPILE_DEFINITIONS "GTEST_LANG_CXX11=0")
+endif()
+
set(GMOCK_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(GTEST_DIR ${GMOCK_DIR}/gtest)
set(GTEST_SOURCES ${GTEST_DIR}/src/gtest-all.cc)
REMOTE_HASH SOURCE_FILE)
list(APPEND LIBGROMACS_SOURCES ${GENERATED_VERSION_FILE})
-# apply gcc 4.4.x bug workaround
-if(GMX_USE_GCC44_BUG_WORKAROUND)
- include(gmxGCC44O3BugWorkaround)
- gmx_apply_gcc44_bug_workaround("listed-forces/bonded.cpp")
- gmx_apply_gcc44_bug_workaround("mdlib/force.c")
- gmx_apply_gcc44_bug_workaround("mdlib/constr.c")
-endif()
-
if (GMX_GPU AND NOT GMX_USE_OPENCL)
cuda_add_library(libgromacs ${LIBGROMACS_SOURCES})
else()
#include "gromacs/analysisdata/datamodulemanager.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
-#include "gromacs/utility/uniqueptr.h"
#include "dataproxy.h"
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "analysisdata.h"
+#include <memory>
+
#include "gromacs/analysisdata/dataframe.h"
#include "gromacs/analysisdata/datastorage.h"
#include "gromacs/analysisdata/paralleloptions.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
-#include "gromacs/utility/uniqueptr.h"
namespace gmx
{
{
public:
//! Smart pointer type to manage a data handle implementation.
- typedef gmx_unique_ptr<internal::AnalysisDataHandleImpl>::type
+ typedef std::unique_ptr<internal::AnalysisDataHandleImpl>
HandlePointer;
//! Shorthand for a list of data handles.
typedef std::vector<HandlePointer> HandleList;
}
Impl::HandlePointer handle(new internal::AnalysisDataHandleImpl(this));
- impl_->handles_.push_back(move(handle));
+ impl_->handles_.push_back(std::move(handle));
return AnalysisDataHandle(impl_->handles_.back().get());
}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include <algorithm>
#include <iterator>
#include <limits>
+#include <memory>
#include <vector>
#include "gromacs/analysisdata/abstractdata.h"
#include "gromacs/analysisdata/paralleloptions.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
-#include "gromacs/utility/uniqueptr.h"
namespace gmx
{
{
//! Smart pointer type for managing a storage frame builder.
-typedef gmx_unique_ptr<AnalysisDataStorageFrame>::type
+typedef std::unique_ptr<AnalysisDataStorageFrame>
AnalysisDataFrameBuilderPointer;
/*! \internal \brief
{
public:
//! Smart pointer type for managing a stored frame.
- typedef gmx_unique_ptr<AnalysisDataStorageFrameData>::type FramePointer;
+ typedef std::unique_ptr<AnalysisDataStorageFrameData> FramePointer;
//! Shorthand for a list of data frames that are currently stored.
typedef std::vector<FramePointer> FrameList;
{
return AnalysisDataFrameBuilderPointer(new AnalysisDataStorageFrame(*data_));
}
- AnalysisDataFrameBuilderPointer builder(move(builders_.back()));
+ AnalysisDataFrameBuilderPointer builder(std::move(builders_.back()));
builders_.pop_back();
- return move(builder);
+ return std::move(builder);
}
{
status_ = eStarted;
header_ = header;
- builder_ = move(builder);
+ builder_ = std::move(builder);
builder_->data_ = this;
builder_->selectDataSet(0);
}
GMX_RELEASE_ASSERT(!builder_->bPointSetInProgress_,
"Unfinished point set");
}
- AnalysisDataFrameBuilderPointer builder(move(builder_));
+ AnalysisDataFrameBuilderPointer builder(std::move(builder_));
builder_.reset();
- return move(builder);
+ return std::move(builder);
}
{
exportedTopics_.push_back(topic->name());
}
- addSubTopic(move(topic));
+ addSubTopic(std::move(topic));
}
//! Exports all the top-level topics with the given exporter.
void exportHelp(IHelpExport *exporter);
void CommandLineHelpModule::addTopic(HelpTopicPointer topic, bool bExported)
{
- impl_->rootTopic_->addTopic(move(topic), bExported);
+ impl_->rootTopic_->addTopic(std::move(topic), bExported);
}
void CommandLineHelpModule::setShowHidden(bool bHidden)
#define GMX_COMMANDLINE_CMDLINEMODULEMANAGER_IMPL_H
#include <map>
+#include <memory>
#include <string>
#include <vector>
#include "gromacs/options/options.h"
#include "gromacs/utility/classhelpers.h"
#include "gromacs/utility/gmxassert.h"
-#include "gromacs/utility/uniqueptr.h"
namespace gmx
{
};
//! Smart pointer type for managing a CommandLineModuleGroup.
-typedef gmx_unique_ptr<CommandLineModuleGroupData>::type
+typedef std::unique_ptr<CommandLineModuleGroupData>
CommandLineModuleGroupDataPointer;
//! Container type for keeping a list of module groups.
typedef std::vector<CommandLineModuleGroupDataPointer>
ensureHelpModuleExists();
HelpTopicPointer helpTopic(helpModule_->createModuleHelpTopic(*module));
modules_.insert(std::make_pair(std::string(module->name()),
- move(module)));
- helpModule_->addTopic(move(helpTopic), false);
+ std::move(module)));
+ helpModule_->addTopic(std::move(helpTopic), false);
}
void CommandLineModuleManager::Impl::ensureHelpModuleExists()
void CommandLineModuleManager::addModule(CommandLineModulePointer module)
{
- impl_->addModule(move(module));
+ impl_->addModule(std::move(module));
}
void CommandLineModuleManager::addModuleCMain(
{
CommandLineModulePointer module(
new CMainCommandLineModule(name, shortDescription, mainFunction));
- addModule(move(module));
+ addModule(std::move(module));
}
CommandLineModuleGroup CommandLineModuleManager::addModuleGroup(
const char *const binaryName = impl_->binaryName_.c_str();
CommandLineModuleGroupDataPointer group(
new CommandLineModuleGroupData(impl_->modules_, binaryName, title));
- impl_->moduleGroups_.push_back(move(group));
+ impl_->moduleGroups_.push_back(std::move(group));
return CommandLineModuleGroup(impl_->moduleGroups_.back().get());
}
void CommandLineModuleManager::addHelpTopic(HelpTopicPointer topic)
{
impl_->ensureHelpModuleExists();
- impl_->helpModule_->addTopic(move(topic), true);
+ impl_->helpModule_->addTopic(std::move(topic), true);
}
int CommandLineModuleManager::run(int argc, char *argv[])
#ifndef GMX_COMMANDLINE_CMDLINEMODULEMANAGER_H
#define GMX_COMMANDLINE_CMDLINEMODULEMANAGER_H
+#include <memory>
+
#include "gromacs/onlinehelp/ihelptopic.h"
#include "gromacs/utility/classhelpers.h"
-#include "gromacs/utility/uniqueptr.h"
namespace gmx
{
//! \{
//! Smart pointer type for managing a ICommandLineModule.
-typedef gmx_unique_ptr<ICommandLineModule>::type
+typedef std::unique_ptr<ICommandLineModule>
CommandLineModulePointer;
/*! \libinternal \brief
const char *description, FactoryMethod factory)
{
CommandLineModulePointer module(createModule(name, description, factory));
- manager->addModule(move(module));
+ manager->addModule(std::move(module));
}
// static
{
CommandLineModulePointer wrapperModule(
new CommandLineOptionsModule(name, description, module));
- manager->addModule(move(wrapperModule));
+ manager->addModule(std::move(wrapperModule));
}
} // namespace gmx
#include <cmath>
+#include <memory>
+
#include <gtest/gtest.h>
#include "gromacs/correlationfunctions/expfit.h"
#include "gromacs/fft/fft.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
-#include "gromacs/utility/uniqueptr.h"
#include "testutils/refdata.h"
#include "testutils/testasserts.h"
{
//! Definition of pointer to class containing test data.
-typedef gmx_unique_ptr<CorrelationDataSet>::type CorrelationDataSetPointer;
+typedef std::unique_ptr<CorrelationDataSet> CorrelationDataSetPointer;
class AutocorrTest : public ::testing::Test
{
#else
fprintf(fp, "RDTSCP usage: disabled\n");
#endif
-#if GMX_CXX11
- fprintf(fp, "C++11 compilation: enabled\n");
-#else
- fprintf(fp, "C++11 compilation: disabled\n");
-#endif
#ifdef GMX_USE_TNG
fprintf(fp, "TNG support: enabled\n");
#else
int *global_atom_index)
{
#ifdef GMX_SIMD_HAVE_REAL
- gmx_bool bUseSIMD;
- /* MSVC 2010 produces buggy SIMD PBC code, disable SIMD for MSVC <= 2010 */
-#if defined _MSC_VER && _MSC_VER < 1700 && !defined(__ICL)
- bUseSIMD = FALSE;
-#else
- bUseSIMD = fr->use_simd_kernels;
-#endif
+ gmx_bool bUseSIMD = fr->use_simd_kernels;
#endif
int nat1, nbonds, efptFTYPE;
#include "gromacs/utility/gmxomp.h"
#include "gromacs/utility/smalloc.h"
-/* MSVC 2010 produces buggy SIMD PBC code, disable SIMD for MSVC <= 2010 */
-#if defined GMX_SIMD_HAVE_REAL && !(defined _MSC_VER && _MSC_VER < 1700) && !defined(__ICL)
+#if defined GMX_SIMD_HAVE_REAL
#define LINCS_SIMD
#endif
const IHelpTopic *topicPtr = topic.get();
impl_->subTopics_.reserve(impl_->subTopics_.size() + 1);
impl_->subTopicMap_.insert(std::make_pair(std::string(topicPtr->name()), topicPtr));
- impl_->subTopics_.push_back(move(topic));
+ impl_->subTopics_.push_back(std::move(topic));
}
} // namespace gmx
#ifndef GMX_ONLINEHELP_HELPTOPIC_H
#define GMX_ONLINEHELP_HELPTOPIC_H
+#include <memory>
+
#include "gromacs/onlinehelp/ihelptopic.h"
#include "gromacs/utility/classhelpers.h"
#include "gromacs/utility/stringutil.h"
-#include "gromacs/utility/uniqueptr.h"
namespace gmx
{
*
* \inlibraryapi
*/
-typedef gmx_unique_ptr<AbstractCompositeHelpTopic>::type
+typedef std::unique_ptr<AbstractCompositeHelpTopic>
CompositeHelpTopicPointer;
//! \endcond
#ifndef GMX_ONLINEHELP_IHELPTOPIC_H
#define GMX_ONLINEHELP_IHELPTOPIC_H
-#include "gromacs/utility/uniqueptr.h"
+#include <memory>
namespace gmx
{
};
//! Smart pointer type to manage a IHelpTopic object.
-typedef gmx_unique_ptr<IHelpTopic>::type HelpTopicPointer;
+typedef std::unique_ptr<IHelpTopic> HelpTopicPointer;
} // namespace gmx
gmx::CompositeHelpTopicPointer topic(new gmx::CompositeHelpTopic<TestHelpText>);
MockHelpTopic::addSubTopic(topic.get(), "subtopic", "First subtopic", "Text");
MockHelpTopic::addSubTopic(topic.get(), "other", "Second subtopic", "Text");
- rootTopic_.addSubTopic(move(topic));
+ rootTopic_.addSubTopic(std::move(topic));
checkHelpFormatting();
}
#include <list>
#include <map>
+#include <memory>
#include <string>
#include <vector>
#include "gromacs/options/abstractoption.h"
#include "gromacs/options/optionmanagercontainer.h"
#include "gromacs/options/options.h"
-#include "gromacs/utility/uniqueptr.h"
namespace gmx
{
};
//! Smart pointer for managing an AbstractOptionStorage object.
- typedef gmx_unique_ptr<AbstractOptionStorage>::type
+ typedef std::unique_ptr<AbstractOptionStorage>
AbstractOptionStoragePointer;
//! Convenience type for list of sections.
typedef std::vector<Options *> SubSectionList;
options_.reserve(options_.size() + 1);
std::pair<OptionMap::iterator, bool> insertionResult =
parent_->optionMap_.insert(std::make_pair(option->name(),
- move(option)));
+ std::move(option)));
if (!insertionResult.second)
{
GMX_THROW(APIError("Duplicate option: " + option->name()));
{
gmx_simd_real_t shz, shy, shx;
-#if defined _MSC_VER && _MSC_VER < 1700 && !defined(__ICL)
- /* The caller side should make sure we never end up here.
- * TODO Black-list _MSC_VER < 1700 when it's old enough, so we can rid
- * of this code complication.
- */
- gmx_incons("pbc_correct_dx_simd was called for code compiled with MSVC 2010 or older, which produces incorrect code (probably corrupts memory) and therefore this function should not have been called");
-#endif
-
shz = gmx_simd_round_r(gmx_simd_mul_r(*dz, pbc->inv_bzz));
*dx = gmx_simd_fnmadd_r(shz, pbc->bzx, *dx);
*dy = gmx_simd_fnmadd_r(shz, pbc->bzy, *dy);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
BEGIN_ACTION;
SelectionParserParameterListPointer list(get((yyvsp[(1) - (2)].plist)));
list->push_back(get((yyvsp[(2) - (2)].param)));
- set((yyval.plist), move(list));
+ set((yyval.plist), std::move(list));
END_ACTION;
}
break;
BEGIN_ACTION;
SelectionParserValueListPointer list(get((yyvsp[(1) - (2)].vlist)));
list->push_back(get((yyvsp[(2) - (2)].val)));
- set((yyval.vlist), move(list));
+ set((yyval.vlist), std::move(list));
END_ACTION;
}
break;
BEGIN_ACTION;
SelectionParserValueListPointer list(get((yyvsp[(1) - (3)].vlist)));
list->push_back(get((yyvsp[(3) - (3)].val)));
- set((yyval.vlist), move(list));
+ set((yyval.vlist), std::move(list));
END_ACTION;
}
break;
BEGIN_ACTION;
SelectionParserValueListPointer list(get((yyvsp[(1) - (2)].vlist)));
list->push_back(get((yyvsp[(2) - (2)].val)));
- set((yyval.vlist), move(list));
+ set((yyval.vlist), std::move(list));
END_ACTION;
}
break;
BEGIN_ACTION;
SelectionParserValueListPointer list(get((yyvsp[(1) - (3)].vlist)));
list->push_back(get((yyvsp[(3) - (3)].val)));
- set((yyval.vlist), move(list));
+ set((yyval.vlist), std::move(list));
END_ACTION;
}
break;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
BEGIN_ACTION;
SelectionParserParameterListPointer list(get($1));
list->push_back(get($2));
- set($$, move(list));
+ set($$, std::move(list));
END_ACTION;
}
;
BEGIN_ACTION;
SelectionParserValueListPointer list(get($1));
list->push_back(get($2));
- set($$, move(list));
+ set($$, std::move(list));
END_ACTION;
}
| value_list_contents ',' value_item
BEGIN_ACTION;
SelectionParserValueListPointer list(get($1));
list->push_back(get($3));
- set($$, move(list));
+ set($$, std::move(list));
END_ACTION;
}
;
BEGIN_ACTION;
SelectionParserValueListPointer list(get($1));
list->push_back(get($2));
- set($$, move(list));
+ set($$, std::move(list));
END_ACTION;
}
| basic_value_list_contents ',' basic_value_item
BEGIN_ACTION;
SelectionParserValueListPointer list(get($1));
list->push_back(get($3));
- set($$, move(list));
+ set($$, std::move(list));
END_ACTION;
}
;
#ifndef GMX_SELECTION_PARSER_INTERNAL_H
#define GMX_SELECTION_PARSER_INTERNAL_H
-#include "config.h"
-
#include <exception>
#include <boost/exception_ptr.hpp>
}
//!\}
-#if !GMX_CXX11
-//! No-op to enable use of same get()/set() implementation as with C++11.
-static gmx::SelectionParserValue &move(gmx::SelectionParserValue &src)
-{
- return src;
-}
-//! No-op to enable use of same get()/set() implementation as with C++11.
-static gmx::SelectionParserParameter &move(gmx::SelectionParserParameter &src)
-{
- return src;
-}
-#endif
-
/*! \brief
* Retrieves a semantic value.
*
* \param[in] src Semantic value to get the value from.
* \returns Retrieved value.
* \throws unspecified Any exception thrown by the move constructor of
- * ValueType (copy constructor if GMX_CXX11 is 0).
+ * ValueType.
*
* There should be no statements that may throw exceptions in actions before
* this function has been called for all semantic values that have a C++ object
{
GMX_RELEASE_ASSERT(src != NULL, "Semantic value pointers should be non-NULL");
boost::scoped_ptr<ValueType> srcGuard(src);
- return ValueType(move(*src));
+ return ValueType(std::move(*src));
}
/*! \brief
* Sets a semantic value.
* \param[in] value Value to put into the semantic value.
* \throws std::bad_alloc if out of memory.
* \throws unspecified Any exception thrown by the move constructor of
- * ValueType (copy constructor if GMX_CXX11 is 0).
+ * ValueType.
*
* This should be the last statement before ::END_ACTION, except for a
* possible ::CHECK_SEL.
template <typename ValueType> static
void set(ValueType * &dest, ValueType value)
{
- dest = new ValueType(move(value));
+ dest = new ValueType(std::move(value));
}
/*! \brief
* Sets an empty semantic value.
SelectionParserValueListPointer values,
const SelectionLocation &location)
: name_(name != NULL ? name : ""), location_(location),
- values_(values ? move(values)
+ values_(values ? std::move(values)
: SelectionParserValueListPointer(new SelectionParserValueList))
{
}
params.push_back(
SelectionParserParameter::createFromExpression(NULL, child));
params.push_back(
- SelectionParserParameter::create(NULL, move(args), location));
+ SelectionParserParameter::create(NULL, std::move(args), location));
_gmx_sel_parse_params(params, root->u.expr.method->nparams,
root->u.expr.method->param, root, scanner);
}
gmx::SelectionParserValueListPointer args,
const char *rpost, yyscan_t scanner)
{
- return init_keyword_internal(method, gmx::eStringMatchType_Auto, move(args),
+ return init_keyword_internal(method, gmx::eStringMatchType_Auto, std::move(args),
rpost, scanner);
}
"String keyword method called for a non-string-valued method");
GMX_RELEASE_ASSERT(args && !args->empty(),
"String keyword matching method called without any values");
- return init_keyword_internal(method, matchType, move(args), rpost, scanner);
+ return init_keyword_internal(method, matchType, std::move(args), rpost, scanner);
}
/*!
gmx::SelectionDataPointer selPtr(
new gmx::internal::SelectionData(
sel.get(), _gmx_sel_lexer_pselstr(scanner)));
- sc->sel.push_back(gmx::move(selPtr));
+ sc->sel.push_back(std::move(selPtr));
}
}
/* Clear the selection string now that we've saved it */
#include <exception>
#include <list>
+#include <memory>
#include <string>
#include "gromacs/math/vec.h"
#include "gromacs/math/vectypes.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/real.h"
-#include "gromacs/utility/uniqueptr.h"
#include "selelem.h"
#include "selvalue.h"
typedef std::list<SelectionParserValue>
SelectionParserValueList;
//! Smart pointer type for managing a SelectionParserValueList.
-typedef gmx::gmx_unique_ptr<SelectionParserValueList>::type
+typedef std::unique_ptr<SelectionParserValueList>
SelectionParserValueListPointer;
/*! \internal
{
SelectionParserValueListPointer list(new SelectionParserValueList);
list->push_back(value);
- return move(list);
+ return std::move(list);
}
/*! \brief
* Allocates and initializes an expression value.
typedef std::list<SelectionParserParameter>
SelectionParserParameterList;
//! Smart pointer type for managing a SelectionParserParameterList.
-typedef gmx::gmx_unique_ptr<SelectionParserParameterList>::type
+typedef std::unique_ptr<SelectionParserParameterList>
SelectionParserParameterListPointer;
/*! \internal \brief
class SelectionParserParameter
{
public:
+ // Default move constructor and assignment. Only needed for old compilers.
+ //! \cond
+ SelectionParserParameter(SelectionParserParameter &&o)
+ : name_(std::move(o.name_)), location_(std::move(o.location_)),
+ values_(std::move(o.values_))
+ {
+ }
+
+ SelectionParserParameter &operator=(SelectionParserParameter &&o)
+ {
+ name_ = std::move(o.name_);
+ location_ = std::move(o.location_);
+ values_ = std::move(o.values_);
+ return *this;
+ }
+ //! \endcond
+
//! Allocates and initializes an empty parameter list.
static SelectionParserParameterListPointer createList()
{
create(const char *name, SelectionParserValueListPointer values,
const SelectionLocation &location)
{
- return SelectionParserParameter(name, move(values), location);
+ return SelectionParserParameter(name, std::move(values), location);
}
//! \copydoc create(const char *, SelectionParserValueListPointer, const SelectionLocation &)
static SelectionParserParameter
create(const std::string &name, SelectionParserValueListPointer values,
const SelectionLocation &location)
{
- return SelectionParserParameter(name.c_str(), move(values), location);
+ return SelectionParserParameter(name.c_str(), std::move(values), location);
}
/*! \brief
* Allocates and initializes a parsed method parameter.
#ifndef GMX_SELECTION_SELECTIONCOLLECTION_IMPL_H
#define GMX_SELECTION_SELECTIONCOLLECTION_IMPL_H
+#include <memory>
#include <string>
#include <vector>
#include "gromacs/selection/indexutil.h"
#include "gromacs/selection/selection.h" // For gmx::SelectionList
#include "gromacs/selection/selectioncollection.h"
-#include "gromacs/utility/uniqueptr.h"
#include "poscalc.h"
#include "selelem.h"
{
//! Smart pointer for managing an internal selection data object.
-typedef gmx_unique_ptr<internal::SelectionData>::type SelectionDataPointer;
+typedef std::unique_ptr<internal::SelectionData> SelectionDataPointer;
//! Container for storing a list of selections internally.
typedef std::vector<SelectionDataPointer> SelectionDataList;
root->registerSubTopic<SimpleHelpTopic<EvaluationHelpText> >();
root->registerSubTopic<SimpleHelpTopic<LimitationsHelpText> >();
root->registerSubTopic<SimpleHelpTopic<ExamplesHelpText> >();
- return move(root);
+ return std::move(root);
}
//! \endcond
#include "symrec.h"
#include <map>
+#include <memory>
#include <string>
#include <utility>
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/stringutil.h"
-#include "gromacs/utility/uniqueptr.h"
#include "poscalc.h"
#include "selelem.h"
{
public:
//! Smart pointer type for managing a SelectionParserSymbol.
- typedef gmx::gmx_unique_ptr<SelectionParserSymbol>::type
+ typedef std::unique_ptr<SelectionParserSymbol>
SymbolPointer;
//! Container type for the list of symbols.
typedef std::map<std::string, SymbolPointer> SymbolMap;
void
SelectionParserSymbolTable::Impl::addSymbol(SymbolPointer symbol)
{
- symbols_.insert(std::make_pair(symbol->name(), move(symbol)));
+ symbols_.insert(std::make_pair(symbol->name(), std::move(symbol)));
}
void
SymbolPointer sym(new SelectionParserSymbol(
new SelectionParserSymbol::Impl(
SelectionParserSymbol::ReservedSymbol, sym_reserved[i])));
- addSymbol(move(sym));
+ addSymbol(std::move(sym));
}
}
SymbolPointer sym(new SelectionParserSymbol(
new SelectionParserSymbol::Impl(
SelectionParserSymbol::PositionSymbol, postypes[i])));
- addSymbol(move(sym));
+ addSymbol(std::move(sym));
}
}
new SelectionParserSymbol::Impl(
SelectionParserSymbol::VariableSymbol, name)));
sym->impl_->var_ = sel;
- impl_->addSymbol(move(sym));
+ impl_->addSymbol(std::move(sym));
}
void
new SelectionParserSymbol::Impl(
SelectionParserSymbol::MethodSymbol, name)));
sym->impl_->meth_ = method;
- impl_->addSymbol(move(sym));
+ impl_->addSymbol(std::move(sym));
}
} // namespace gmx
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gromacs/selection/poscalc.h"
+#include <memory>
#include <vector>
#include <gtest/gtest.h>
#include "gromacs/selection/position.h"
#include "gromacs/topology/topology.h"
#include "gromacs/utility/smalloc.h"
-#include "gromacs/utility/uniqueptr.h"
#include "testutils/refdata.h"
gmx::PositionCalculationCollection pcc_;
private:
- typedef gmx::gmx_unique_ptr<gmx_ana_pos_t>::type PositionPointer;
+ typedef std::unique_ptr<gmx_ana_pos_t> PositionPointer;
struct PositionTest
{
PositionTest(PositionPointer pos, gmx_ana_poscalc_t *pc,
const char *name)
- : pos(gmx::move(pos)), pc(pc), name(name)
+ : pos(std::move(pos)), pc(pc), name(name)
{
}
+ // Default move constructor and assignment. Only needed for old compilers.
+ PositionTest(PositionTest &&o)
+ : pos(std::move(o.pos)), pc(o.pc), name(o.name)
+ {
+ }
+
+ PositionTest &operator= (PositionTest &&o)
+ {
+ pos = std::move(o.pos);
+ pc = o.pc;
+ name = o.name;
+ return *this;
+ }
+
PositionPointer pos;
gmx_ana_poscalc_t *pc;
const char *name;
posList_.reserve(posList_.size() + 1);
PositionPointer p(new gmx_ana_pos_t());
gmx_ana_pos_t *result = p.get();
- posList_.push_back(PositionTest(gmx::move(p), pc, name));
+ posList_.push_back(PositionTest(std::move(p), pc, name));
gmx_ana_poscalc_init_pos(pc, result);
return result;
}
{
CommandLineModulePointer module(
new Impl::RunnerCommandLineModule(name, description, factory));
- manager->addModule(move(module));
+ manager->addModule(std::move(module));
}
} // namespace gmx
* The header qsort_threadsafe.h provides a guaranteed threadsafe
* implementation for qsort().
*
- * The header uniqueptr.h declares gmx::gmx_unique_ptr, which is intended for
- * declaring smart pointer types with unique ownership.
- *
* \endif
*
* \author Teemu Murtola <teemu.murtola@gmail.com>
#ifndef GMX_UTILITY_SCOPED_PTR_SFREE_H
#define GMX_UTILITY_SCOPED_PTR_SFREE_H
-#include "config.h"
-
#include "gromacs/utility/classhelpers.h"
#include "gromacs/utility/smalloc.h"
//! Returns the stored pointer.
T *get() const { return ptr_; }
//! Check for non-null pointer in boolean context.
-#if GMX_CXX11
- explicit
-#endif
- operator bool () const { return ptr_ != 0; }
+ explicit operator bool () const { return ptr_ != 0; }
//! Sets the pointer and frees previous pointer if necessary.
void reset(T *ptr) { D(ptr_); ptr_ = ptr; }
//! Clears the pointer without freeing the memory, and returns the old value.
+++ /dev/null
-/*
- * This file is part of the GROMACS molecular simulation package.
- *
- * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
- * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
- * and including many others, as listed in the AUTHORS file in the
- * top-level source directory and at http://www.gromacs.org.
- *
- * GROMACS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * GROMACS 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with GROMACS; if not, see
- * http://www.gnu.org/licenses, or write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * If you want to redistribute modifications to GROMACS, please
- * consider that scientific software is very special. Version
- * control is crucial - bugs must be traceable. We will be happy to
- * consider code for inclusion in the official distribution, but
- * derived work must not be called official GROMACS. Details are found
- * in the README & COPYING files - if they are missing, get the
- * official version at http://www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the research papers on the package. Check out http://www.gromacs.org.
- */
-/*! \libinternal \file
- * \brief
- * Declares gmx::gmx_unique_ptr and supporting functionality.
- *
- * \author Roland Schulz <roland@utk.edu>
- * \author John Eblen <jeblen@acm.org>
- * \inlibraryapi
- * \ingroup module_utility
- */
-#ifndef GMX_UTILITY_UNIQUEPTR_H
-#define GMX_UTILITY_UNIQUEPTR_H
-
-#include "config.h"
-
-#if GMX_CXX11 // C++11 Compiler
-#include <memory> // IWYU pragma: export
-#include <utility> // IWYU pragma: export
-#else // C++03 Compiler
-#include <boost/shared_ptr.hpp>
-#endif
-
-namespace gmx
-{
-
-//! \cond libapi
-/*! \libinternal \class gmx_unique_ptr
- * \brief
- * Smart pointer for unique ownership.
- *
- * The \a type member typedef declares the actual smart pointer type.
- * If std::unique_ptr from C++11 is available, it is used, otherwise maps to
- * boost::shared_ptr. Because of this, there are some limitations to usage.
- * gmx::move() should be used to move the pointer.
- *
- * Avoid using directly as a type, use a typedef instead. Typical usage:
- * \code
- typedef gmx_unique_ptr<ExampleClass>::type ExampleClassPointer;
- \endcode
- *
- * \ingroup module_utility
- * \inlibraryapi
- */
-/*! \libinternal \typedef gmx_unique_ptr::type
- * \brief The smart pointer type.
- * Work-around for the non-existence of template typedefs in C++03.
- */
-#if GMX_CXX11 // C++11 Compiler
-using std::move;
-template<typename T>
-struct gmx_unique_ptr
-{
- typedef std::unique_ptr<T> type;
-};
-#else // C++03 Compiler
-/*! \fn boost::shared_ptr<T> &move(boost::shared_ptr<T> &ptr)
- * \brief
- * Moves gmx::gmx_unique_ptr type pointers
- *
- * For C++11 gmx::move is the std::move, for non-C++11 compilers, the
- * move operation is a no-op.
- *
- * \inlibraryapi
- */
-template<typename T>
-boost::shared_ptr<T> &move(boost::shared_ptr<T> &ptr)
-{
- return ptr;
-}
-template<typename T>
-struct gmx_unique_ptr
-{
- typedef boost::shared_ptr<T> type;
-};
-#endif
-//! \endcond
-
-} // namespace gmx
-
-#endif
{
gmx::CommandLineModulePointer module(
new NoNiceModule(name, shortDescription, mainFunction));
- manager->addModule(move(module));
+ manager->addModule(std::move(module));
}
/*! \brief
const char *name)
{
gmx::CommandLineModulePointer module(new ObsoleteToolModule(name));
- manager->addModule(move(module));
+ manager->addModule(std::move(module));
}
} // namespace
* \ingroup module_mdrun
*/
+#include <memory>
#include <string>
#include <gtest/gtest.h>
-#include "gromacs/utility/uniqueptr.h"
-
#include "testutils/cmdlinetest.h"
#include "moduletest.h"
{
//! Convenience typedef
-typedef gmx_unique_ptr<CommandLine>::type CommandLinePointer;
+typedef std::unique_ptr<CommandLine> CommandLinePointer;
class MultiSimTest : public gmx::test::ParameterizedMdrunTestFixture
{
#define GMX_TESTUTILS_REFDATA_IMPL_H
#include <list>
+#include <memory>
#include <string>
#include "gromacs/utility/gmxassert.h"
-#include "gromacs/utility/uniqueptr.h"
namespace gmx
{
class ReferenceDataEntry
{
public:
- typedef gmx_unique_ptr<ReferenceDataEntry>::type EntryPointer;
+ typedef std::unique_ptr<ReferenceDataEntry> EntryPointer;
typedef std::list<EntryPointer> ChildList;
typedef ChildList::const_iterator ChildIterator;