[prev in list] [next in list] [prev in thread] [next in thread]
List: hpux-cxx-dev
Subject: Re: CXX-DEV: using templates with aC++
From: Daniel Alex Finkelstein <dfinkels () siac ! com>
Date: 2000-12-14 15:47:28
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Dec 13, 2000 at 9:31pm, Michael S. Tsirkin wrote:
> Hello!
> Quoting r. Alain Miniussi (alainm@cup.hp.com) "Re: CXX-DEV: using templates with aC++":
> > Subbarao Gaddamadugu wrote:
> > >
> > > The following code sample is compiling fine witn Solaris CC compiler,
> >
> > Because it fails to flag the error.
>
> I don't think this is an error.
It is an error, according to the ISO/IEC 14882 C++ standard (1998). See
pages 257, 236, 109 (relative importance).
> >
> > > but giving errors with aC++ A.03.30
> > > Error 419: "tmpltest.cc", line 6 # 'value_type' is used as a type, but
> > > has not
> > > been defined as a type.
> > > typedef T::value_type value_type;
> > > ^^^^^^^^^^
> > > Error 922: "tmpltest.cc", line 6 # Incomplete type not allowed.
> > > typedef T::value_type value_type;
> > > ^^^^^^^^^^^^^^^^^^^^^^^^
> >
> > You need to add a typename:
> > typedef typename T::value_type value_type;
>
> I think in ANSI C++ in typedef you don't need to specify the typename keyword,
> because the compiler can figure it out itself.
>
>
> >
> > You can have a look to the transition guide for more details/explanation.
> >
> > Alain
> > >
> > > --------------------------------------
> > > #include <vector>
> > > template <class T>
> > > class SimpleType : public T
> > > {
> > > public:
> > > typedef T::value_type value_type;
> > > const value_type* dosomething() {}
> > > };
> > >
> > > int main()
> > > {
> > > SimpleType<std::vector<int> > simple;
> > > return 0;
> > > }
> > > --------------------------------------------
>
>
- --
Daniel Alex Finkelstein
Central Services
phone 212-383-2951
pager 917-427-1630
fax 212-335-0420
Securities Industry Automation Corporation
-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.8
iQA/AwUBOjjrkPthwHD7ijPLEQJZKACgtDA3453xIfcomxOOvXwyftDvDIcAn2Iu
HgXdRijBw+mx1rMtxP+lc4R/
=QYtp
-----END PGP SIGNATURE-----
_________________________________________________________________
To leave this mailing list, send mail to majordomo@cxx.cup.hp.com
with the message UNSUBSCRIBE cxx-dev
_________________________________________________________________
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic