TestTempB.h
#ifndef TESTTEMPB_H_
#define TESTTEMPB_H_
#include <string>
using namespace std;
namespace ddl_lib {
class TestTempB {
public:
TestTempB();
virtual ~TestTempB();
template<class ... Args>
void callCommandB(const string&, const uint32_t*, Args ...);
template<class ... Args>
void callCommandA(const string&, Args ...);
};
} /* namespace ddl_lib */
#endif /* TESTTEMPB_H_ */
TestTempB.cpp
#include "TestTempB.h"
#include "TestTempA.h"
#include "stdint.h"
#include <iostream>
namespace ddl_lib {
TestTempB::TestTempB() {
// TODO Auto-generated constructor stub
}
TestTempB::~TestTempB() {
// TODO Auto-generated destructor stub
}
template<class ... Args>
void TestTempB::callCommandB(const string& cmdName, const uint32_t* cmdSn, Args ... params) {
cout << cmdName << endl;
}
template<class ... Args>
void TestTempB::callCommandA(const string& cmdName, Args ... params) {
callCommandB(cmdName, NULL, params...);
}
} /* namespace ddl_lib */
main
#include <iostream>
#include "TestTempB.h"
using namespace std;
using namespace ddl_lib;
int main() {
string aa="15615";
bool ccc=false;
TestTempB b;
b.callCommandA("name", &aa, &ccc);//undefined reference to `void ddl_lib::TestTempB::callCommandA<std::string*, bool*>(std::string const&, std::string*, bool*)'
}
I'm using the variadic-template. Why the gcc can't deduced the real func? When the callCommandA and callCommandB in the main file,it works just fine.
#include <iostream>
#include "TestTempB.h"
using namespace std;
using namespace ddl_lib;
template<class ... Args>
void callCommandB(const string& cmdName, const uint32_t* cmdSn, Args ... params) {
cout << cmdName << endl;
}
template<class ... Args>
void callCommandA(const string& cmdName, Args ... params) {
callCommandB(cmdName, NULL, params...);
}
int main() {
string aa = "15615";
bool ccc = false;
callCommandA("name", &aa, &ccc); //no erro
}
Why and how could I fix it? Thanks!!!