Boost logo

Boost Users :

From: gast128 (gast128_at_[hidden])
Date: 2007-07-26 04:33:04


Joel de Guzman <joel <at> boost-consulting.com> writes:

>
> > - bind expression with tuple becomes a nightmare
>
> Why? Ah access to the members?

Yes. boost::bind(&tp::get<1>, _1) does not work (something to do with bind's
difficulties with overloads and return types?). This can be overcome by using
Karlsson's tuple_select.

>
> > - default initialising of its members is m_member() (while sometimes we
> > reserve -1 for uninitialised)
>
> Dunno what you mean. Please elaborate.

Oh this simple. Let says one has a tuple with handles boost::tuple<HANDLE>; In
Win32 an INVALID_HANDLE_VALUE is defined as -1. So if one writes:

boost::tuple<HANDLE> tp;

If at the moment of definition, the actual values are not known, it should be
default intialised with invalid handles (-1) and not with zeros, which can
represent valid file handles. This can of course be overcome with an extra
intialiser e.g.

const boost::tuple<HANDLE> g_tpInvalid(INVALID_HANDLE_VALUE);

and then always write:

boost::tuple<HANDLE> tp = tpInvalid;

but this is an extra step. Using a structure one could handle that in the
defualt constructor.

Wkr,
me


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