Skip to content

Commit 8df1547

Browse files
committed
ouch, the constexpr of std::array::size() is of C++17
1 parent 9952d5f commit 8df1547

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

deps/LibComm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit ec984514b44480e98bd1578bcacca7a19c849724

deps/LibRI

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit bd299faeaa184b912e4bdf5c0e182dfb7f47272a

source/module_io/read_input.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <sstream>
88
#include <array>
99
#include <vector>
10+
#include <cassert>
1011
#include "module_base/formatter.h"
1112
#include "module_base/global_file.h"
1213
#include "module_base/global_function.h"
@@ -20,14 +21,18 @@ std::string longstring(const std::vector<std::string>& words)
2021
return FmtCore::join(" ", words);
2122
}
2223

23-
bool assume_bool(const std::string& val)
24+
bool assume_as_boolean(const std::string& val)
2425
{
2526
const std::string val_ = FmtCore::lower(val);
2627

2728
const std::array<std::string, 7> t_ = {"true", "1", "t", "yes", "y", "on", ".true."};
2829
const std::array<std::string, 7> f_ = {"false", "0", "f", "no", "n", "off", ".false."};
2930
// This will work because std::array<T, N>::size() is a constexpr function
30-
static_assert(t_.size() == f_.size(), "t_ and f_ must have the same lengths");
31+
// Ouch it is of C++17 standard...
32+
// static_assert(t_.size() == f_.size(), "t_ and f_ must have the same lengths");
33+
#ifdef __DEBUG // C++11 can do this
34+
assert(t_.size() == f_.size());
35+
#endif
3136

3237
if (std::find(t_.begin(), t_.end(), val_) != t_.end())
3338
{

source/module_io/read_input.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class ReadInput
142142
// convert string vector to a long string
143143
std::string longstring(const std::vector<std::string>& str_values);
144144
// convert string to bool
145-
bool assume_bool(const std::string& val);
145+
bool assume_as_boolean(const std::string& val);
146146
// convert to directory format
147147
std::string to_dir(const std::string& str);
148148
// return a warning string if the string is not found in the vector

source/module_io/read_input_item_output.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void ReadInput::item_output()
101101
{
102102
ModuleBase::WARNING_QUIT("ReadInput", "out_band should have 1 or 2 values");
103103
}
104-
para.input.out_band[0] = assume_bool(item.str_values[0]);
104+
para.input.out_band[0] = assume_as_boolean(item.str_values[0]);
105105
para.input.out_band[1] = (count == 2) ? std::stoi(item.str_values[1]) : 8;
106106
};
107107
item.reset_value = [](const Input_Item& item, Parameter& para) {
@@ -236,7 +236,7 @@ void ReadInput::item_output()
236236
{
237237
ModuleBase::WARNING_QUIT("ReadInput", "out_mat_hs should have 1 or 2 values");
238238
}
239-
para.input.out_mat_hs[0] = assume_bool(item.str_values[0]);
239+
para.input.out_mat_hs[0] = assume_as_boolean(item.str_values[0]);
240240
para.input.out_mat_hs[1] = (count == 2) ? std::stoi(item.str_values[1]) : 8;
241241
};
242242
item.reset_value = [](const Input_Item& item, Parameter& para) {
@@ -257,7 +257,7 @@ void ReadInput::item_output()
257257
{
258258
ModuleBase::WARNING_QUIT("ReadInput", "out_mat_tk should have 1 or 2 values");
259259
}
260-
para.input.out_mat_tk[0] = assume_bool(item.str_values[0]);
260+
para.input.out_mat_tk[0] = assume_as_boolean(item.str_values[0]);
261261
para.input.out_mat_tk[1] = (count == 2) ? std::stoi(item.str_values[1]) : 8;
262262
};
263263
sync_intvec(input.out_mat_tk, 2, 0);

source/module_io/read_input_tool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define strvalue item.str_values[0]
99
#define intvalue std::stoi(item.str_values[0])
1010
#define doublevalue std::stod(item.str_values[0])
11-
#define boolvalue assume_bool(item.str_values[0])
11+
#define boolvalue assume_as_boolean(item.str_values[0])
1212

1313
#ifdef __MPI
1414
#define add_double_bcast(PARAMETER) \

0 commit comments

Comments
 (0)