libstdc++/5133: Problems with toupper

Pete Ratzlaff rpete@legs.harvard.edu
Fri Nov 15 21:19:00 GMT 2002


I realize this PR is closed, but don't agree with the conclusion that
mixing linkages in this case is ill-formed.  There's is nothing to
preclude the template argument from being a function with C
linkage. Here is what the standard has to say:

template<class InputIterator, class OutputIterator,
         class UnaryOperation>
  OutputIterator
    transform(InputIterator first, InputIterator last,
              OutputIterator result, UnaryOperation op);

  1- Effects: Assigns through every iterator i in the range [result,
     result + (last1 - first1)) a new corresponding value equal to
     op(*(first1 + (i - result))

In other words, anything that can have an () appended and follows the
rules for template parameters is fair game for the 3rd template
argument in this case.

All I can guess is that Martin was thinking of the std::ptr_fun and
std::pointer_to_unary_function templates, whose argument (and ctor)
are explicitly pointers to function (with C++ linkage).

I cannot see anything that keeps one from using the toupper/tolower
from <cctype> with transform, and the fact that gcc won't allow it
should be considered a bug.

Although it certainly doesn't prove my point, I would just note that
Comeau's compiler seems to concur.

Cheers,
-Pete



More information about the Gcc-bugs mailing list