Fix out-of-range error

Closes #31.
This commit is contained in:
Vladimir Prus
2017-07-21 18:30:47 +03:00
parent a30cc1082f
commit 3e1d2603e6

View File

@@ -26,7 +26,12 @@ namespace boost { namespace program_options {
inline std::string strip_prefixes(const std::string& text)
{
// "--foo-bar" -> "foo-bar"
return text.substr(text.find_first_not_of("-/"));
std::string::size_type i = text.find_first_not_of("-/");
if (i == std::string::npos) {
return text;
} else {
return text.substr(i);
}
}
/** Base class for all errors in the library. */