"qazmlp" <qa********@rediffmail.com> wrote in message
news:db*************************@posting.google.co m...
How do you check whether an std::string object contains only printable
characters ?
I think this would work:
#include <algorithm>
#include <cctype>
#include <functional>
#include <string>
namespace util
{
bool isAllPrintable (std::string const &s)
{
typedef std::unary_negate<
std::pointer_to_unary_function<int, int> > NotFunc;
NotFunc isNotPrintable(std::ptr_fun(std::isprint));
return std::find_if(s.begin(), s.end(), isNotPrintable) ==
s.end();
}
}
--
Russell Hanneken
rh*******@pobox.com