fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <functional>
  5. #include <iterator>
  6.  
  7.  
  8. struct island {
  9. long long x,y; //coords
  10. };
  11.  
  12. int main() {
  13. std::vector<island> sea;
  14. std::vector<std::reference_wrapper<const island>> r_sea;
  15.  
  16. std::transform(sea.begin(), sea.end(),
  17. std::back_inserter(r_sea),
  18. std::cref<island>
  19. );
  20.  
  21. return 0;
  22. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:19:5: error: no matching function for call to ‘transform(std::vector<island>::iterator, std::vector<island>::iterator, std::back_insert_iterator<std::vector<std::reference_wrapper<const island> > >, <unresolved overloaded function type>)’
     );
     ^
In file included from /usr/include/c++/6/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/6/bits/stl_algo.h:4166:5: note: candidate: template<class _IIter, class _OIter, class _UnaryOperation> _OIter std::transform(_IIter, _IIter, _OIter, _UnaryOperation)
     transform(_InputIterator __first, _InputIterator __last,
     ^~~~~~~~~
/usr/include/c++/6/bits/stl_algo.h:4166:5: note:   template argument deduction/substitution failed:
prog.cpp:19:5: note:   could not resolve address from overloaded function ‘cref<island>’
     );
     ^
In file included from /usr/include/c++/6/algorithm:62:0,
                 from prog.cpp:3:
/usr/include/c++/6/bits/stl_algo.h:4203:5: note: candidate: template<class _IIter1, class _IIter2, class _OIter, class _BinaryOperation> _OIter std::transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation)
     transform(_InputIterator1 __first1, _InputIterator1 __last1,
     ^~~~~~~~~
/usr/include/c++/6/bits/stl_algo.h:4203:5: note:   template argument deduction/substitution failed:
prog.cpp:19:5: note:   could not resolve address from overloaded function ‘cref<island>’
     );
     ^
stdout
Standard output is empty