#include <string>
#include <sstream>
#include <iostream>
extern "C" {
struct A {
public:
#ifdef __cplusplus
//extern "C++" {
template<typename T>
T to_string(T value) {
return value;
}
//}
#endif /* __cplusplus */
};
}
int main() {
A a;
std::cout << a.to_string<int>(1);
return 0;
}
How to handle situation like this to keep the main function can execute correctly? To make struct A able to use its member function.
Since it seems unable to use extern "C++"
in a struct and it will report error templates must have C++ linkage
currently.