
Thanks, Nate. Instead of writing "const std::string& separator", I wrote "std::string separator" - missed this somehow. can't believe it. Thank you, again. On Wed, Aug 3, 2011 at 4:07 AM, Nathan Ridge <zeratul976@hotmail.com> wrote:
Hi,
Here is a piece of code that _only_ works when I provide it a hard-coded constant ";":
typedef boost::char_separator<char_type_t> sep_type_t; typedef boost::tokenizer<sep_type_t> tokenizer_t;
sep_(pa_->separator_.c_str()), t_(messageString,sep_), i_(t_.begin())
It wouldn't work with the separator passed in a variable (pa_->separator.c_str()). Tokenizer wouldn't work even if I initialize a const char* with a ";" and then pass that const char *variable to sep_ above. It gives me the following errors on if I pass separator in a variable:
error C2780: 'bool boost::char_separator<Char>::operator ()(InputIterator &,InputIterator,Token &)' : expects 3 arguments - 1 provided
Any idea how I can pass it a separator in a variable?
The following code compiles fine with MSVC10 and gcc:
#include <boost/tokenizer.hpp>
template <typename char_type_t> struct S { typedef boost::char_separator<char_type_t> sep_type_t; typedef boost::tokenizer<sep_type_t> tokenizer_t;
S(const std::string& messageString, const std::string& separator) : sep_(separator.c_str()), t_(messageString, sep_), i_(t_.begin()) {}
sep_type_t sep_; tokenizer_t t_; typename tokenizer_t::iterator i_; };
int main() { S<char> s("foo bar", " "); }