Boost logo

Boost :

Subject: [boost] Boost.Bind and boost.ref propagation
From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2011-01-07 15:54:40


Why this code asserts?

struct foo
  typedef void result_type;
  template <typename T>
  void operator()(T obj) const
          typename boost::mpl::not_
            typename boost::is_same<typename
boost::unwrap_reference<T>::type, T>::type
          , typename boost::is_reference<T>::type

int main()
  int i = 0;
  boost::bind(::foo(), boost::ref(i))();

I would expect the T type to be boost::reference_wrapper<int>, but it
is actually int.
It is not int& as well.

How do I get to propagate the boost::reference_wrapper through boost.bind to a

I don't want to use T& for the parameter, because the algorithm accepts
objects-by-value correctly, but I would like to be able to use boost.bind
as I would call this algorithm with boost.ref for some data-types.

foo()(boost::ref(i)); // Calls with boost::reference_wrapper<int>

Thanks in advance,

Felipe Magno de Almeida

Boost list run by bdawes at, gregod at, cpdaniel at, john at