@@ -58,20 +58,21 @@ void mkdir(const std::string& path, std::filesystem::perms mode) {
58
58
std::filesystem::permissions (dir, mode);
59
59
}
60
60
61
- template <typename T>
61
+ template <typename T>
62
62
T string_to_num (const std::string& input) {
63
- static_assert (std::is_arithmetic<T>::value, " Template argument must be an arithmetic type" );
63
+ static_assert (std::is_arithmetic<T>::value,
64
+ " Template argument must be an arithmetic type" );
64
65
65
- std::istringstream iss (input);
66
- T result;
67
- iss >> result;
66
+ std::istringstream iss (input);
67
+ T result;
68
+ iss >> result;
68
69
69
- // Check for conversion failure or extra characters
70
- if (iss.fail () || !iss.eof ()) {
71
- throw std::invalid_argument (" Invalid input for conversion to numeric type" );
72
- }
70
+ // Check for conversion failure or extra characters
71
+ if (iss.fail () || !iss.eof ()) {
72
+ throw std::invalid_argument (" Invalid input for conversion to numeric type" );
73
+ }
73
74
74
- return result;
75
+ return result;
75
76
}
76
77
77
78
using dict = std::map<std::string, std::string>;
@@ -89,9 +90,8 @@ dict parse_args(int argc, char* argv[]) {
89
90
return kwargs;
90
91
}
91
92
92
- template <typename T>
93
- T get_arg (dict& kwargs, const std::string& key,
94
- const T& default_value) {
93
+ template <typename T>
94
+ T get_arg (dict& kwargs, const std::string& key, const T& default_value) {
95
95
if (kwargs.find (key) != kwargs.end ()) {
96
96
return string_to_num<T>(kwargs[key]);
97
97
} else {
@@ -101,7 +101,7 @@ T get_arg(dict& kwargs, const std::string& key,
101
101
102
102
template <>
103
103
std::string get_arg<std::string>(dict& kwargs, const std::string& key,
104
- const std::string& default_value) {
104
+ const std::string& default_value) {
105
105
if (kwargs.find (key) != kwargs.end ()) {
106
106
return kwargs[key];
107
107
} else {
0 commit comments