Skip to content

Commit 3e1d260

Browse files
committed
Fix out-of-range error
Closes #31.
1 parent a30cc10 commit 3e1d260

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

include/boost/program_options/errors.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ namespace boost { namespace program_options {
2626
inline std::string strip_prefixes(const std::string& text)
2727
{
2828
// "--foo-bar" -> "foo-bar"
29-
return text.substr(text.find_first_not_of("-/"));
29+
std::string::size_type i = text.find_first_not_of("-/");
30+
if (i == std::string::npos) {
31+
return text;
32+
} else {
33+
return text.substr(i);
34+
}
3035
}
3136

3237
/** Base class for all errors in the library. */

0 commit comments

Comments
 (0)