From b29566628e180ce100f9cbdb08d4ba56ab650a01 Mon Sep 17 00:00:00 2001 From: Treb Connell Date: Mon, 28 Sep 2015 18:26:35 -0700 Subject: [PATCH] Revert "Fix issue #49" This reverts commit a46d6fcf0d69a20f630cd590ba0867a1cf6a8cb4. --- include/gsl.h | 4 +- tests/maybenull_tests.cpp | 80 ++++++++++++++------------------------- 2 files changed, 31 insertions(+), 53 deletions(-) diff --git a/include/gsl.h b/include/gsl.h index a73db6b..1405993 100644 --- a/include/gsl.h +++ b/include/gsl.h @@ -223,12 +223,12 @@ public: template ::value>> - maybe_null_dbg(const maybe_null_dbg &other) : ptr_(other.ptr_), tested_(false) {} + maybe_null_dbg(const maybe_null_dbg &other) : ptr_(other.get()), tested_(false) {} template ::value>> maybe_null_dbg& operator=(const maybe_null_dbg &other) { - ptr_ = other.ptr_; + ptr_ = other.get(); tested_ = false; return *this; } diff --git a/tests/maybenull_tests.cpp b/tests/maybenull_tests.cpp index a889e52..d6b53f0 100644 --- a/tests/maybenull_tests.cpp +++ b/tests/maybenull_tests.cpp @@ -256,64 +256,42 @@ SUITE(MaybeNullTests) CHECK(p1.get() != nullptr); } - template - void TestMaybeNullAssignmentOpsHelper() - { - MyBase base; - MyDerived derived; - Unrelated unrelated; + TEST(TestMaybeNullAssignmentOps) + { + MyBase base; + MyDerived derived; + Unrelated unrelated; - not_null nnBase(&base); - not_null nnDerived(&derived); - not_null nnUnrelated(&unrelated); + not_null nnBase(&base); + not_null nnDerived(&derived); + not_null nnUnrelated(&unrelated); - maybe_null_type::type mnBase_ret1(&base), mnBase_ret2; - mnBase_ret2 = mnBase_ret1; // maybe_null_ret = maybe_null_ret - mnBase_ret2 = nnBase; // maybe_null_ret = not_null + maybe_null_ret mnBase_ret1(&base), mnBase_ret2; + mnBase_ret2 = mnBase_ret1; // maybe_null_ret = maybe_null_ret + mnBase_ret2 = nnBase; // maybe_null_ret = not_null - maybe_null_type::type mnDerived_ret(&derived); - mnBase_ret2 = mnDerived_ret; // maybe_null_ret = maybe_null_ret - mnBase_ret1 = &derived; // maybe_null_ret = U; - mnBase_ret1 = nnDerived; // maybe_null_ret = not_null + maybe_null_ret mnDerived_ret(&derived); + mnBase_ret2 = mnDerived_ret; // maybe_null_ret = maybe_null_ret + mnBase_ret1 = &derived; // maybe_null_ret = U; + mnBase_ret1 = nnDerived; // maybe_null_ret = not_null - maybe_null_type::type mnUnrelated_ret; - mnUnrelated_ret = &unrelated; // maybe_null_ret = T + maybe_null_ret mnUnrelated_ret; + mnUnrelated_ret = &unrelated; // maybe_null_ret = T - maybe_null_type::type mnBase_dbg1(&base), mnBase_dbg2; - mnBase_dbg2 = mnBase_dbg1; // maybe_null_dbg = maybe_null_dbg - mnBase_dbg2 = nnBase; // maybe_null_dbg = not_null + maybe_null_dbg mnBase_dbg1(&base), mnBase_dbg2; + mnBase_dbg2 = mnBase_dbg1; // maybe_null_dbg = maybe_null_dbg + mnBase_dbg2 = nnBase; // maybe_null_dbg = not_null - maybe_null_type::type mnDerived_dbg(&derived); - CHECK(mnDerived_dbg.present()); - mnBase_dbg2 = mnDerived_dbg; // maybe_null_dbg = maybe_null_dbg + maybe_null_dbg mnDerived_dbg(&derived); + CHECK(mnDerived_dbg.present()); + mnBase_dbg2 = mnDerived_dbg; // maybe_null_dbg = maybe_null_dbg + + mnBase_dbg1 = &derived; // maybe_null_dbg = U; + mnBase_dbg1 = nnDerived; // maybe_null_dbg = not_null - mnBase_dbg1 = &derived; // maybe_null_dbg = U; - mnBase_dbg1 = nnDerived; // maybe_null_dbg = not_null - - maybe_null_type::type mnUnrelated_dbg; - mnUnrelated_dbg = &unrelated; // maybe_null_dbg = T - } - - struct maybe_null_ret_type - { - template - using type = maybe_null_ret; - }; - struct maybe_null_dbg_type - { - template - using type = maybe_null_dbg; - }; - - TEST(TestMaybeNullRetAssignmentOps) - { - TestMaybeNullAssignmentOpsHelper(); - } - - TEST(TestMaybeNullDbgAssignmentOps) - { - TestMaybeNullAssignmentOpsHelper(); - } + maybe_null_dbg mnUnrelated_dbg; + mnUnrelated_dbg = &unrelated; // maybe_null_dbg = T + } } int main(int, const char *[])