|
Boost : |
From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-06-24 17:46:01
Peter Dimov wrote:
> get_pointer is somewhat overloaded in the sense that mem_fn allows
> get_pointer to return anything usable in a get_pointer(x)->*f(...)
> experssion, i.e. it's not limited to raw pointers. I should
> have named it 'mem_fn_get_pointer.'
>
> I guess the right thing to do is to document 'get_pointer(px)' as returng
> the raw pointer contained in px on the smart pointer side, and make
> mem_fn_get_pointer forward to it on the mem_fn side. Comments?
If 'get_pointer' is going to become a free-standing equivalent of 'get'
member function, I would suggest to call it 'c_ptr' (never liked 'get' :),
e.g.
void foo(std::auto_ptr<something> thing) // or boost::shared_ptr, et al.
{
if (c_ptr(thing)) // #1
{
// ...
boost::scoped_array<char> a(new char[n]);
std::memcpy(c_ptr(a), src, n); // #2, etc.
}
}
That's what we have here at work.
Aleksey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk