c++ - 在模板中使用 'export' 关键字时解决此错误?

标签 c++ templates export

程序: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/

相关文章:

c++ - 全屏写意

c++ - OpenCV 视频捕获 : Howto get specific frame correctly?

ios - 在同一个文件中导出文本和图像

excel - 下载公开的谷歌电子表格

c++ - 销毁时神秘的段错误

ios - 如何将语音备忘录从我的应用程序导出到 iPhone 的语音备忘录应用程序?

c++ - 我可以通过其基础的默认构造函数实例化一个结构吗?

c++ - C++的类图

c++ - 确定传递给模板函数的变量类型

C++、海湾合作委员会 : avoid evaluation of useless expressions