3018. shared_ptr of function type

Section: 23.11.3 [util.smartptr.shared] Status: New Submitter: Agustín K-ballo Bergé Opened: 2017-09-13 Last modified: 2017-11-09

Priority: 3

View other active issues in [util.smartptr.shared].

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

View all issues with New status.

Discussion:

shared_ptr has been designed to support use cases where it owns a pointer to function, and whose deleter does something with it. This can be used, for example, to keep a dynamic library loaded for as long as their exported functions are referenced.

Implementations have overlooked that the T in shared_ptr<T> can be a function type. It isn't immediately obvious from the standard, and it's not possible to tell from the wording that this is intentional.

[2017-11 Albuquerque Wednesday night issues processing]

Priority set to 3

Proposed resolution:

This wording is relative to N4687.

  1. Edit 23.11.3 [util.smartptr.shared] as indicated:

    […]

    -2- Specializations of shared_ptr shall be CopyConstructible, CopyAssignable, and LessThanComparable, allowing their use in standard containers. Specializations of shared_ptr shall be contextually convertible to bool, allowing their use in boolean expressions and declarations in conditions. The template parameter T of shared_ptr may be an incomplete type.

    -?- The template parameter T of shared_ptr may be an incomplete type. T* shall be an object pointer type or a function pointer type.

    […]