I have been using GDBs "call" functionality for last few weeks and it seems very useful Code like below
void VectorPrint(const std::vector<int>& v)
{
std::cout << "start printing vector\n";
for (int i = 0; i < v.size(); ++i) {
std::cout << v[i];
if (i != v.size() - 1)
std::cout << "\n";
}
//std::cout << "\n printing end \n";
}
(gdb) call VectorPrint(any1DVectorhere) This executes the above function and prints the vector contents on console.
The issue I am facing is, I am unable to call the same function if it is templated, something like below. GDB does not recognize the templated functions
template <typename Traits>
template <typename myVec>
void MyClass<Traits>::VectorPrint(const std::vector<myVec>& v)
{
std::cout << "start printing vector\n";
for (int i = 0; i < v.size(); ++i) {
std::cout << v[i];
if (i != v.size() - 1)
std::cout << "\n";
}
//std::cout << "\n printing end \n";
}
Could anyone suggest how to get the call functionality working with GDB in this usecase ? Any help is highly appreciated.
Thanks a lot in advance !