From 5dcb650651a9a65c9dd7249f9ad383e8565be657 Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Thu, 9 Dec 2021 17:44:49 +0000 Subject: [PATCH 1/2] first cut requiring c++17 Only used a bit of basic c++17 to pull some of the crud out of tuple. Now uses overload resolution for get rather than template instantiation. --- .gitignore | 8 ++++++-- CMakeLists.txt | 11 +++++------ include/camp/tuple.hpp | 25 ++++++++++++++----------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index a9427bd9..047c4574 100644 --- a/.gitignore +++ b/.gitignore @@ -10,9 +10,13 @@ .vscode/ .cache/ +# codespaces clean +.venv/ + # build directories -build/ -build-*/ +/build/ +/build-*/ +/*-build/ cmake-build-*/ docker-*-build/ /Debug/ diff --git a/CMakeLists.txt b/CMakeLists.txt index a640eeaa..842ed9a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,19 +4,18 @@ project (camp LANGUAGES CXX C VERSION 0.1.0) -# Default to C++11 if not set so GTest/GMock can build +# Default to C++17 if not set so GTest/GMock can build if (NOT BLT_CXX_STD) - set(BLT_CXX_STD "c++14" CACHE STRING "") + set(BLT_CXX_STD "c++17" CACHE STRING "") else() - set(_unsupported_cxx "c++98" "c++11") + set(_unsupported_cxx "c++98" "c++11" "c++14") if (BLT_CXX_STD IN_LIST _unsupported_cxx) - message(FATAL_ERROR "CAMP and the RAJA framework no longer support c++11, select a c++ standard of 14 or higher") + message(FATAL_ERROR "CAMP and the RAJA framework no longer support c++ standards below c++17, select a c++ standard of 14 or higher") endif() endif() include(cmake/load_blt.cmake) - cmake_dependent_option(CAMP_ENABLE_TESTS "Build tests" On "ENABLE_TESTS" Off) # if ENABLE_TESTS is defined by a parent project, and @@ -112,7 +111,7 @@ target_include_directories (camp INTERFACE ) set_target_properties (camp PROPERTIES INTERFACE_LIB_VERSION $camp_VERSION - INTERFACE_COMPILE_FEATURES cxx_std_14) + INTERFACE_COMPILE_FEATURES cxx_std_17) include(CMakePackageConfigHelpers) diff --git a/include/camp/tuple.hpp b/include/camp/tuple.hpp index e0fed385..0ccb5d20 100644 --- a/include/camp/tuple.hpp +++ b/include/camp/tuple.hpp @@ -106,12 +106,15 @@ namespace internal { } - CAMP_HOST_DEVICE constexpr const Type& get_inner() const noexcept + CAMP_HOST_DEVICE constexpr auto& get_inner(::camp::num) const noexcept { return val; } - CAMP_HOST_DEVICE constexpr Type& get_inner() noexcept { return val; } + CAMP_HOST_DEVICE constexpr auto& get_inner(::camp::num) noexcept + { + return val; + } public: Type val; @@ -130,12 +133,12 @@ namespace internal { } - CAMP_HOST_DEVICE constexpr const Type& get_inner() const noexcept + CAMP_HOST_DEVICE constexpr const Type& get_inner(::camp::num) const noexcept { return ((Type const*)this)[0]; } - CAMP_HOST_DEVICE constexpr Type& get_inner() noexcept + CAMP_HOST_DEVICE constexpr Type& get_inner(::camp::num) noexcept { return ((Type*)this)[0]; } @@ -151,7 +154,7 @@ CAMP_HOST_DEVICE constexpr auto& get(const Tuple& t) noexcept { using internal::tpl_get_store; static_assert(tuple_size::value > index, "index out of range"); - return static_cast const&>(t.base).get_inner(); + return t.base.get_inner(num{}); } template @@ -159,7 +162,7 @@ CAMP_HOST_DEVICE constexpr auto& get(Tuple& t) noexcept { using internal::tpl_get_store; static_assert(tuple_size::value > index, "index out of range"); - return static_cast&>(t.base).get_inner(); + return t.base.get_inner(num{}); } // by type @@ -171,8 +174,7 @@ CAMP_HOST_DEVICE constexpr auto& get(const Tuple& t) noexcept static_assert(!std::is_same::value, "invalid type index"); - return static_cast&>(t.base) - .get_inner(); + return t.base.get_inner(index_type{}); } template @@ -183,8 +185,7 @@ CAMP_HOST_DEVICE constexpr auto& get(Tuple& t) noexcept static_assert(!std::is_same::value, "invalid type index"); - return static_cast&>(t.base) - .get_inner(); + return t.base.get_inner(index_type{}); } namespace internal @@ -228,10 +229,12 @@ namespace internal template CAMP_HOST_DEVICE tuple_helper& operator=(const RTuple& rhs) { - return (camp::sink((this->tuple_storage::get_inner() = + return (camp::sink((this->get_inner(num{}) = ::camp::get(rhs))...), *this); } + + using internal::tuple_storage::get_inner...; }; template From 6e4d2f8580e5a11498a38eb61055c80d090bb6b4 Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Thu, 9 Dec 2021 16:28:53 -0800 Subject: [PATCH 2/2] Update CMakeLists.txt Co-authored-by: Rich Hornung --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 842ed9a6..219ac02c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ if (NOT BLT_CXX_STD) else() set(_unsupported_cxx "c++98" "c++11" "c++14") if (BLT_CXX_STD IN_LIST _unsupported_cxx) - message(FATAL_ERROR "CAMP and the RAJA framework no longer support c++ standards below c++17, select a c++ standard of 14 or higher") + message(FATAL_ERROR "CAMP and the RAJA framework no longer support c++ standards below c++17, select a c++ standard of 17 or higher") endif() endif()