Boost logo

Boost Users :

Subject: Re: [Boost-users] [bind][make_shared] compilation failure with ref arg
From: Peter Dimov (pdimov_at_[hidden])
Date: 2010-01-25 09:08:38


Jeff Flinn wrote:
> The last statement below fails to compile with boost 1.39.0 on MSVC 8.
> Am I doing anything obviously wrong? Any help is appreciated.

...

> boost::bind(&boost::make_shared<Y, int&>, boost::ref(i));

Under C++03 compilers, make_shared takes its arguments by const reference:

template<class T, class A1>
    shared_ptr<T> make_shared( A1 const & a1 );

MSVC doesn't like the A1=int& case because it forms the questionably valid
"int& const&".

boost::bind(
    &boost::make_shared<Y, boost::reference_wrapper<int> >,
    boost::ref(i) );

works though. This is what make_shared<Y>( ref(i) ) would instantiate.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net