 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Mehturt@gmail.com Guest
|
Posted: Tue Nov 29, 2005 4:06 pm Post subject: template class with template as parameter |
|
|
I have this code which compiles fine under gcc 4:
#include <vector>
#include <string>
template<
typename T = std::string
, template
, typename stringize_operation = stringize_fo<T>
{
// member functions here
};
However, when compiling using cxx (Compaq C++ V6.5-014 for Compaq Tru64
UNIX V5.1B (Rev. 2650)) I get the following errors:
cxx: Warning: ***.hh, line 55: declaration of "T" hides template
parameter
, template <typename T> class CONTAINER = std::vector
-------------------------------------^
cxx: Error: ***.hh, line 56: class template "std::vector" is not
compatible with template template parameter "CONTAINER"
, typename stringize_operation = stringize_fo<T>
----------------^
I wonder whether gcc or cxx is correct.
Thanks
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Carl Barron Guest
|
Posted: Wed Nov 30, 2005 10:56 am Post subject: Re: template class with template as parameter |
|
|
In article <1133276845.346304.247910 (AT) o13g2000cwo (DOT) googlegroups.com>,
<"Mehturt (AT) gmail (DOT) com"> wrote:
| Quote: | I have this code which compiles fine under gcc 4:
#include <vector
#include
template
typename T = std::string
, template
, typename stringize_operation = stringize_fo<T
class Stringizer
{
// member functions here
};
However, when compiling using cxx (Compaq C++ V6.5-014 for Compaq Tru64
UNIX V5.1B (Rev. 2650)) I get the following errors:
cxx: Warning: ***.hh, line 55: declaration of "T" hides template
parameter
, template
-------------------------------------^
cxx: Error: ***.hh, line 56: class template "std::vector" is not
compatible with template template parameter "CONTAINER"
, typename stringize_operation = stringize_fo<T
----------------^
I wonder whether gcc or cxx is correct.
Thanks
the template std::vector has two parameters not one and gcc is in |
error in extending this. This a major problem with template template
parameters.
either pass the complete container type as a type parameter or require
two parameters of the template template parameter.
[template class vector;]
template
<
class C =std::vector
class Op = stringize_to<typename C::value_type>
| Quote: | class Stringizer
{ |
public:
typedef typename C::value_type T;
// ...
};
is probably the 'best' solution, as it will work with any class C
having member functions of std::vector you use in Stringizer, with the
same semantics as those of std::vector and has a member typedef
value_type, the type stored in the container.
More compilers than not will behave as cxx. Technically gcc is
non-standard here.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|