Title
[fund.ts.v2] std::hash<std::experimental::shared_ptr<T>> does not work for arrays
Status
open
Section
[memory.smartptr.shared]
Submitter
Tim Song

Created on 2015-12-13.00:00:00 last changed 90 months ago

Messages

Date: 2015-12-20.06:53:36

Proposed resolution:

This wording is relative to N4562.

  1. Insert a new subclause after [memory.smartptr.shared.cast]:

    [Note for the editor: The synopses in [header.memory.synop] and [memory.smartptr.shared] should be updated to refer to the new subclause rather than C++14 §20.8.2.7]

    ?.?.?.? shared_ptr hash support [memory.smartptr.shared.hash]

    template <class T> struct hash<experimental::shared_ptr<T>>;
    

    -1- The template specialization shall meet the requirements of class template hash (C++14 §20.9.12). For an object p of type experimental::shared_ptr<T>, hash<experimental::shared_ptr<T>>()(p) shall evaluate to the same value as hash<typename experimental::shared_ptr<T>::element_type*>()(p.get()).

Date: 2015-12-13.00:00:00

Addresses: fund.ts.v2

The library fundamentals TS does not provide a separate specification for std::hash<std::experimental::shared_ptr<T>>, deferring to the C++14 specification in §20.8.2.7/3:

template <class T> struct hash<shared_ptr<T> >;

-3- The template specialization shall meet the requirements of class template hash (20.9.13). For an object p of type shared_ptr<T>, hash<shared_ptr<T> >()(p) shall evaluate to the same value as hash<T*>()(p.get()).

That specification doesn't work if T is an array type (U[N] or U[]), as in this case get() returns U*, which cannot be hashed by std::hash<T*>.

History
Date User Action Args
2017-07-30 20:10:41adminsetstatus: wp -> open
2016-06-28 12:52:37adminsetstatus: ready -> wp
2016-03-07 04:46:57adminsetstatus: new -> ready
2015-12-19 15:37:12adminsetmessages: + msg7664
2015-12-13 00:00:00admincreate