模板化代码无法调用正确的构造函数 [英] templated code not able to call correct constructor
问题描述
我正在从HP-UX编译器aCC 5.55切换到aCC 6.13,我得到
以下错误:
" templateptr。 h",第20行:错误#2289:无实例
构造函数" defclass :: base :: base"匹配
参数列表
参数类型为:(obj *)
:defclass :: base(p)
$ b在实例化期间检测到$ b ^
" templateptr< T> :: templateptr(T *)[含
T = obj] "在第50行
" starter.h"
由于obj来自一个defclass,我没有看到问题。 />
我用来编译的行是:
/ opt / bin / aCC -o main main.cxx
我在使用GCC 3.4.6的linux机箱上也遇到了类似的问题,而且它不是3.2.3的问题。
我以为它可能是新编译器中新的两个名称查找
但传递+ dep_name和+ nodep_name开关没有产生
差异。
有没有人有任何想法?
-----------------
main.cxx
-----------------
#include< iostream>
#include" starter.h"
int main(无效)
{
起动器s;
返回0;
}
--------------
starter.h
--------------
#include" templateptr.h"
class obj;
typedef templateptr< objobj_ptr;
class starter
{
public:
starter(){}
~starter(){}
obj_ptr p;
};
------------------- -
template_ptr.h
--------------------
#include " itrefcounted.h"
模板< class T>
class templateptr
:public defclass: :base
{
public:
inline templateptr(T * p = 0);
};
模板< class T>
inline
templateptr< T> :: templateptr(T * p)
:defclass :: base(p)
{
}
------------ -
defclass.h
-------------
class defclass
{
public:
class base
{
public:
/ / base(base b);
base(defclass * p = 0);
defclass * m_ref;
};
朋友类基地;
< br $>
};
---------------
defclass.cxx
---------------
#include" defclass.h"
itrefcounted :: base(defclass * p)
:m_ref(p)
{
}
-------- -
obj.h
---------
#include" defclass.h"
class obj
:public defclass
{
public:
obj(){}
~obj(){}
};
< blockquote> Keith Halligan写道:
我正在从HP-UX编译器aCC 5.55切换到aCC 6.13而且我得到了
以下错误:
" templateptr.h",第20行:错误#2289:无实例
构造函数" defclass :: base :: base" ;匹配
参数列表
参数类型为:(obj *)
:defclass :: base(p)
$ b在实例化期间检测到$ b ^
" templateptr< T> :: templateptr(T *)[含
T = obj] "在第50行
" starter.h"
由于obj来自一个defclass,我没有看到问题。 />
我用来编译的行是:
/ opt / bin / aCC -o main main.cxx
我在使用GCC 3.4.6的linux机箱上也遇到了类似的问题,而且它是b / b的b $ b不是问题。
我以为它可能是新编译器中新的两个名称查找
但传递+ dep_name和+ nodep_name开关没有
的区别。
有人有任何想法吗?
请收集_one_模块中的所有代码,并再次发布*。
[。 ..disconnected和不完整的代码剪断...]
V
-
请删除资金' 'A'在通过电子邮件回复时
我没有回复最热门的回复,请不要问
5月1日下午6:08,Victor Bazarov < v.Abaza ... @ comAcast.netwrote:
Keith Halligan写道:
I ''从HP-UX编译器aCC 5.55切换到aCC 6.13,我得到
以下错误:
" templateptr.h",第20行:错误#2289:无实例
构造函数" defclass :: base :: base"匹配
参数列表
参数类型为:(obj *)
:defclass :: base(p)
$ b在实例化期间检测到$ b ^
" templateptr< T> :: templateptr(T *)[含
T = obj] "在第25行的
" starter.h"
因为obj是从defclass派生的,所以我没有看到问题。
我用来编译的行是:
/ opt / bin / aCC -o main main.cxx
我在使用GCC 3.4.6的linux机箱上也遇到了类似的问题并且它不是3.2.3中的
不是问题。
我以为它可能是新编译器中新的两个名称查找
但是传递+ dep_name和+ nodep_name交换机没有产生不同的b $ b差价。
有没有人有任何想法?
请收集_one_模块中的所有代码,并再次发布*。
[。 ..已断开且不完整的代码被剪断...]
V
-
请删除资金' 'A'在通过电子邮件回复时
我没有回复最热门的回复,请不要问
这就是海报要求的所有来源。
#include< iostream>
class obj;
typedef templateptr< objobj_ptr;
类启动器
{
public:
starter(){}
~starter(){}
obj_ptr p;
};
模板< class T>
class templateptr
:public defclass :: base
{
public:
inline templateptr(T * p = 0);
} ;
模板< class T>
inline
templateptr< T> :: templateptr(T * p)
:defclass :: base(p)
{
}
class defclass
{
public:
班级基础
{
public:
// base(
base b);
base(defclass * p = 0);
defclass * m_ref;
} ;
朋友类基地;
};
defclass :: base(defclass * p)
:m_ref(p)
{
}
class obj
:public defclass
{
public:
obj(){}
~obj(){}
};
int main(无效)
{
starter s ;
返回0;
}
Keith Halligan写道:
>
#include< iostream>
不需要。
>
class obj;
typedef templateptr< objobj_ptr;
templateptr undefined here
>
class starter
{
public:
starter(){}
~starter(){}
>
obj_ptr p;
因为未定义obj_ptr(见上文),这是一个错误。
>
};
模板< class T>
class templateptr
:public defclass :: base
defclass :: base undefined here
{
public:
inline templateptr(T * p = 0);
};
模板< class T>
inline
templateptr< T> :: templateptr(T * p)
:defclass :: base(p)
{
}
class defclass
{
public:
class base
{
public:
// base(base b);
base(defclass * p = 0);
defclass * m_ref;
};
朋友类基地;
};
defclass :: base(defclass * p)
应该是defclass :: base :: base
< blockquote clas s =post_quotes>
:m_ref(p)
{
}
class obj
:public defclass
{
public:
obj(){}
~obj(){}
};
int main(无效)
{
起始点;
返回0;
}
I''m switching from the HP-UX compiler aCC 5.55 to aCC 6.13 and I get
the following error:
"templateptr.h", line 20: error #2289: no instance
of constructor "defclass::base::base" matches the
argument list
argument types are: (obj *)
: defclass::base(p)
^
detected during instantiation of
"templateptr<T>::templateptr(T *) [with
T=obj]" at line 50 of
"starter.h"
Since an obj is derived from a defclass, I don''t see the problem.
The line I''m using to compile is:
/opt/bin/aCC -o main main.cxx
I''m also getting similar issues on a linux box with GCC 3.4.6 and it
wasn''t an issue with 3.2.3.
I was thinking it might be the new two name lookup in the new compiler
but passing +dep_name and +nodep_name switches are making no
difference.
Does anyone have any ideas on it?
-----------------
main.cxx
-----------------
#include <iostream>
#include "starter.h"
int main(void)
{
starter s;
return 0;
}
--------------
starter.h
--------------
#include "templateptr.h"
class obj;
typedef templateptr<objobj_ptr;
class starter
{
public:
starter() {}
~starter() {}
obj_ptr p;
};
--------------------
template_ptr.h
--------------------
#include "itrefcounted.h"
template <class T>
class templateptr
: public defclass::base
{
public:
inline templateptr(T* p = 0);
};
template <class T>
inline
templateptr<T>::templateptr(T* p)
: defclass::base(p)
{
}
-------------
defclass.h
-------------
class defclass
{
public:
class base
{
public:
// base (base b);
base (defclass* p = 0);
defclass *m_ref;
};
friend class base;
};
---------------
defclass.cxx
---------------
#include "defclass.h"
itrefcounted::base(defclass *p)
: m_ref(p)
{
}
----------
obj.h
---------
#include "defclass.h"
class obj
: public defclass
{
public:
obj() {}
~obj() {}
};
Keith Halligan wrote:I''m switching from the HP-UX compiler aCC 5.55 to aCC 6.13 and I get
the following error:
"templateptr.h", line 20: error #2289: no instance
of constructor "defclass::base::base" matches the
argument list
argument types are: (obj *)
: defclass::base(p)
^
detected during instantiation of
"templateptr<T>::templateptr(T *) [with
T=obj]" at line 50 of
"starter.h"
Since an obj is derived from a defclass, I don''t see the problem.
The line I''m using to compile is:
/opt/bin/aCC -o main main.cxx
I''m also getting similar issues on a linux box with GCC 3.4.6 and it
wasn''t an issue with 3.2.3.
I was thinking it might be the new two name lookup in the new compiler
but passing +dep_name and +nodep_name switches are making no
difference.
Does anyone have any ideas on it?Please collect all the code in _one_ module, and post it *again*.
[...disconnected and incomplete code snipped...]V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask
On May 1, 6:08 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:Keith Halligan wrote:I''m switching from the HP-UX compiler aCC 5.55 to aCC 6.13 and I get
the following error:
"templateptr.h", line 20: error #2289: no instance
of constructor "defclass::base::base" matches the
argument list
argument types are: (obj *)
: defclass::base(p)
^
detected during instantiation of
"templateptr<T>::templateptr(T *) [with
T=obj]" at line 50 of
"starter.h"
Since an obj is derived from a defclass, I don''t see the problem.
The line I''m using to compile is:
/opt/bin/aCC -o main main.cxx
I''m also getting similar issues on a linux box with GCC 3.4.6 and it
wasn''t an issue with 3.2.3.
I was thinking it might be the new two name lookup in the new compiler
but passing +dep_name and +nodep_name switches are making no
difference.
Does anyone have any ideas on it?
Please collect all the code in _one_ module, and post it *again*.
[...disconnected and incomplete code snipped...]
V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t askHere''s it all in one source as the poster requested.
#include <iostream>
class obj;
typedef templateptr<objobj_ptr;
class starter
{
public:
starter() {}
~starter() {}
obj_ptr p;
};
template <class T>
class templateptr
: public defclass::base
{
public:
inline templateptr(T* p = 0);
};
template <class T>
inline
templateptr<T>::templateptr(T* p)
: defclass::base(p)
{
}
class defclass
{
public:
class base
{
public:
// base (base b);
base (defclass* p = 0);
defclass *m_ref;
};
friend class base;
};
defclass::base(defclass *p)
: m_ref(p)
{
}
class obj
: public defclass
{
public:
obj() {}
~obj() {}
};
int main(void)
{
starter s;
return 0;
}
Keith Halligan wrote:>
#include <iostream>unneeded.
>
class obj;
typedef templateptr<objobj_ptr;templateptr undefined here
>
class starter
{
public:
starter() {}
~starter() {}
obj_ptr p;because obj_ptr is not defined (see above), this is an error.
>
};
template <class T>
class templateptr
: public defclass::basedefclass::base undefined here
{
public:
inline templateptr(T* p = 0);
};
template <class T>
inline
templateptr<T>::templateptr(T* p)
: defclass::base(p)
{
}
class defclass
{
public:
class base
{
public:
// base (base b);
base (defclass* p = 0);
defclass *m_ref;
};
friend class base;
};
defclass::base(defclass *p)should be defclass::base::base
: m_ref(p)
{
}
class obj
: public defclass
{
public:
obj() {}
~obj() {}
};
int main(void)
{
starter s;
return 0;
}
这篇关于模板化代码无法调用正确的构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!