Skip to content

Commit

Permalink
fix(cc): remove C++ 17 usage
Browse files Browse the repository at this point in the history
  • Loading branch information
njzjz authored Jan 24, 2025
1 parent a68b313 commit 2a1efbd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ set(DEEPMD_C_ROOT
""
CACHE PATH "Path to imported DeePMD-kit C library")

set(CMAKE_CXX_STANDARD 11)
if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
macro(set_if_higher VARIABLE VALUE)
# ${VARIABLE} is a variable name, not a string
if(${VARIABLE} LESS "${VALUE}")
Expand Down
4 changes: 2 additions & 2 deletions source/api_cc/src/DeepPotPT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void DeepPotPT::compute(ENERGYVTYPE& ener,
int natoms = atype.size();
auto options = torch::TensorOptions().dtype(torch::kFloat64);
torch::ScalarType floatType = torch::kFloat64;
if (std::is_same_v<VALUETYPE, float>) {
if (std::is_same<VALUETYPE, float>::value) {
options = torch::TensorOptions().dtype(torch::kFloat32);
floatType = torch::kFloat32;
}
Expand Down Expand Up @@ -341,7 +341,7 @@ void DeepPotPT::compute(ENERGYVTYPE& ener,
int natoms = atype.size();
auto options = torch::TensorOptions().dtype(torch::kFloat64);
torch::ScalarType floatType = torch::kFloat64;
if (std::is_same_v<VALUETYPE, float>) {
if (std::is_same<VALUETYPE, float>::value) {
options = torch::TensorOptions().dtype(torch::kFloat32);
floatType = torch::kFloat32;
}
Expand Down
4 changes: 2 additions & 2 deletions source/api_cc/src/DeepSpinPT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void DeepSpinPT::compute(ENERGYVTYPE& ener,
int natoms = atype.size();
auto options = torch::TensorOptions().dtype(torch::kFloat64);
torch::ScalarType floatType = torch::kFloat64;
if (std::is_same_v<VALUETYPE, float>) {
if (std::is_same<VALUETYPE, float>::value) {
options = torch::TensorOptions().dtype(torch::kFloat32);
floatType = torch::kFloat32;
}
Expand Down Expand Up @@ -365,7 +365,7 @@ void DeepSpinPT::compute(ENERGYVTYPE& ener,
int natoms = atype.size();
auto options = torch::TensorOptions().dtype(torch::kFloat64);
torch::ScalarType floatType = torch::kFloat64;
if (std::is_same_v<VALUETYPE, float>) {
if (std::is_same<VALUETYPE, float>::value) {
options = torch::TensorOptions().dtype(torch::kFloat32);
floatType = torch::kFloat32;
}
Expand Down

0 comments on commit 2a1efbd

Please sign in to comment.