Skip to content

The public CPP API from PGM should rely on c++17 standard #930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions power_grid_model_c/power_grid_model_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ target_sources(power_grid_model_cpp PUBLIC
set_target_properties(power_grid_model_cpp PROPERTIES
VERSION ${PGM_VERSION}
SOVERSION ${PGM_VERSION}
CXX_STANDARD 17
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,19 @@ constexpr double nan = std::numeric_limits<double>::quiet_NaN();
constexpr int8_t na_IntS = std::numeric_limits<int8_t>::min();
constexpr ID na_IntID = std::numeric_limits<ID>::min();

template <std::same_as<double> T> constexpr T nan_value() { return nan; }
template <std::same_as<std::array<double, 3>> T> constexpr T nan_value() { return {nan, nan, nan}; }
template <std::same_as<ID> T> constexpr T nan_value() { return na_IntID; }
template <std::same_as<int8_t> T> constexpr T nan_value() { return na_IntS; }
template <typename T> constexpr T nan_value() {
if constexpr (std::is_same_v<T, double>) {
return nan;
} else if constexpr (std::is_same_v<T, ID>) {
return na_IntID;
} else if constexpr (std::is_same_v<T, int8_t>) {
return na_IntS;
} else if constexpr (std::is_same_v<T, std::array<double, 3>>) {
return std::array<double, 3>{nan, nan, nan};
} else {
static_assert(false, "Unsupported type for nan_value");
}
}

class UnsupportedPGM_CType : public PowerGridError {
public:
Expand Down
2 changes: 1 addition & 1 deletion tests/package_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmake_minimum_required (VERSION 3.23)

project(power_grid_model_package_tests)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
Expand Down
Loading