mercredi 1 juin 2016

How to tokenize and transform a c-string using regex and boost transform iterators?

I try to tokenize a c-string with semicolon separated digits and store them in a vector. This is my simplified approach

auto string = "1;2;3;4"
const std::regex separator {";"};
std::cregex_token_iterator t_begin{string, string + strlen(string, -1)};
std::cregex_token_iterator t_end{};
auto begin = boost::make_transform_iterator(tbegin, atoi);
auto bend = boost::make_transform_iterator(tend, atoi);
std::vector<int> result{begin, end};

I get the error message:

error: no type named 'type' in 'boost::mpl::eval_if<boost::is_same<boost::iterators::use_default, boost::iterators::use_default>, boost::result_of<const int(std::sub_match<const char*>&)>, boost::mpl::identity<boost::iterator::use_default> >::f_{aka struct boost::result_of<const int(const std::sub_match<const char*>&)>}'
typedef typename f_::type type;

which I don't understand.

Aucun commentaire:

Enregistrer un commentaire