diff --git a/CMakeLists.txt b/CMakeLists.txt index 876052be1..988ee6523 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -302,8 +302,8 @@ else() message(WARNING "shellcheck not found, skipping") endif() -# Use C++11, but without GNU or other extensions -set(CMAKE_CXX_STANDARD 11) +# Use C++17, but without GNU or other extensions +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_EXTENSIONS OFF) # Export compile_commands.json for clang-tidy diff --git a/src/libaktualizr/utilities/utils.h b/src/libaktualizr/utilities/utils.h index 64ff81879..2bfb260ba 100644 --- a/src/libaktualizr/utilities/utils.h +++ b/src/libaktualizr/utilities/utils.h @@ -172,39 +172,10 @@ static void curlEasySetoptWrapper(CURL *curl_handle, CURLoption option, T &&...a } } -// this is reference implementation of make_unique which is not yet included to C++11 +// Aktualizr used to compile on C++11, where std::make_unique wasn't present. +// std_ used to contain an implementation of make_unique, and there are various +// references throughout the codebase. This provides backwards compatbility. namespace std_ { -template -struct _Unique_if { // NOLINT(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) - using _Single_object = std::unique_ptr; // NOLINT(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) -}; - -template -// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays,bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) -struct _Unique_if { - // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays,bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) - using _Unknown_bound = std::unique_ptr; -}; - -template -// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays,bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) -struct _Unique_if { - using _Known_bound = void; // NOLINT(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) -}; - -template -typename _Unique_if::_Single_object make_unique(Args &&...args) { - return std::unique_ptr(new T(std::forward(args)...)); -} - -template -typename _Unique_if::_Unknown_bound make_unique(size_t n) { - using U = typename std::remove_extent::type; - return std::unique_ptr(new U[n]()); +using std::make_unique; } - -template -typename _Unique_if::_Known_bound make_unique(Args &&...) = delete; -} // namespace std_ - #endif // UTILS_H_