fork download
  1. #include <string>
  2. #include <iterator>
  3. #include <iostream>
  4. #include <algorithm>
  5. using namespace std;
  6. int main()
  7. {
  8. string test = "TEST";
  9. string test2 = "TEST2";
  10.  
  11. // This (only?) works on Visual Studio
  12. transform(test2.begin(), test2.end(), test2.begin(), tolower);
  13.  
  14. // :: global namespace for clib tolower
  15. transform(test.begin(), test.end(), test.begin(), ::tolower);
  16.  
  17. cout << test2 << endl;
  18. cout << test << endl;
  19. return 0;
  20. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:12:65: error: no matching function for call to ‘transform(std::basic_string<char>::iterator, std::basic_string<char>::iterator, std::basic_string<char>::iterator, <unresolved overloaded function type>)’
prog.cpp:12:65: note: candidates are:
In file included from /usr/include/c++/4.7/algorithm:63:0,
                 from prog.cpp:4:
/usr/include/c++/4.7/bits/stl_algo.h:4940:5: note: template<class _IIter, class _OIter, class _UnaryOperation> _OIter std::transform(_IIter, _IIter, _OIter, _UnaryOperation)
/usr/include/c++/4.7/bits/stl_algo.h:4940:5: note:   template argument deduction/substitution failed:
prog.cpp:12:65: note:   couldn't deduce template parameter ‘_UnaryOperation’
In file included from /usr/include/c++/4.7/algorithm:63:0,
                 from prog.cpp:4:
/usr/include/c++/4.7/bits/stl_algo.h:4977:5: note: template<class _IIter1, class _IIter2, class _OIter, class _BinaryOperation> _OIter std::transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation)
/usr/include/c++/4.7/bits/stl_algo.h:4977:5: note:   template argument deduction/substitution failed:
prog.cpp:12:65: note:   candidate expects 5 arguments, 4 provided
stdout
Standard output is empty