Boost logo

Boost Users :

From: Hansi (hansipet_at_[hidden])
Date: 2008-05-21 04:55:53


Okay this version is working.
The problem is that I have a fixed defined tuple and for that the tuple
is not defined inside a template struct.
for that I get the error that typename can be used only inside a
template declaration...
I have something similar to the following declaration:

struct Test
{
     typedef boost::tuple<int,char> tuple_t;
     tuple_t tup;
     enum Members { NAME, VALUE };

     typename boost::tuples::element<NAME, tuple_t>::type
     name()
     { return boost::get<NAME>(tup); }

     template < Members mem >
     typename boost::tuples::element<mem, tuple_t>::type
     member()
     { return boost::get<mem>(tup); }
};

Maik Beckmann schrieb:
> Am Mittwoch 21 Mai 2008 08:42:34 schrieb Hansi:
>> Noah Roberts schrieb:
>>> #include <boost/tuple/tuple.hpp>
>>> #include <string>
>>> #include <iostream>
>>>
>>> template < typename T1, typename T2 >
>>> struct Test
>>> {
>>> typedef boost::tuple<T1,T2> tuple_t;
>>> tuple_t tup;
>>>
>>> enum Members { NAME, VALUE };
>>>
>>> typename boost::tuples::element<NAME, tuple_t>::type name() { return
>>> tup.get<NAME>(); }
>
> This code is almost correct :o) . Try the attached File.
>
>> this version doesn't work with my compiler (msvc8.0). I get the error:
>>
>> error C2899:typename cannot be used outside a template declaration
>>
>> But this would be the preferred version for me. Have you an idea how I
>> can solve this?
>
>
> Best,
> -- Maik
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net