I just installed boost and all functions that i used so far has worked fine, but when i used trim_if when you need to use boost::is_any_of it generated multiple errors.
This is some of the errors i'm getting:
error C2868: 'std::iterator_traits<_Iter>::iterator_category' : illegal syntax
for using-declaration; expected qualified-name
error C2825: '_Iter': must be a class or namespace when
followed by '::'
error C2602: 'boost::range_iterator<C>::type' is not a member of a base class
of 'boost::range_iterator<C>'
error C2602: 'std::iterator_traits<_Iter>::iterator_category'
is not a member of a base class of 'std::iterator_traits<_Iter>'
error C2039: 'iterator_category' : is not a member of '`global namespace''
I have tried to reinstall boost but that didn't work.
Code:
#include <iostream>
#include <string>
#include <boost/algorithm/string.hpp>
int main(int argc, char *argv[])
{
std::string string = "\t\tthis is a string\t";
boost::trim_if(string, boost::is_any_of('\t'));
std::cout << string << std::cout;
system("pause");
return 0;
}
Your problem is in the call boost::is_any_of('\\t')
.
is_any_of
takes a sequence of characters, and you are passing a single character.
Change your code to:
boost::trim_if(string, boost::is_any_of("\t"));
ie, use double-quoes instead of single quotes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.