Boost logo

Boost :

From: Pavel Chikulaev (pavel.chikulaev_at_[hidden])
Date: 2005-06-27 07:09:27


"Roman Yakovenko" <roman.yakovenko_at_[hidden]> wrote in message
news:BC29F2A417B44F44BD3AA1AD9868CEDC07F9C6_at_ilexchange.adrembi.com...
> If you try to solve code readability then adding simple enum, even unnamed,
> solves the problem
>
> enum { name, year };
> s.get<name>()
I don't like this, because of the following:
tuple<double, double> s;
enum { width, height };
tuple<double, double> p;
enum { apples_weight, bananas_weight };
s.get<width>() = 1.04;
double apples_price = s.get<apples_weight>()* 5; (mistake: there should be p
instead of s)

> If you try to solve an other problem, please describe the problem first.
Yeah, sorry, I forgot to mention that explicitly. No just this one.

> And second this has been already discussed on the list.
Sorry again :)
> One of the objections
> was the use case where you have same type occurs more then once in tuple.

> tagged_tuple<std::string, name_t, std::string, name_t > s;
>
> s.get<name_t>() - is this operation defined and what it's result
With current implemention, such object can not be created...

My rationale for it:
tag is like a name, but it to be applied in compile time, and as in case of
objects there cannot be two objects(two tuple elements) with the same name.

--
Pavel Chikulaev 

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk