Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-03-21 12:43:03


AMDG

Elisabeth Benoit wrote:
> Can someone please tell me how to use boost::algorithm::is_alnum(). I first
> thought I could do
>
> std::string test
> boost::algorithm::is_alnum(test)
>
> but obviously the function doesn't take a string as a parameter. I've been
> searching for an example in the doc and on the web, but niet.
>
> an example would be greatly appreciated.
>

is_alnum() returns a unary function object that takes a character.

std::string s("!($(@ U98");
std::cout << std::count_if(s.begin(), s.end(),
boost::algorithm::is_alnum()); // prints 3

see also
http://www.boost.org/doc/html/string_algo/reference.html#header.boost.algorithm.string.classification.hpp

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net