Created on 2014-06-12.00:00:00 last changed 100 months ago
Proposed resolution:
This wording is relative to N3936.
Change [util.smartptr.shared.const] around p33 as indicated:
template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r);-?- Remark: This constructor shall not participate in overload resolution unless unique_ptr<Y, D>::pointer is convertible to T*.
-33- Effects: Equivalent to shared_ptr(r.release(), r.get_deleter()) when D is not a reference type, otherwise shared_ptr(r.release(), ref(r.get_deleter())).
[ 2014-06-16 Rapperswil ]
Move to Ready
Consider the following code:
#include <iostream>
#include <memory>
#include <string>
using namespace std;
void meow(const shared_ptr<int>& sp) {
cout << "int: " << *sp << endl;
}
void meow(const shared_ptr<string>& sp) {
cout << "string: " << *sp << endl;
}
int main() {
meow(make_unique<int>(1729));
meow(make_unique<string>("kitty"));
}
This fails to compile due to ambiguous overload resolution, but we can easily make this work. (Note: shared_ptr's constructor from auto_ptr is also affected, but I believe that it's time to remove auto_ptr completely.)
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2017-07-30 20:15:43 | admin | set | status: wp -> c++17 |
| 2014-11-08 19:44:42 | admin | set | status: voting -> wp |
| 2014-11-04 10:26:50 | admin | set | status: ready -> voting |
| 2014-06-16 23:41:12 | admin | set | messages: + msg7052 |
| 2014-06-16 23:41:12 | admin | set | status: new -> ready |
| 2014-06-14 17:11:17 | admin | set | messages: + msg7029 |
| 2014-06-12 00:00:00 | admin | create | |