This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix libstdc++/36962


-- Jonathan,

if you have got two spare minutes, I'd like to understand in some better detail the logic in the new _S_create_from_up functions. Doesn't seem obvious to me, reading the standard, that we have to use reference_wrapper explicitly. In other terms, I'd like to understand why applying the below all the existing tests still work, or we need one more testcase, or something...

Thanks in advance!
Paolo.

///////////////
Index: shared_ptr.h
===================================================================
*** shared_ptr.h	(revision 140031)
--- shared_ptr.h	(working copy)
*************** namespace std
*** 394,402 ****
          _S_create_from_up(std::unique_ptr<_Tp, _Del>&& __r,
            typename std::enable_if<std::is_reference<_Del>::value>::type* = 0)
          {
!           typedef typename std::remove_reference<_Del>::type _Del1;
!           typedef std::reference_wrapper<_Del1> _Del2;
!           return new _Sp_counted_deleter<_Tp*, _Del2, std::allocator<_Tp>,
              _Lp>(__r.get(), std::ref(__r.get_deleter()));
          }
  
--- 394,400 ----
          _S_create_from_up(std::unique_ptr<_Tp, _Del>&& __r,
            typename std::enable_if<std::is_reference<_Del>::value>::type* = 0)
          {
!           return new _Sp_counted_deleter<_Tp*, _Del, std::allocator<_Tp>,
              _Lp>(__r.get(), std::ref(__r.get_deleter()));
          }
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]