Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-02-19 13:44:18


"Ed Brey" <brey_at_[hidden]> writes:

> Eric Friedman wrote:
>>
>>> The area would be helped by renaming extract to access.
>> I tend to agree the name is confusing. So shall we call it
>> boost::access<>? Input?
>
> Dave A.'s comment that access is confusing because it is a noun and a
> verb is well taken. Of course, the same can be said for
> extract. ;-)

But not as plausibly, IMO.

> I agree the issues goes beyond member vs. free. By the way, what is
> the motivation for using free over a member function?

For one thing, the lovely template keyword:

    var.template extract<T>();
        ^^^^^^^^^

For another, syntax compatibility with Boost.Python.

Incidentally, no Boost.Python user has reported confusion about
extract, and they tend to be slightly more naive than the average
Boost user.

> Part of my motivation is because this following usage came to mind
> as a solution to the extract confusion:
>
> T value = var.content<T>(); // Throws on type mismatch T& ref =
> var.content<T&>(); // Throws on type mismatch T* ptr =
> var.content<T*>(); // Returns null on type mismatch

All missing "template" in a dependent context.

-- 
Dave Abrahams
Boost Consulting
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