This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libstdc++/5133: Problems with toupper


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]