Re: Is this valid ISO C++?
From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 03/30/05
- Next message: Daniel Schüle: "is it undefined behaviour?"
- Previous message: Ioannis Vranos: "Is this valid ISO C++?"
- In reply to: Ioannis Vranos: "Is this valid ISO C++?"
- Next in thread: Ioannis Vranos: "Re: Is this valid ISO C++?"
- Reply: Ioannis Vranos: "Re: Is this valid ISO C++?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 29 Mar 2005 20:08:28 -0500
"Ioannis Vranos" <ivr@remove.this.grad.com> wrote...
> This compiles with MINGW GCC 3.4.2 but not with my other compilers. Is it
> valid ISO C++?
>
>
> #include <vector>
>
>
> template< template<class> class ContainerTemplate, class ValueType>
> inline void test(const ValueType &val)
> {
> ContainerTemplate<ValueType> container(val);
> }
>
>
>
> int main()
> {
> using namespace std;
>
> test<vector>(10);
> }
No, this is not valid for a simple reason that std::vector is a template
that has more than one argument. Your 'ContainerTemplate' template
template argument has only one argument itself.
Until we have template typedefs you're probably out of luck. You could
try declaring your own template deriving form 'vector<T>', but you'd
have to duplicate all functionality.
V
- Next message: Daniel Schüle: "is it undefined behaviour?"
- Previous message: Ioannis Vranos: "Is this valid ISO C++?"
- In reply to: Ioannis Vranos: "Is this valid ISO C++?"
- Next in thread: Ioannis Vranos: "Re: Is this valid ISO C++?"
- Reply: Ioannis Vranos: "Re: Is this valid ISO C++?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|