$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] Boost.Tokenizer / Sep - Compile-time errors ...
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2011-08-02 19:07:00
> 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", " ");
}
If you are doing something different, please post the exact code.
Regards,
Nate