Essentially, I have a 2D Vector:
std::vector<std::vector<double> > vect = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};
I pass this vector into a function using iterators:
template<typename Inverse>
void Diag(Inverse begin, Inverse end)
{
for(auto row : begin)
{
for(auto col : row)
{
}
}
}
I pass to the function like: Diag(std::begin(vect), std::end(vect))
But I keep getting complained at that there is no matching function, even though I have seen similar range based loops Here.
An example can be found Here
EDIT:
Error Message:
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: