diff --git a/libs/program_options/src/options_description.cpp b/libs/program_options/src/options_description.cpp index 343bd30..22aaeb3 100644 --- a/libs/program_options/src/options_description.cpp +++ b/libs/program_options/src/options_description.cpp @@ -419,7 +419,7 @@ namespace boost { namespace program_options { else { // only one tab per paragraph allowed - if (count(par.begin(), par.end(), '\t') > 1) + if (par.find('\t', par_indent+1) != string::npos) { boost::throw_exception(program_options::error( "Only one tab per paragraph is allowed in the options description")); @@ -469,7 +469,7 @@ namespace boost { namespace program_options { // Take care to never increment the iterator past // the end, since MSVC 8.0 (brokenly), assumes that // doing that, even if no access happens, is a bug. - unsigned remaining = static_cast(std::distance(line_begin, par_end)); + unsigned remaining = static_cast(par_end - line_begin); string::const_iterator line_end = line_begin + ((remaining < line_length) ? remaining : line_length); @@ -479,20 +479,17 @@ namespace boost { namespace program_options { ((line_end < par_end) && (*line_end != ' '))) { // find last ' ' in the second half of the current paragraph line - string::const_iterator last_space = - find(reverse_iterator(line_end), - reverse_iterator(line_begin), - ' ') - .base(); + string::size_type last_space_pos = par.find(' ', line_end - par.begin()); - if (last_space != line_begin) + if (last_space_pos != string::npos && + last_space_pos > (line_begin - par.begin())) { - // is last_space within the second half ot the + // is last space within the second half of the // current line - if (static_cast(std::distance(last_space, line_end)) < + if (static_cast(par.length() - last_space_pos) < (line_length / 2)) { - line_end = last_space; + line_end = par.begin() + last_space_pos; } } } // prevent chopped words diff --git a/libs/program_options/src/value_semantic.cpp b/libs/program_options/src/value_semantic.cpp index 5314029..647550e 100644 --- a/libs/program_options/src/value_semantic.cpp +++ b/libs/program_options/src/value_semantic.cpp @@ -368,7 +368,8 @@ namespace boost { namespace program_options { string error_template = original_error_template; // remove duplicates using std::set std::set alternatives_set (m_alternatives.begin(), m_alternatives.end()); - std::vector alternatives_vec (alternatives_set.begin(), alternatives_set.end()); + std::vector alternatives_vec; + copy(alternatives_set.begin(), alternatives_set.end(), back_inserter(alternatives_vec)); error_template += " and matches "; // Being very cautious: should be > 1 alternative!