本文介绍了在icpc中导出模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好, intel c ++编译器支持导出的模板,但我想知道他们使用的语法是否有点b $ b。如果我比较 strostroup'的书中所用的语法,那就有区别了。所以我想知道英特尔提出的 语法是否正确。 非常感谢 // file1.cpp #include< stdio.h> static void trace(){printf(" File 1 \ n"); } 导出模板< class TT const& min(T const&,T const&); int main(){ trace(); return min(2,3 ); } // file2.cpp #include< stdio.h> static void trace(){printf(" File 2 \ n)"); } 导出模板< class TT const& min(T const& a,T const& b){ trace(); 返回< b? a:b; } 解决方案 您先与英特尔核对过吗? 这个新闻组不包括特定的编译器。 [OT] 语法看起来正确,你需要-export / -export_dir选项。 [/ OT] 您先与英特尔核对过吗? 这个新闻组不包括特定的编译器。 [OT] 语法看起来正确,你需要-export / -export_dir选项。 [/ OT] 是的我知道这一点,但根据strostroup,不应该在file1.cpp中导出 。所以问题是,语法是否正确? 因此,它属于这个新闻组;-) 我似乎记得最终采用的措辞是 标准没有'' t实际上对应于意图。我认为你显示的 代码对应于意图---看起来合乎逻辑,无论如何都是。 Stroustrup可能在手头有一个 的实际实现之前写了他的书,并且基于标准中的 文本。 您的代码符合最新草稿。什么Stroustrup 似乎在说与C ++ 98中的文字相对应(其中说' 模板只能在一个程序中导出一次,并且 必须导出定义。 - James Kanze(GABI Software)mailto:ja *** ******@gmail.com Conseils en informatique orient ??? e objet / Beratung in objektorientierter Datenverarbeitung 9个地方S ??? mard,78210 St.-Cyr-l''??? cole,France,+ 33(0)1 30 23 00 34 Hi all,The intel c++ compiler supports exported templates but I was wondering abit about their used syntax. If I compare the syntax written instrostroup''s book then there is a difference. So I was wondering if thefollowing syntax proposed by intel is correct.Thanks a lot// file1.cpp#include <stdio.h>static void trace() { printf("File 1\n"); }export template<class TT const& min(T const&, T const&);int main() {trace();return min(2, 3);}// file2.cpp#include <stdio.h>static void trace() { printf("File 2\n"); }export template<class TT const& min(T const &a, T const &b) {trace();return a<b? a: b;} 解决方案Did you check with Intel first?This newsgroup doesn''t cover specific compilers.[OT]The syntax looks correct, you do need the -export/-export_dir options.[/OT]Did you check with Intel first?This newsgroup doesn''t cover specific compilers.[OT]The syntax looks correct, you do need the -export/-export_dir options.[/OT]Yes I am aware of that, but according to strostroup there should not bean export in file1.cpp. So the question was, is the syntax correct?Hence, it belongs in this news group ;-)I seem to recall that the wording finally adopted into thestandard didn''t actually correspond to the intent. I think thecode you show corresponds to the intent---it seems logical,anyway. Stroustrup probably wrote his book before having anactual implementation at hand, and based himself soley on thetext in the standard.Your code is conform with the latest draft. What Stroustrupseems to be saying corresponds to the text in C++98 (which saysthat "A template shall be exported only once in a program", andthat the definition must be exported).--James Kanze (GABI Software) mailto:ja*********@gmail.comConseils en informatique orient???e objet/Beratung in objektorientierter Datenverarbeitung9 place S???mard, 78210 St.-Cyr-l''???cole, France, +33 (0)1 30 23 00 34 这篇关于在icpc中导出模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!