Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 2000-01-11 16:28:13


> The easiest way to do that is by adding the following line to change the
> "ext" variable to all lower-case:
>
> std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);

No!

Unfortunately, std::tolower takes and returns an int, not a char. On some
standard-conforming systems the above code will work, on others it will
fail. Instead, do this:

    inline char chartolower(char c) { return std::tolower(c); }

    std::transform(ext.begin(), ext.end(), ext.begin(), chartolower);

I've been discussing this with Nicolai Josuttis because this example appears
in his book and he's planning to correct it.

    -- Darin


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk