Title
shared_ptr of function type
Status
c++20
Section
[util.smartptr.shared]
Submitter
Agustín K-ballo Bergé

Created on 2017-09-13.00:00:00 last changed 46 months ago

Messages

Date: 2020-02-14.10:54:21

Proposed resolution:

This wording is relative to N4849.

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

    […]

    -2- Specializations of shared_ptr shall be Cpp17CopyConstructible, Cpp17CopyAssignable, and Cpp17LessThanComparable, 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. [Note: T may be a function type. -- end note]

    […]

Date: 2020-02-14.10:54:21

[ 2020-02 Friday AM discussion in Prague. ]

Marshall provides updated wording; status to Immediate

Date: 2020-02-15.00:00:00

[ 2020-02-13; Prague ]

LWG would prefer to make the new constraint a Mandates-like thing.

Original resolution [SUPERSEDED]:

This wording is relative to N4849.

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

    […]

    -2- Specializations of shared_ptr shall be Cpp17CopyConstructible, Cpp17CopyAssignable, and Cpp17LessThanComparable, 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. The program is ill-formed unless T* is an object pointer type or a function pointer type.

    […]

Date: 2020-02-13.21:50:15

[ 2017-11 Albuquerque Wednesday night issues processing ]

Priority set to 3

Previous resolution [SUPERSEDED]:

This wording is relative to N4687.

  1. Edit [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.

    […]

Date: 2017-09-13.00:00:00

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.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2020-02-24 16:02:59adminsetstatus: immediate -> wp
2020-02-14 10:54:21adminsetmessages: + msg11110
2020-02-14 10:54:21adminsetstatus: new -> immediate
2020-02-13 21:50:15adminsetmessages: + msg11088
2017-11-09 15:13:04adminsetmessages: + msg9519
2017-09-13 19:21:17adminsetmessages: + msg9462
2017-09-13 00:00:00admincreate