Boost logo

Boost :

From: John Max Skaller (skaller_at_[hidden])
Date: 2001-06-19 17:18:15


Gary Powell wrote:

> [John Max Skaller]
> 2. Why the limit of 10 elements? Why not 20? Is the limit documented?
> [Gary]
> Laziness. :>,

        :-)

> At some point there will be a limit. What is reasonable? Do you even have a
> use for 20?

        No. But I regularly use tuples of up to 6 or 7 elements,
which is too close to 10 for comfort, IMHO.

> [John Max Skaller]
> 3. How does one get a pointer to member? [ptm]

> [Gary]
> use bind? But then that assumes you want to hold an element as well.
>
> How about this:
>
> tuple<ResultType (ObjectType::*)()> foo(ResultType (ObjectType::* const &f)
> () )
> {
> return tuple<ResultType (ObjectType::*)()>(f);
> }
>
> Here a function foo, takes a member function f, from class ObjectType,
> returning a ResultType, which takes no arguments.) And the function foo
> returns a tuple holding that pointer to member.
>
> And did you really want to know this, or just want us to put it in the docs?

        Urgle :-) I don't understand. Here is a tuple:

        tuple<int, float>

and I want to get a pointer to member 'float' ptm so that

        tuple<int, float> x;
        float i = x.*ptm;

I want something equivalent to

        get_ptm<N, T>()

which is a pointer to the n'th member of the tuple type T,
so I can write:

        float (tuple<int,float>::*ptm) = get_ptm<2,tuple<int,float> >();

If the tuple had named members, I could write:

        &tuple<int,float>::mem_2 // did I get the syntax right?

but it doesn't have named members, so you have to provide
a function which does the equivalent job.

-- 
John (Max) Skaller, mailto:skaller_at_[hidden]
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net

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