fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <iterator>
  4.  
  5. using namespace std;
  6.  
  7. template<typename Inverse>
  8. void Diag(Inverse begin, Inverse end)
  9. {
  10. for(auto row : &begin)
  11. {
  12. for(auto col : row)
  13. {
  14.  
  15. }
  16. }
  17.  
  18. }
  19.  
  20.  
  21. int main() {
  22. // your code goes here
  23.  
  24. std::vector<std::vector<double> > vect = {
  25. {1, 2, 3},
  26. {4, 5, 6},
  27. {7, 8, 9}
  28. };
  29.  
  30. Diag(std::begin(vect), std::end(vect));
  31. return 0;
  32. }
Compilation error #stdin compilation error #stdout 0s 3224KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of 'void Diag(Inverse, Inverse) [with Inverse = __gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >]':
prog.cpp:30:39:   required from here
prog.cpp:10:2: error: no matching function for call to 'begin(__gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >*&)'
  for(auto row : &begin)
  ^
prog.cpp:10:2: note: candidates are:
In file included from /usr/include/c++/4.9/bits/basic_string.h:42:0,
                 from /usr/include/c++/4.9/string:52,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/initializer_list:89:5: note: template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)
     begin(initializer_list<_Tp> __ils) noexcept
     ^
/usr/include/c++/4.9/initializer_list:89:5: note:   template argument deduction/substitution failed:
prog.cpp:10:2: note:   mismatched types 'std::initializer_list<_Tp>' and '__gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >*'
  for(auto row : &begin)
  ^
In file included from /usr/include/c++/4.9/string:51:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/range_access.h:87:5: note: template<class _Tp, unsigned int _Nm> _Tp* std::begin(_Tp (&)[_Nm])
     begin(_Tp (&__arr)[_Nm])
     ^
/usr/include/c++/4.9/bits/range_access.h:87:5: note:   template argument deduction/substitution failed:
prog.cpp:10:2: note:   mismatched types '_Tp [_Nm]' and '__gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >*'
  for(auto row : &begin)
  ^
In file included from /usr/include/c++/4.9/string:51:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/range_access.h:58:5: note: template<class _Container> decltype (__cont.begin()) std::begin(const _Container&)
     begin(const _Container& __cont) -> decltype(__cont.begin())
     ^
/usr/include/c++/4.9/bits/range_access.h:58:5: note:   template argument deduction/substitution failed:
/usr/include/c++/4.9/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(const _Container&) [with _Container = __gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >*]':
prog.cpp:10:2:   required from 'void Diag(Inverse, Inverse) [with Inverse = __gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >]'
prog.cpp:30:39:   required from here
/usr/include/c++/4.9/bits/range_access.h:58:5: error: request for member 'begin' in '__cont', which is of pointer type '__gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >* const' (maybe you meant to use '->' ?)
prog.cpp: In instantiation of 'void Diag(Inverse, Inverse) [with Inverse = __gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >]':
prog.cpp:30:39:   required from here
/usr/include/c++/4.9/bits/range_access.h:48:5: note: template<class _Container> decltype (__cont.begin()) std::begin(_Container&)
     begin(_Container& __cont) -> decltype(__cont.begin())
     ^
/usr/include/c++/4.9/bits/range_access.h:48:5: note:   template argument deduction/substitution failed:
/usr/include/c++/4.9/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(_Container&) [with _Container = __gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >*]':
prog.cpp:10:2:   required from 'void Diag(Inverse, Inverse) [with Inverse = __gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >]'
prog.cpp:30:39:   required from here
/usr/include/c++/4.9/bits/range_access.h:48:5: error: request for member 'begin' in '__cont', which is of pointer type '__gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >*' (maybe you meant to use '->' ?)
prog.cpp: In instantiation of 'void Diag(Inverse, Inverse) [with Inverse = __gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >]':
prog.cpp:30:39:   required from here
prog.cpp:10:2: error: no matching function for call to 'end(__gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >*&)'
  for(auto row : &begin)
  ^
prog.cpp:10:2: note: candidates are:
In file included from /usr/include/c++/4.9/bits/basic_string.h:42:0,
                 from /usr/include/c++/4.9/string:52,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/initializer_list:99:5: note: template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^
/usr/include/c++/4.9/initializer_list:99:5: note:   template argument deduction/substitution failed:
prog.cpp:10:2: note:   mismatched types 'std::initializer_list<_Tp>' and '__gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >*'
  for(auto row : &begin)
  ^
In file included from /usr/include/c++/4.9/string:51:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/range_access.h:97:5: note: template<class _Tp, unsigned int _Nm> _Tp* std::end(_Tp (&)[_Nm])
     end(_Tp (&__arr)[_Nm])
     ^
/usr/include/c++/4.9/bits/range_access.h:97:5: note:   template argument deduction/substitution failed:
prog.cpp:10:2: note:   mismatched types '_Tp [_Nm]' and '__gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >*'
  for(auto row : &begin)
  ^
In file included from /usr/include/c++/4.9/string:51:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/range_access.h:78:5: note: template<class _Container> decltype (__cont.end()) std::end(const _Container&)
     end(const _Container& __cont) -> decltype(__cont.end())
     ^
/usr/include/c++/4.9/bits/range_access.h:78:5: note:   template argument deduction/substitution failed:
/usr/include/c++/4.9/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(const _Container&) [with _Container = __gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >*]':
prog.cpp:10:2:   required from 'void Diag(Inverse, Inverse) [with Inverse = __gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >]'
prog.cpp:30:39:   required from here
/usr/include/c++/4.9/bits/range_access.h:78:5: error: request for member 'end' in '__cont', which is of pointer type '__gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >* const' (maybe you meant to use '->' ?)
prog.cpp: In instantiation of 'void Diag(Inverse, Inverse) [with Inverse = __gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >]':
prog.cpp:30:39:   required from here
/usr/include/c++/4.9/bits/range_access.h:68:5: note: template<class _Container> decltype (__cont.end()) std::end(_Container&)
     end(_Container& __cont) -> decltype(__cont.end())
     ^
/usr/include/c++/4.9/bits/range_access.h:68:5: note:   template argument deduction/substitution failed:
/usr/include/c++/4.9/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(_Container&) [with _Container = __gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >*]':
prog.cpp:10:2:   required from 'void Diag(Inverse, Inverse) [with Inverse = __gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >]'
prog.cpp:30:39:   required from here
/usr/include/c++/4.9/bits/range_access.h:68:5: error: request for member 'end' in '__cont', which is of pointer type '__gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >*' (maybe you meant to use '->' ?)
prog.cpp: In instantiation of 'void Diag(Inverse, Inverse) [with Inverse = __gnu_cxx::__normal_iterator<std::vector<double>*, std::vector<std::vector<double> > >]':
prog.cpp:30:39:   required from here
prog.cpp:12:3: error: unable to deduce 'auto&&' from 'row'
   for(auto col : row)
   ^
stdout
Standard output is empty