Merge pull request #88 from trebconnell/fixmaybenull

Fix issue #49
This commit is contained in:
Neil MacIntosh 2015-09-28 18:54:31 -07:00
commit 065f4880c3
2 changed files with 2 additions and 4 deletions

View File

@ -223,12 +223,12 @@ public:
template <typename U, typename Dummy = std::enable_if_t<std::is_convertible<U, T>::value>> template <typename U, typename Dummy = std::enable_if_t<std::is_convertible<U, T>::value>>
maybe_null_dbg(const maybe_null_dbg<U> &other) : ptr_(other.get()), tested_(false) {} maybe_null_dbg(const maybe_null_dbg<U> &other) : ptr_(other.ptr_), tested_(false) {}
template <typename U, typename Dummy = std::enable_if_t<std::is_convertible<U, T>::value>> template <typename U, typename Dummy = std::enable_if_t<std::is_convertible<U, T>::value>>
maybe_null_dbg& operator=(const maybe_null_dbg<U> &other) maybe_null_dbg& operator=(const maybe_null_dbg<U> &other)
{ {
ptr_ = other.get(); ptr_ = other.ptr_;
tested_ = false; tested_ = false;
return *this; return *this;
} }

View File

@ -289,9 +289,7 @@ SUITE(MaybeNullTests)
mnBase_dbg2 = nnBase; // maybe_null_dbg<T> = not_null<T> mnBase_dbg2 = nnBase; // maybe_null_dbg<T> = not_null<T>
maybe_null_dbg<MyDerived*> mnDerived_dbg(&derived); maybe_null_dbg<MyDerived*> mnDerived_dbg(&derived);
CHECK(mnDerived_dbg.present());
mnBase_dbg2 = mnDerived_dbg; // maybe_null_dbg<T> = maybe_null_dbg<U> mnBase_dbg2 = mnDerived_dbg; // maybe_null_dbg<T> = maybe_null_dbg<U>
mnBase_dbg1 = &derived; // maybe_null_dbg<T> = U; mnBase_dbg1 = &derived; // maybe_null_dbg<T> = U;
mnBase_dbg1 = nnDerived; // maybe_null_dbg<T> = not_null<U> mnBase_dbg1 = nnDerived; // maybe_null_dbg<T> = not_null<U>