Skip to content
Snippets Groups Projects
Unverified Commit d65ebaee authored by Bensong Liu's avatar Bensong Liu
Browse files

fix msvc compilation issue on opt_parser::getValueArg overloading

parent 69f44ebd
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ ARFLAGS = rcs ...@@ -8,7 +8,7 @@ ARFLAGS = rcs
PREFIX ?= /usr PREFIX ?= /usr
def: def:
@echo Run make install @echo This library is header-only, and no need to compile. Run make install if you would like.
install_header: install_header:
[ ! -d $(PREFIX)/include/rlib ] || rm -rf $(PREFIX)/include/rlib [ ! -d $(PREFIX)/include/rlib ] || rm -rf $(PREFIX)/include/rlib
......
...@@ -79,20 +79,8 @@ namespace rlib { ...@@ -79,20 +79,8 @@ namespace rlib {
} }
} }
rlib::string getValueArg(const std::string &longName, const char *shortName) // rlib::string getValueArg(const std::string &longName, const std::string &shortName, bool required = true, const std::string &def = std::string()) // MSVC doesn't allow this overload.
{ //getValueArg("--long", "-l") may be converted to getValueArg("--long", true). rlib::string getValueArg(const std::string &longName, const std::string &shortName, bool required, const std::string &def)
return getValueArg(longName, shortName, true);
}
bool getBoolArg(const std::string &argName)
{ //Return if it's defined.
auto pos = std::find(args.cbegin(), args.cend(), argName);
if(pos == args.cend()) return false;
args.erase(pos);
return true;
}
rlib::string getValueArg(const std::string &longName, const std::string &shortName, bool required = true, const std::string &def = std::string())
{ {
using rlib::literals::operator "" _format; using rlib::literals::operator "" _format;
std::string valueL = getValueArg(longName, false); std::string valueL = getValueArg(longName, false);
...@@ -107,6 +95,25 @@ namespace rlib { ...@@ -107,6 +95,25 @@ namespace rlib {
} }
return std::move(value); return std::move(value);
} }
rlib::string getValueArg(const std::string &longName, const std::string &shortName, bool required) {
return getValueArg(longName, shortName, required, std::string());
}
rlib::string getValueArg(const std::string &longName, const std::string &shortName) {
return getValueArg(longName, shortName, true, std::string());
}
rlib::string getValueArg(const std::string &longName, const char *shortName)
{ //getValueArg("--long", "-l") may be converted to getValueArg("--long", true).
return getValueArg(longName, shortName, true);
}
bool getBoolArg(const std::string &argName)
{ //Return if it's defined.
auto pos = std::find(args.cbegin(), args.cend(), argName);
if(pos == args.cend()) return false;
args.erase(pos);
return true;
}
bool getBoolArg(const std::string &longName, const std::string &shortName) bool getBoolArg(const std::string &longName, const std::string &shortName)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment