avatar
c*e
1
class A
{
public:
template
operator T & ()
{
return *(new T);
}
template
operator T * ()
{
return (new T);
}
};
int main ()
{
A a;
int & i = a; //wont compile under gcc3.2.3 but ok with 3.4
int * j = a;
}
what does the spec say about this?
thx a ton!
avatar
t*t
2
FT,有难度
你这是要干嘛呀, factory?这回头怎么释放啊, delete &i? 怎么看怎么不自然啊

【在 c********e 的大作中提到】
: class A
: {
: public:
: template
: operator T & ()
: {
: return *(new T);
: }
: template
: operator T * ()

avatar
t*t
3
我手上没有3.2.3,不过我看没什么问题啊,除了看起来很恶心以外
cf: 13.3.1.6 [over.match.ref] & 8.5.3 [dcl.init.ref]

【在 c********e 的大作中提到】
: class A
: {
: public:
: template
: operator T & ()
: {
: return *(new T);
: }
: template
: operator T * ()

avatar
c*e
4
the code is just an example to recreate the problem. never done a template
function that has no augment.
I searched in the gcc release note but didnt find anything that fixed this
after 3.2.3 but apparently something is done here.
thx.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。