Skip to content

Commit 31efe17

Browse files
committed
update arithmetic operator overloads for ArgumentValueList so that the rest of the list is copied to the resultant list. other small changes to resolve WSL compilation errors
1 parent d9f5a6e commit 31efe17

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

argparse.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ bool ArgumentValueList::operator<=(const char* other) const{
110110

111111
// Arithmetic Operators {{{2
112112
ArgumentValueList ArgumentValueList::operator+(const char* other) const{
113-
ArgumentValueList temp = {(std::string)at(0).c_str() + other};
113+
ArgumentValueList temp = vec();
114+
temp.at(0) = at(0) + other;
114115
return temp;
115116
}
116117

argparse.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef ARGPARSE_H
22
#define ARGPARSE_H
3-
#define ARGPARSE_VERSION 2.2.6
3+
#define ARGPARSE_VERSION 2.2.7
44
#include <iostream>
55
#include <sstream>
66
#include <fstream>
@@ -224,31 +224,31 @@ namespace argparse{
224224
// Arithmetic Operators
225225
template <typename T>
226226
ArgumentValueList operator+(const T& other) const{
227-
ArgumentValueList temp = {""};
227+
ArgumentValueList temp = vec();
228228
temp.at(0) = (T)at(0) + other;
229229
return temp;
230230
}
231231
template <typename T>
232232
ArgumentValueList operator-(const T& other) const{
233-
ArgumentValueList temp = {""};
233+
ArgumentValueList temp = vec();
234234
temp.at(0) = (T)at(0) - other;
235235
return temp;
236236
}
237237
template <typename T>
238238
ArgumentValueList operator*(const T& other) const{
239-
ArgumentValueList temp = {""};
239+
ArgumentValueList temp = vec();
240240
temp.at(0) = (T)at(0) * other;
241241
return temp;
242242
}
243243
template <typename T>
244244
ArgumentValueList operator/(const T& other) const{
245-
ArgumentValueList temp = {""};
245+
ArgumentValueList temp = vec();
246246
temp.at(0) = (T)at(0) / other;
247247
return temp;
248248
}
249249
template <typename T>
250250
ArgumentValueList operator%(const T& other) const{
251-
ArgumentValueList temp = {""};
251+
ArgumentValueList temp = vec();
252252
temp.at(0) = (T)at(0) % other;
253253
return temp;
254254
}

0 commit comments

Comments
 (0)