如何在C ++编译器中实现模板(General / Variadic)功能 [英] How template(General/Variadic) functionality implemented in C++ Compiler

查看:101
本文介绍了如何在C ++编译器中实现模板(General / Variadic)功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





不要将这个问题视为一个复杂问题。我想知道的是,编译器开发人员正在使用哪些机制来实现这两个问题。 模板可变参数模板功能。我研究了这个主题并找到了一些可选机制,例如C风格预处理技巧结构化模板功能

我也找到了以下链接,

http://stackoverflow.com/questions/7683041/how-to-implement-variadic-template-with-pre-c0xvs2008 [ ^ ]



主要我想知道的是我们如何在旧的C ++编译器中实现类似方案的可变参数模板(不要把它当作重新发明轮子)。如果你能提供一些有用的链接或来源,请发帖回复。

谢谢。

(对不起,我的英文不好)

Hi,

Do not take this question as a complex one.What I want to know is,Which mechanisms are being used by compiler developers to implement both general "template" and "variadic template" functionality.I've researched about this topic and found some optional mechanisms such as "C style preprocessing trick" and structured template fucntions.
And I have found following link also,
http://stackoverflow.com/questions/7683041/how-to-implement-variadic-template-with-pre-c0xvs2008[^]

Mainly I want to know is How can we implement variadic template like scenario in older C++ compiler(do not take this as reinventing the wheel).Please post replies,if you can provide some useful links or sources.
Thank you.
(Sorry for my bad english)

推荐答案

根据最初的不要把这个问题视为一个复杂的问题。,我只能得出结论,唯一有效的答案是NULL,SEGV或NaN。



模板本身 devilisly 很难做对。变量模板是......更难。



主要我想知道的是我们如何在旧的C ++编译器中实现类似方案的可变参数模板

不可能。您需要一个完整的C ++解析器来理解它,然后您已经将整个AST发送到后端。在MS-parlance中,您必须实现c1xxEXTRAPLUS.dll,然后将其移交给c2.dll。没有办法(合理可靠地)将C ++ 11代码转换为C ++ 98代码。
Based on the initial "Do not take this question as a complex one.", I can only conclude the only valid answer is NULL, SEGV, or NaN.

Templates themselves are devilisly hard to get right. Variadic templates are ... harder.

Mainly I want to know is How can we implement variadic template like scenario in older C++ compiler
Not possible. You'd need a complete C++ parser to understand it, and by then you already have the whole AST to send to the backend. In MS-parlance, you'd have to implement a c1xxEXTRAPLUS.dll, and then simply hand it off to c2.dll. There is no way to (reasonably and reliably) convert C++ 11 code into C++ 98 code.


这篇关于如何在C ++编译器中实现模板(General / Variadic)功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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