Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2005-04-26 17:34:53


On 04/26/2005 05:22 PM, Giovanni P. Deretta wrote:
[snip]
>> Agreed, but the indexed get works just as well when the argument is
>> an enumerator instead of a literal unsigned, and when it's an
>> enumerator, the meaning is clearer:
>>
>> t.get<0>();
>> t.get<1>();
>>
>> is obviously not as clear as:
>>
>> t.get<first_field>();
>> t.get<second_field>();
>>
>> [snip]
>
>
> Well, i actually believe the first to be clearer. It is a matter of
> taste though.

I hope you didn't misinterpret what I was saying. I used 'first_field'
and 'second_field' to emphasize the use of names instead of numbers.
In a real application, the names would, of course, indicate the type of
relationship. E.g. in an employee record, the enumerators would be:

      enum
    employee_fields
    { name
    , salary
    , title
    };

which, I hope you'll agree would make the meaning of:

    a_employee.get<name>();
    a_employee.get<salary>();

clearer than:

    a_employee.get<0>();
    a_employee.get<1>();


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