german diago wrote:
> Hello. I'm trying to implement a variadic vector type in c++0x with
> the variadic templates proposal (in gcc-4.4).
>
> I tried with this, and I wonder why I can't do this.
>
> template <class...Values>
> class vector {
> private:
> //This is not legal
> Values v...;
> ....
> };
>
> I think this should be allowed and a way to access every v would be to
> give v, v2, v3 names to the unpacked parameter pack or something
> similar.
>
> Now I'm trying to do this, which is legal:
>
> template <class... Values> class vector;
>
> template <class Head, class...Tail> class vector<Head, Tail...> :
> vector<Head, Tail...>
> {
> private:
> Head head_;
> };
>
> But the problem is that as every head_ variable shadows its base head_
> variable, I don't know how to access them. It woul also be nice to be
> able to implement operator[] as a constexpr to be able to index
> the vector like v[0] and so on, but I think it's not possible.
> Anyway, I think the syntax to expand variables (first example) should
> be legal because doing what I'm doing in the second example is
> unnecessarily complicated.
>
If I didn't get it wrong, what you want is tuple class. If so have a
look at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2242.pdf
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


|