Skip to content

Commit

Permalink
Raise minimum C++ standard to 20
Browse files Browse the repository at this point in the history
This will make our lives a lot easier with concepts, etc.
  • Loading branch information
stephenswat committed Jul 30, 2024
1 parent 389a843 commit f7c0637
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 39 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
- "Release"
- "Debug"
CXX_STANDARD:
- 17
- 20
COMPILER:
- NAME: "gcc"
Expand All @@ -34,7 +33,7 @@ jobs:

runs-on: "ubuntu-latest"

container: ubuntu:22.04
container: ubuntu:24.04

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -83,7 +82,7 @@ jobs:
- "Release"
- "Debug"
CXX_STANDARD:
- 17
- 20
COMPILER:
- NAME: "gcc"
CXX: "g++"
Expand All @@ -95,7 +94,7 @@ jobs:

runs-on: "ubuntu-latest"

container: ubuntu:22.04
container: ubuntu:24.04

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -145,7 +144,6 @@ jobs:
- "Release"
- "Debug"
CXX_STANDARD:
- 17
- 20

name: "Windows/Core/${{ matrix.BUILD }}/MSVC/C++${{ matrix.CXX_STANDARD }}"
Expand Down
10 changes: 1 addition & 9 deletions lib/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@ target_include_directories(
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_compile_features(core INTERFACE cxx_std_17)

if(COVFIE_REQUIRE_CXX20)
target_compile_definitions(
core
INTERFACE
COVFIE_REQUIRE_CXX20
)
endif()
target_compile_features(core INTERFACE cxx_std_20)

if(COVFIE_QUIET)
target_compile_definitions(
Expand Down
5 changes: 1 addition & 4 deletions lib/core/covfie/core/concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@

#pragma once

#include <concepts>
#include <iostream>
#include <optional>

#include <covfie/core/definitions.hpp>
#include <covfie/core/parameter_pack.hpp>

#if __cpp_concepts >= 201907L
#include <concepts>
namespace covfie::concepts {
template <typename T>
concept is_initial = T::is_initial == true;
Expand Down Expand Up @@ -243,4 +241,3 @@ concept field_backend = requires
template <typename T>
concept vector_descriptor = true;
}
#endif
19 changes: 0 additions & 19 deletions lib/core/covfie/core/definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,7 @@

#pragma once

#if __cpp_concepts >= 201907L
#define CONSTRAINT(x) x
#elif defined(COVFIE_REQUIRE_CXX20)
#error "C++20 concepts are not supported by the current compiler. The build \
is configured to reject such set-ups. Consider upgrating to C++20 or \
disabling the COVFIE_REQUIRE_CXX20 flag."
#else
#if !defined(COVFIE_QUIET)
#ifdef _WIN32
#pragma message("C++20 concepts are not supported by the current compiler.\n" \
"covfie will compile as normal, but compile-time\n" \
"guarantees will be weaker. Consider upgrading to C++20.")
#else
#pragma message "C++20 concepts are not supported by the current compiler. \
covfie will compile as normal, but compile-time guarantees will be \
weaker. Consider upgrading to C++20."
#endif // _WIN32
#endif
#define CONSTRAINT(x) typename
#endif

#ifdef _MSC_VER
#define UNLIKELY(x) x
Expand Down
2 changes: 1 addition & 1 deletion lib/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ target_include_directories(
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_compile_features(cpu INTERFACE cxx_std_17)
target_compile_features(cpu INTERFACE cxx_std_20)

# Logic to ensure that the CPU module can be installed properly.
install(
Expand Down
2 changes: 1 addition & 1 deletion lib/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ target_include_directories(
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_compile_features(cuda INTERFACE cxx_std_17)
target_compile_features(cuda INTERFACE cxx_std_20)

target_link_libraries(
cuda
Expand Down

0 comments on commit f7c0637

Please sign in to comment.