Allow upcast in unique_ref assignment

This commit is contained in:
Sebastian Messmer 2015-06-28 17:40:16 +02:00
parent 6442512877
commit 0edf28402c

View File

@ -28,13 +28,18 @@ class unique_ref final {
public:
unique_ref(unique_ref&& from): _target(std::move(from._target)) {}
// TODO Test this dynamic-cast-allowing move constructor
// TODO Test this upcast-allowing move constructor
template<typename U> unique_ref(unique_ref<U>&& from): _target(std::move(from._target)) {}
unique_ref& operator=(unique_ref&& from) {
_target = std::move(from._target);
return *this;
}
// TODO Test this upcast-allowing assignment
template<typename U> unique_ref& operator=(unique_ref<U>&& from) {
_target = std::move(from._target);
return *this;
}
typename std::add_lvalue_reference<T>::type operator*() const& {
return *_target;