程序:main.cpp
struct X {
int x;
};
export template <class T> T const& min(T const&, T const&);
int main()
{
return min(2, 3);
}
x.cpp
struct X {
int x;
};
export template <class T> T const& min(T const &a, T const &b) {
return a<b ? a : b;
}
错误:用gcc编译
export.cpp:23: warning: keyword ‘export’ not implemented, and will be ignored
export.cpp: In function ‘int main()’:
export.cpp:27: error: call of overloaded ‘min(int, int)’ is ambiguous
swap.cpp:16: warning: keyword ‘export’ not implemented, and will be ignored
错误:用EDG编译器编译
export.cpp", line 27: error: more than one instance of overloaded function
export.cpp", line 23: error: support for exported templates is disabled
swap.cpp", line 16: error: support for exported templates is disabled
谁能解决这个问题?
有人解释一下 export 关键字的用法吗?
最佳答案
export 关键字非常无用,据我所知,EDG 是唯一实现它的编译器。该关键字在 C++0x 中已弃用。至于它的用途 - 甚至不考虑它。
关于c++ - 在模板中使用 'export' 关键字时解决此错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3352554/