fork download
  1. #include <string>
  2. #include <vector>
  3.  
  4. namespace otherns {
  5.  
  6. class Property {
  7. public:
  8. const std::string &getName() const { return m_name; }
  9.  
  10. private:
  11. std::string m_name;
  12. };
  13. }
  14.  
  15. bool operator==(const otherns::Property &a, const otherns::Property &b) {
  16. return a.getName() == b.getName();
  17. }
  18.  
  19. #include <algorithm>
  20.  
  21. /* Merge, second takes priority */
  22. std::vector<otherns::Property>
  23. merge_props(const std::vector<otherns::Property> &xs,
  24. const std::vector<otherns::Property> &ys) {
  25. std::vector<otherns::Property> ans = ys;
  26. for (const auto &x : xs) {
  27. if (std::find(ans.begin(), ans.end(), x) == ans.end()) {
  28. ans.push_back(x);
  29. }
  30. }
  31. return ans;
  32. }
  33.  
  34. int main() { return 0; }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/c++/5/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/5/bits/char_traits.h:39,
                 from /usr/include/c++/5/string:40,
                 from prog.cpp:1:
/usr/include/c++/5/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_equals_val<_Value>::operator()(_Iterator) [with _Iterator = __gnu_cxx::__normal_iterator<otherns::Property*, std::vector<otherns::Property> >; _Value = const otherns::Property]':
/usr/include/c++/5/bits/stl_algo.h:120:14:   required from '_RandomAccessIterator std::__find_if(_RandomAccessIterator, _RandomAccessIterator, _Predicate, std::random_access_iterator_tag) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<otherns::Property*, std::vector<otherns::Property> >; _Predicate = __gnu_cxx::__ops::_Iter_equals_val<const otherns::Property>]'
/usr/include/c++/5/bits/stl_algo.h:161:23:   required from '_Iterator std::__find_if(_Iterator, _Iterator, _Predicate) [with _Iterator = __gnu_cxx::__normal_iterator<otherns::Property*, std::vector<otherns::Property> >; _Predicate = __gnu_cxx::__ops::_Iter_equals_val<const otherns::Property>]'
/usr/include/c++/5/bits/stl_algo.h:3790:28:   required from '_IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = __gnu_cxx::__normal_iterator<otherns::Property*, std::vector<otherns::Property> >; _Tp = otherns::Property]'
prog.cpp:27:44:   required from here
/usr/include/c++/5/bits/predefined_ops.h:194:17: error: no match for 'operator==' (operand types are 'otherns::Property' and 'const otherns::Property')
  { return *__it == _M_value; }
                 ^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/5/bits/char_traits.h:39,
                 from /usr/include/c++/5/string:40,
                 from prog.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:820:5: note: candidate: template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)
     operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
     ^
/usr/include/c++/5/bits/stl_iterator.h:820:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/5/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/5/bits/char_traits.h:39,
                 from /usr/include/c++/5/string:40,
                 from prog.cpp:1:
/usr/include/c++/5/bits/predefined_ops.h:194:17: note:   'otherns::Property' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
  { return *__it == _M_value; }
                 ^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/5/bits/char_traits.h:39,
                 from /usr/include/c++/5/string:40,
                 from prog.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:827:5: note: candidate: template<class _Iterator, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)
     operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
     ^
/usr/include/c++/5/bits/stl_iterator.h:827:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/5/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/5/bits/char_traits.h:39,
                 from /usr/include/c++/5/string:40,
                 from prog.cpp:1:
/usr/include/c++/5/bits/predefined_ops.h:194:17: note:   'otherns::Property' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
  { return *__it == _M_value; }
                 ^
In file included from /usr/include/i386-linux-gnu/c++/5/bits/c++allocator.h:33:0,
                 from /usr/include/c++/5/bits/allocator.h:46,
                 from /usr/include/c++/5/string:41,
                 from prog.cpp:1:
/usr/include/c++/5/ext/new_allocator.h:139:5: note: candidate: template<class _Tp> bool __gnu_cxx::operator==(const __gnu_cxx::new_allocator<_Tp>&, const __gnu_cxx::new_allocator<_Tp>&)
     operator==(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
     ^
/usr/include/c++/5/ext/new_allocator.h:139:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/5/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/5/bits/char_traits.h:39,
                 from /usr/include/c++/5/string:40,
                 from prog.cpp:1:
/usr/include/c++/5/bits/predefined_ops.h:194:17: note:   'otherns::Property' is not derived from 'const __gnu_cxx::new_allocator<_Tp>'
  { return *__it == _M_value; }
                 ^
stdout
Standard output is empty