fork(3) download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. int main() {
  8. string s = "Onetwothree";
  9. int lc = count_if(s.begin(), s.end(), islower);
  10. int uc = count_if(s.begin(), s.end(), isupper);
  11. cout << uc << " " << lc << endl;
  12. return 0;
  13. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:9:47: error: no matching function for call to 'count_if(std::basic_string<char>::iterator, std::basic_string<char>::iterator, <unresolved overloaded function type>)'
  int lc = count_if(s.begin(), s.end(), islower);
                                               ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/5/bits/stl_algo.h:3982:5: note: candidate: template<class _IIter, class _Predicate> typename std::iterator_traits<_Iterator>::difference_type std::count_if(_IIter, _IIter, _Predicate)
     count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
     ^
/usr/include/c++/5/bits/stl_algo.h:3982:5: note:   template argument deduction/substitution failed:
prog.cpp:9:47: note:   couldn't deduce template parameter '_Predicate'
  int lc = count_if(s.begin(), s.end(), islower);
                                               ^
prog.cpp:10:47: error: no matching function for call to 'count_if(std::basic_string<char>::iterator, std::basic_string<char>::iterator, <unresolved overloaded function type>)'
  int uc = count_if(s.begin(), s.end(), isupper);
                                               ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/5/bits/stl_algo.h:3982:5: note: candidate: template<class _IIter, class _Predicate> typename std::iterator_traits<_Iterator>::difference_type std::count_if(_IIter, _IIter, _Predicate)
     count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
     ^
/usr/include/c++/5/bits/stl_algo.h:3982:5: note:   template argument deduction/substitution failed:
prog.cpp:10:47: note:   couldn't deduce template parameter '_Predicate'
  int uc = count_if(s.begin(), s.end(), isupper);
                                               ^
stdout
Standard output is empty