From: Yuval Ronen (ronen_yuval_at_[hidden])
Date: 2006-03-21 08:23:00
In the tuples library there is a function that creates a tuple with auto
deduction of types - make_tuple(), and there's also a function that
creates a tuple with reference of auto deduction of types - tie(), but
there's no function that does the same with const reference.
I found that such a function is useful when I have a simple struct with
simple members, and I want comparision operators to it. Instead of
writing these operators myself, I'd like to use tuples' code that does
it. To ease this task (IOW, to save me specifying the tuple type
explicitly) a const_tie would be most useful.
my code would then look like:
#define MY_STRUCT_AS_TUPLE(obj) const_tie(obj.x, obj.y, obj.z)
bool operator<(const MyStruct &lhs, const MyStruct &rhs)
return MY_STRUCT_AS_TUPLE(lhs) < MY_STRUCT_AS_TUPLE(rhs);
which is the best I can think of (with typeof I could also turn the
macro to a template function).
I know I can accomplish the same with make_tuple() and cref(), but this
way I can avoid the repetitive cref() calls.
Can this be added?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk