Boost logo

Boost :

From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2008-08-08 09:02:00


Frank Mori Hess wrote:
>> boost::shared_ptr<int> s;
>> {
>> int sockfd = socket(PF_INET,SOCK_STREAM,0);
>> if( sockfd!=-1 )
>> s.reset(&sockfd, boost::lambda::bind(close, * boost::lambda::_1));
>> }
>>
>> I've never really used lambda, but it compiles at least. By the way, is
>> there any documentation on the lambda headers (which ones to include to use
>> what)? I didn't see anything in the lambda docs.
>
> Err, nevermind. This will fail when sockfd goes out of scope.

boost::shared_ptr<void> s;
{
    int sockfd = socket(PF_INET, SOCK_STREAM, 0);
    if( sockfd != -1)
        s.reset(static_cast<void*>(sockfd), bind(close,
static_cast_<int>(_1)));
}


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