Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-09-04 08:51:33


From: "Alexander Nasonov" <alnsn_at_[hidden]>

> I still not quit understand the extract. I understand extraction of
value:
> any a = 0;
> int i = extract<int>(a); // copy created
>
> but I puzzled with extraction of references and pointers. May be its
better
> to rename to access?
> any a = 0;
> int & r = access<int &>(a); // direct access using reference

In Boost.Python, you can extract<T&>(o) if o contains a T lvalue.

> int * r = access<int *>(a); // direct access using pointer

I would be inclined to treat pointers like values in C++: you can extract
an int* if the variant contains an int*... unless you intend to use a NULL
pointer to mean, "not contained".

In any case I don't think two separate names are needed.

-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave_at_[hidden] * http://www.boost-consulting.com


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