Splitting string at whitespace

Hello,
for some time now I've been trying to split a given string at whitespaces:
"A B C" -> "A", "B", "C". I want to use boost/algorithm/string
#include "boost/algorithm/string/split.hpp"
#include "boost/algorithm/string/compare.hpp"
std::vectorstd::string tokenize(const std::string& text )
{
std::vectorstd::string tokens;
boost::algorithm::split(tokens, text, boost::algorithm::is_equal(" "));
return tokens;
}
but compilation on gcc 4.9.0 / boost 1.55.0 just gives:
test.cpp: In function 'std::vector

On Jun 16, 2014, at 3:34 PM, Florian Lindner
Hello,
for some time now I've been trying to split a given string at whitespaces: "A B C" -> "A", "B", "C". I want to use boost/algorithm/string
#include "boost/algorithm/string/split.hpp" #include "boost/algorithm/string/compare.hpp"
std::vectorstd::string tokenize(const std::string& text ) { std::vectorstd::string tokens; boost::algorithm::split(tokens, text, boost::algorithm::is_equal(" ")); return tokens; }
That’s the wrong predicate to use; use is_space instead. boost::algorithm::split(tokens, text, boost::algorithm::is_space()); is_equal takes two characters and says if they’re equal. split wants to call the predicate with a single character and get a true/false back.
but compilation on gcc 4.9.0 / boost 1.55.0 just gives:
[snip] — Marshall
participants (2)
-
Florian Lindner
-
Marshall Clow