Boost logo

Boost :

Subject: Re: [boost] [core] Breaking change to boost::ref in 1.56
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2014-07-14 05:42:11


On Monday 14 July 2014 12:13:44 Peter Dimov wrote:
> Andrey Semashev wrote:
> > Why would you want r2? I mean, in what case would you intentionally write
> > code to employ recursive references?
>
> You don't write code to "employ recursive references". You write code that
> applies ref to an object of type T and stores the result in
> reference_wrapper<T>.

Would you expect this code to work:

  struct my_class
  {
    void bar();
  };

  struct my_class_const
  {
    void bar() const;
  };

  template< typename T >
  void foo(T const& t)
  {
    typedef typename boost::unwrap_reference<T>::type class_type;
    boost::bind(&class_type::bar, boost::ref(t))();
  }

  foo(my_class_const());
  my_class x;
  foo(boost::ref(x));


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