Hi,
I am using Boost 1.47.0 / Windows Server 2003 Standard 32-bit / Visual C++
2010 Express.
I copied/pasted the following code from StackOverFlow and it works:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <iostream>
#include
int main()
{
std::string str = "This is a test string";
for( boost::algorithm::split_iteratorstd::string::iterator i
= make_split_iterator(str, token_finder(
boost::algorithm::is_space(),
boost::algorithm::token_compress_on));
i != boost::algorithm::split_iteratorstd::string::iterator();
++i)
{
//std::string s = *i;
std::cout << *i << '\n';
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
However, when I assign the result of *i to an std::string then I get a
compiler conversion error:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <iostream>
#include
int main()
{
std::string str = "This is a test string";
for( boost::algorithm::split_iteratorstd::string::iterator i
= make_split_iterator(str, token_finder(
boost::algorithm::is_space(),
boost::algorithm::token_compress_on));
i != boost::algorithm::split_iteratorstd::string::iterator();
++i)
{
std::string s = *i; ////////////////////////////COMPILER ERROR:
cannot convert from 'const boost::iterator_range<IteratorT>' to 'const
std::basic_string<_Elem,_Traits,_Ax>'
std::cout << s << '\n';
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Can anyone guide me as to how I can eliminate this error and convert the
result of the dereferenced iterator to string? I need to get an std::string.
Thanks in advance, Asif