I'm trying to port somebody else's code from g++-2.95.3 to g++-3.4.1, but am running into template problems with STL algorithms and ptr_fun(isspace<char>).
Compiling the following snippet:
#include <cctype> #include <functional> #include <algorithm> #include <deque> #include <locale> using namespace std; int main () { char init[7] = {1,2,3,4,5,6,7}; deque<char> d(init, init+7); find_if (d.begin(), d.end(), ptr_fun(isspace<char>)); }
with either gcc-3.2.2 (redhat 9) or gcc-3.4.1 yields the following error:
/usr/include/c++/3.2.2/bits/stl_algo.h: In function `_RandomAccessIter
std::find_if(_RandomAccessIter, _RandomAccessIter, _Predicate,
std::random_access_iterator_tag) [with _RandomAccessIter =
std::_Deque_iterator<char, char&, char*>, _Predicate =
std::pointer_to_binary_function<char, const std::locale&, bool>]':
/usr/include/c++/3.2.2/bits/stl_algo.h:318: instantiated from `_InputIter std::find_if(_InputIter, _InputIter, _Predicate) [with _InputIter = std::_Deque_iterator<char, char&, char*>, _Predicate = std::pointer_to_binary_function<char, const std::locale&, bool>]'
a.cc:13: instantiated from here
/usr/include/c++/3.2.2/bits/stl_algo.h:252: no match for call to `(
std::pointer_to_binary_function<char, const std::locale&, bool>) (char&)'
/usr/include/c++/3.2.2/bits/stl_function.h:465: candidates are: _Result
std::pointer_to_binary_function<_Arg1, _Arg2, _Result>::operator()(_Arg1,
_Arg2) const [with _Arg1 = char, _Arg2 = const std::locale&, _Result = bool]
(This is an improvement; the original code didn't specify which isspace, and blew up in a worse way.)
Can anybody point out what's wrong?
Thanks, Dan
-- Trying to get a job as a c++ developer? See http://kegel.com/academy/getting-hired.html