From 7a1a209168b5865c7e5f989028a4716dc58e96ea Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Wed, 29 Mar 2017 08:31:24 +0200 Subject: [PATCH] use std::regex_token_iterator instead of boost tokenized --- src/tools/partition.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/tools/partition.cpp b/src/tools/partition.cpp index 7ea90564d..600bac561 100644 --- a/src/tools/partition.cpp +++ b/src/tools/partition.cpp @@ -12,11 +12,11 @@ #include #include #include -#include #include -#include #include +#include +#include using namespace osrm; @@ -34,9 +34,8 @@ struct MaxCellSizesArgument std::ostream &operator<<(std::ostream &os, const MaxCellSizesArgument &arg) { - return os << boost::algorithm::join( - arg.value | boost::adaptors::transformed([](auto x) { return std::to_string(x); }), - ","); + auto to_string = [](std::size_t x) { return std::to_string(x); }; + return os << boost::algorithm::join(arg.value | boost::adaptors::transformed(to_string), ","); } void validate(boost::any &v, const std::vector &values, MaxCellSizesArgument *, int) @@ -50,18 +49,21 @@ void validate(boost::any &v, const std::vector &values, MaxCellSize // one string, it's an error, and exception will be thrown. const std::string &s = validators::get_single_string(values); + std::regex re(","); std::vector output; - boost::copy(s | tokenized(boost::regex("[^,]+")) | transformed([](const auto &x) { - try - { - return boost::lexical_cast(x); - } - catch (const boost::bad_lexical_cast &) - { - throw validation_error(validation_error::invalid_option_value); - } - }), - std::back_inserter(output)); + std::transform(std::sregex_token_iterator(s.begin(), s.end(), re, -1), + std::sregex_token_iterator(), + std::back_inserter(output), + [](const auto &x) { + try + { + return boost::lexical_cast(x); + } + catch (const boost::bad_lexical_cast &) + { + throw validation_error(validation_error::invalid_option_value); + } + }); v = boost::any(MaxCellSizesArgument{output}); }