Hi , just wanted to ask.. because i was trying to access some data from my vector container. i was using the code below to access it
for (std::vector<string>::const_iterator i = events.begin(); i != events.end(); ++i)
std::cout << *i << ""<<endl;
the funny thing is, it works in my other program . but it does not work on the other. the error is below: sorry the error code is quite long
please advise, as i am new to this
/usr/include/c++/4.9/bits/streambuf_iterator.h:210:5: note: template argument deduction/substitution failed:
IDS.cpp:143:74: note: ‘std::vector<std::basic_string<char> >::const_iterator {aka __gnu_cxx::__normal_iterator<const std::basic_string<char>*, std::vector<std::basic_string<char> > >}’ is not derived from ‘const std::istreambuf_iterator<_CharT, _Traits>’
for (vector<string>::const_iterator i = events.begin(); i != events.end(); ++i)
^
In file included from /usr/include/i386-linux-gnu/c++/4.9/bits/stdc++.h:66:0,
from IDS.cpp:19:
/usr/include/c++/4.9/complex:471:5: note: template<class _Tp> bool std::operator!=(const std::complex<_Tp>&, const std::complex<_Tp>&)
operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)
^
/usr/include/c++/4.9/complex:471:5: note: template argument deduction/substitution failed:
IDS.cpp:143:74: note: ‘std::vector<std::basic_string<char> >::const_iterator {aka __gnu_cxx::__normal_iterator<const std::basic_string<char>*, std::vector<std::basic_string<char> > >}’ is not derived from ‘const std::complex<_Tp>’
for (vector<string>::const_iterator i = events.begin(); i != events.end(); ++i)
^
In file included from /usr/include/i386-linux-gnu/c++/4.9/bits/stdc++.h:66:0,
from IDS.cpp:19:
/usr/include/c++/4.9/complex:476:5: note: template<class _Tp> bool std::operator!=(const std::complex<_Tp>&, const _Tp&)
operator!=(const complex<_Tp>& __x, const _Tp& __y)
^
/usr/include/c++/4.9/complex:476:5: note: template argument deduction/substitution failed:
IDS.cpp:143:74: note: ‘std::vector<std::basic_string<char> >::const_iterator {aka __gnu_cxx::__normal_iterator<const std::basic_string<char>*, std::vector<std::basic_string<char> > >}’ is not derived from ‘const std::complex<_Tp>’
for (vector<string>::const_iterator i = events.begin(); i != events.end(); ++i)
^
Consider upgrading the compiler to the most recent version. It may be worth upgrading the version of Ubuntu that you have too . Later versions of gcc use -std=c++14 by default. I always try to have the latest of everything.
MyProg is the name of the executable file you want to have.
Warnings are your friend, they tell you about problems with your program. Even if it compiles without errors, the warnings mean there will be problems with how the program runs. Ideally one isn't finished until there are no warnings.
Using auto with a nested vector:
1 2 3 4 5 6
for ( constauto& row : events )
{
for ( constauto& s : row ) { std::cout << s << " ";
}
std::cout << '\n';
}