在icpc中导出模板 [英] exported templates in icpc

查看:63
本文介绍了在icpc中导出模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


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;

}

解决方案

1月7日上午5:11,ciccio< no_valid_em ... @ spam.comwrote:


大家好,


intel c ++编译器支持导出模板,但我想知道

关于他们使用的语法。如果我比较

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]


Salt_Peter写道:


1月7日上午5:11,ciccio< ; no_valid_em ... @ spam.comwrote:


>大家好,

英特尔c ++编译器支持导出的模板,但我想知道关于他们使用的语法的一点点。如果我比较
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]



是的我知道这一点,但根据strostroup,不应该在file1.cpp中导出

。所以问题是,语法是否正确?

因此,它属于这个新闻组;-)


1月7日,1:下午33点,ciccio< no_valid_em ... @ spam.comwrote:


Salt_Peter写道:


1月7日上午5:11,ciccio< no_valid_em ... @ spam.comwrote:

< blockquote class =post_quotes>
intel c ++编译器支持导出的模板,但是我想知道他们使用过的语法。如果我比较

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]


是的我知道这一点,但根据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 a
bit about their used syntax. If I compare the syntax written in
strostroup''s book then there is a difference. So I was wondering if the
following 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;
}

解决方案

On Jan 7, 5:11 am, ciccio <no_valid_em...@spam.comwrote:

Hi all,

The intel c++ compiler supports exported templates but I was wondering a
bit about their used syntax. If I compare the syntax written in
strostroup''s book then there is a difference. So I was wondering if the
following 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]


Salt_Peter wrote:

On Jan 7, 5:11 am, ciccio <no_valid_em...@spam.comwrote:

>Hi all,

The intel c++ compiler supports exported templates but I was wondering a
bit about their used syntax. If I compare the syntax written in
strostroup''s book then there is a difference. So I was wondering if the
following 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]

Yes I am aware of that, but according to strostroup there should not be
an export in file1.cpp. So the question was, is the syntax correct?
Hence, it belongs in this news group ;-)


On Jan 7, 1:33 pm, ciccio <no_valid_em...@spam.comwrote:

Salt_Peter wrote:

On Jan 7, 5:11 am, ciccio <no_valid_em...@spam.comwrote:

The intel c++ compiler supports exported templates but I
was wondering a bit about their used syntax. If I compare
the syntax written in strostroup''s book then there is a
difference. So I was wondering if the following 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]

Yes I am aware of that, but according to strostroup there
should not be an 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 the
standard didn''t actually correspond to the intent. I think the
code you show corresponds to the intent---it seems logical,
anyway. Stroustrup probably wrote his book before having an
actual implementation at hand, and based himself soley on the
text in the standard.

Your code is conform with the latest draft. What Stroustrup
seems to be saying corresponds to the text in C++98 (which says
that "A template shall be exported only once in a program", and
that the definition must be exported).

--
James Kanze (GABI Software) mailto:ja*********@gmail.com
Conseils en informatique orient???e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S???mard, 78210 St.-Cyr-l''???cole, France, +33 (0)1 30 23 00 34


这篇关于在icpc中导出模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆