Skip to content

Commit 11ad7d7

Browse files
fix(cc): remove C++ 17 usage (deepmodeling#4570)
Fix deepmodeling#4569. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Build Configuration** - Enhanced flexibility in C++ standard settings based on project dependencies - Added conditional checks for setting C++ standard version - **Code Improvements** - Updated type checking mechanisms in compute methods - Refined method signatures for handling different data types in DeepPotPT and DeepSpinPT classes - **Technical Refinements** - Improved conditional compilation and configuration handling - Introduced more flexible type-specific method overloads <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a68b313 commit 11ad7d7

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

source/CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ set(DEEPMD_C_ROOT
1515
""
1616
CACHE PATH "Path to imported DeePMD-kit C library")
1717

18-
set(CMAKE_CXX_STANDARD 11)
18+
if(NOT DEFINED CMAKE_CXX_STANDARD)
19+
set(CMAKE_CXX_STANDARD 11)
20+
endif()
1921
macro(set_if_higher VARIABLE VALUE)
2022
# ${VARIABLE} is a variable name, not a string
2123
if(${VARIABLE} LESS "${VALUE}")

source/api_cc/src/DeepPotPT.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void DeepPotPT::compute(ENERGYVTYPE& ener,
143143
int natoms = atype.size();
144144
auto options = torch::TensorOptions().dtype(torch::kFloat64);
145145
torch::ScalarType floatType = torch::kFloat64;
146-
if (std::is_same_v<VALUETYPE, float>) {
146+
if (std::is_same<VALUETYPE, float>::value) {
147147
options = torch::TensorOptions().dtype(torch::kFloat32);
148148
floatType = torch::kFloat32;
149149
}
@@ -341,7 +341,7 @@ void DeepPotPT::compute(ENERGYVTYPE& ener,
341341
int natoms = atype.size();
342342
auto options = torch::TensorOptions().dtype(torch::kFloat64);
343343
torch::ScalarType floatType = torch::kFloat64;
344-
if (std::is_same_v<VALUETYPE, float>) {
344+
if (std::is_same<VALUETYPE, float>::value) {
345345
options = torch::TensorOptions().dtype(torch::kFloat32);
346346
floatType = torch::kFloat32;
347347
}

source/api_cc/src/DeepSpinPT.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void DeepSpinPT::compute(ENERGYVTYPE& ener,
145145
int natoms = atype.size();
146146
auto options = torch::TensorOptions().dtype(torch::kFloat64);
147147
torch::ScalarType floatType = torch::kFloat64;
148-
if (std::is_same_v<VALUETYPE, float>) {
148+
if (std::is_same<VALUETYPE, float>::value) {
149149
options = torch::TensorOptions().dtype(torch::kFloat32);
150150
floatType = torch::kFloat32;
151151
}
@@ -365,7 +365,7 @@ void DeepSpinPT::compute(ENERGYVTYPE& ener,
365365
int natoms = atype.size();
366366
auto options = torch::TensorOptions().dtype(torch::kFloat64);
367367
torch::ScalarType floatType = torch::kFloat64;
368-
if (std::is_same_v<VALUETYPE, float>) {
368+
if (std::is_same<VALUETYPE, float>::value) {
369369
options = torch::TensorOptions().dtype(torch::kFloat32);
370370
floatType = torch::kFloat32;
371371
}

0 commit comments

Comments
 (0)