2083. const-qualification on weak_ptr::owner_before

Section: 23.11.4 [util.smartptr.weak], 23.11.4.5 [util.smartptr.weak.obs] Status: C++14 Submitter: Ai Azuma Opened: 2011-09-06 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [util.smartptr.weak].

View all issues with C++14 status.

Discussion:

Is there any reason why weak_ptr::owner_before member function templates are not const-qualified?

Daniel Krügler:

I don't think so. To the contrary, without these to be const member function templates, the semantics of the specializations owner_less<weak_ptr<T>> and owner_less<shared_ptr<T>> described in 23.11.5 [util.smartptr.ownerless] is unclear.

It is amusing to note that this miss has remain undetected from the accepted paper n2637 on. For the suggested wording changes see below.

[2012, Kona]

Move to Ready.

[2012, Portland: applied to WP]

Proposed resolution:

This wording is relative to the FDIS.

  1. Change the class template weak_ptr synopsis in 23.11.4 [util.smartptr.weak] as indicated:

    namespace std {
      template<class T> class weak_ptr {
      public:
        typedef T element_type;
        […]
        template<class U> bool owner_before(shared_ptr<U> const& b) const;
        template<class U> bool owner_before(weak_ptr<U> const& b) const;
      };
      […]
    }
    
  2. Change the prototypes in 23.11.4.5 [util.smartptr.weak.obs] before p6 as indicated:

    template<class U> bool owner_before(shared_ptr<U> const& b) const;
    template<class U> bool owner_before(weak_ptr<U> const& b) const;