1

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;
}
0

1 Answer 1

3

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"));

i.e, use double-quoes instead of single quotes.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.