Template-Meta:查明模板定义是否存在 [英] Template-Meta: Finding out whether a template-definition exists
问题描述
假设我们有
模板< typename T>
struct X;
和一些专业化:
template<>
struct X< A {};
template<>
struct X< B {};
template<> ;
struct X< B {};
给定一个类型''U',有没有办法找出是否
定义''X< U>''存在? (结果应该是一个编译 -
时间常数,这样它就可以用于专门化
其他模板。)
Schobi
-
Sp ****** @ gmx。 de 永远不会被阅读
我是HSchober at gmx dot de
补丁缓冲区溢出并不意味着有一个更少攻击者的方式
可以进入你的系统;这意味着你的设计过程非常糟糕
它允许缓冲区溢出,并且你的代码中可能还有数千个b / b
。
Bruce Schneier
Hi,
suppose we have
template< typename T >
struct X;
and some specializations:
template<>
struct X<A{};
template<>
struct X<B{};
template<>
struct X<B{};
Given a type ''U'', is there a way to find out whether the
definition ''X<U>'' exists? (The result should be a compile-
time constant, so that it can be used for specializing
other templates.)
Schobi
--
Sp******@gmx.de is never read
I''m HSchober at gmx dot de
"A patched buffer overflow doesn''t mean that there''s one less way attackers
can get into your system; it means that your design process was so lousy
that it permitted buffer overflows, and there are probably thousands more
lurking in your code."
Bruce Schneier
推荐答案
9月3日下午2:13,Hendrik Schober < SpamT ... @ gmx.dewrote:
On Sep 3, 2:13 pm, "Hendrik Schober" <SpamT...@gmx.dewrote:
假设我们有
模板< typename T>
struct X;
和一些专业化:
template<>
struct X< A {};
模板<>
struct X< B {};
>
模板<>
struct X< B {};
给定类型''U',有没有办法找出
定义X< U>是否存在? (结果应该是一个编译 -
时间常数,这样它就可以用于专门化
其他模板。)
Schobi
-
垃圾邮件... @ gmx.de永远不会被读取
我是HSchober at gmx dot de
补丁缓冲区溢出并不意味着攻击者可以进入你的系统的方式少于b
$ b这意味着你的设计过程非常糟糕
它允许缓冲区溢出,并且你的代码中可能还有数千个b / b
。
Bruce Schneier
Hi,
suppose we have
template< typename T >
struct X;
and some specializations:
template<>
struct X<A{};
template<>
struct X<B{};
template<>
struct X<B{};
Given a type ''U'', is there a way to find out whether the
definition ''X<U>'' exists? (The result should be a compile-
time constant, so that it can be used for specializing
other templates.)
Schobi
--
SpamT...@gmx.de is never read
I''m HSchober at gmx dot de
"A patched buffer overflow doesn''t mean that there''s one less way attackers
can get into your system; it means that your design process was so lousy
that it permitted buffer overflows, and there are probably thousands more
lurking in your code."
Bruce Schneier
IMHO
模板< typename T>
struct X
{
enum {kIsSpecialized = false};
};
模板<>
struct X< A>
{
enum {kIsSpecialized = true};
};
if你不能触摸结构你可能会手动更新
类型列表(a la Alexandrescu)的专业类型anche检查
a类型是否在类型列表中...
我想不出任何其他方式(所以可能还有成千上万的b $ b更多......)
IMHO
template< typename T >
struct X
{
enum { kIsSpecialized = false };
};
template<>
struct X< A >
{
enum { kIsSpecialized = true };
};
if you cannot touch the structs you might keep a manually updated
typelist ( a la Alexandrescu ) of the specialized types anche check if
a type is in the typelist...
I can''t think of any other way ( so probably there are a thousands
more ... )
xt*********@gmail.com 写道:
9月3日下午2:13,Hendrik Schober和< SpamT ... @ gmx.dewrote:
On Sep 3, 2:13 pm, "Hendrik Schober" <SpamT...@gmx.dewrote:
>
假设我们有
模板< typename T>
struct X;
和一些专业化:
模板<>
结构X< A {};
模板<>
结构X< B {};
模板<>
结构X< B {};
给定类型U,有没有办法找出
定义X< U>是否存在? (结果应该是一个编译时间常数,以便它可以用于专门化其他模板。)
Schobi
-
垃圾邮件... @ gmx.de永远不会被读取
我是gchx dot de
的HSchober补丁缓冲区溢出并不意味着只有一个攻击者可以进入你的系统;这意味着你的设计过程太糟糕了,它允许缓冲区溢出,并且你的代码中可能还有数千个潜伏着。
Bruce Schneier
>Hi,
suppose we have
template< typename T >
struct X;
and some specializations:
template<>
struct X<A{};
template<>
struct X<B{};
template<>
struct X<B{};
Given a type ''U'', is there a way to find out whether the
definition ''X<U>'' exists? (The result should be a compile-
time constant, so that it can be used for specializing
other templates.)
Schobi
--
SpamT...@gmx.de is never read
I''m HSchober at gmx dot de
"A patched buffer overflow doesn''t mean that there''s one less way attackers
can get into your system; it means that your design process was so lousy
that it permitted buffer overflows, and there are probably thousands more
lurking in your code."
Bruce Schneier
IMHO
模板< typename T>
struct X
{
enum {kIsSpecialized = false};
};
模板<>
struct X< A>
{
enum {kIsSpecialized = true};
};
if你不能触摸结构你可能会手动更新
IMHO
template< typename T >
struct X
{
enum { kIsSpecialized = false };
};
template<>
struct X< A >
{
enum { kIsSpecialized = true };
};
if you cannot touch the structs you might keep a manually updated
你是什么意思你不能触摸结构?
what do you mean by "you cannot touch the structs"?
类型列表(a la Alexandrescu)的专业类型anche检查
a类型是否在类型列表中...
typelist ( a la Alexandrescu ) of the specialized types anche check if
a type is in the typelist...
类型列表包含什么?
what will the typelist contains?
我不能想到任何其他方式(所以可能有数千个
更多......)
I can''t think of any other way ( so probably there are a thousands
more ... )
-
谢谢
Barry
--
Thanks
Barry
在2007-09-03 14:47,Barry写道:
On 2007-09-03 14:47, Barry wrote:
xt ********* @ gmail.com 写道:
> 9月3日,2日:13 pm,Hendrik Schober < SpamT ... @ gmx.dewrote:
>On Sep 3, 2:13 pm, "Hendrik Schober" <SpamT...@gmx.dewrote:
>>
假设我们有
模板< typename T>
struct X;
和一些专业化:
模板<>
结构X< A {};
模板<>
结构X< B {};
模板<>
结构X< B {};
给定类型U,有没有办法找出
定义X< U>是否存在? (结果应该是一个编译时间常数,以便它可以用于专门化其他模板。)
Schobi
-
垃圾邮件... @ gmx.de永远不会被读取
我是gchx dot de
的HSchober补丁缓冲区溢出并不意味着只有一个攻击者可以进入你的系统;这意味着你的设计过程太糟糕了,它允许缓冲区溢出,并且你的代码中可能还有数千个潜伏着。
Bruce Schneier
>>Hi,
suppose we have
template< typename T >
struct X;
and some specializations:
template<>
struct X<A{};
template<>
struct X<B{};
template<>
struct X<B{};
Given a type ''U'', is there a way to find out whether the
definition ''X<U>'' exists? (The result should be a compile-
time constant, so that it can be used for specializing
other templates.)
Schobi
--
SpamT...@gmx.de is never read
I''m HSchober at gmx dot de
"A patched buffer overflow doesn''t mean that there''s one less way attackers
can get into your system; it means that your design process was so lousy
that it permitted buffer overflows, and there are probably thousands more
lurking in your code."
Bruce Schneier
恕我直言
模板< typename T>
struct X
{
enum {kIsSpecialized = false};
};
模板<>
struct X< ; A>
{
枚举{kIsSpecialized = true};
};
如果您无法触摸结构,可以保留手动更新的
IMHO
template< typename T >
struct X
{
enum { kIsSpecialized = false };
};
template<>
struct X< A >
{
enum { kIsSpecialized = true };
};
if you cannot touch the structs you might keep a manually updated
你是什么意思你不能触摸结构?
what do you mean by "you cannot touch the structs"?
如果你不能改变包含特化的代码。
If you can''t change the code containing the specialisations.
> typelist(a la Alexandrescu)的专业类型anche检查
类型是否在类型列表中...
>typelist ( a la Alexandrescu ) of the specialized types anche check if
a type is in the typelist...
什么将是typelist包含?
what will the typelist contains?
每个专业化的一次,换句话说,它应该是所有专业的列表
。
-
Erik Wikstr?m
Once of each of the specialisations, in other words it should be a list
of all the specialisations.
--
Erik Wikstr?m
这篇关于Template-Meta:查明模板定义是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!