Add various copy assignment operators to not_null and maybe_null_*.

Also removed unused constant member variable that seemed to be there
to prevent maybe_null_* being used with anything other than a pointer,
which is being taken care of with a static_assert now.
This commit is contained in:
Kern Handa
2015-09-28 07:35:18 +00:00
parent bad8545eee
commit 783eaabf9d
3 changed files with 138 additions and 40 deletions
+9 -2
View File
@@ -65,12 +65,19 @@ SUITE(NotNullTests)
TEST(TestNotNullCasting)
{
MyDerived derived;
MyBase base;
MyDerived derived;
Unrelated unrelated;
not_null<Unrelated*> u = &unrelated;
not_null<MyDerived*> p = &derived;
not_null<MyBase*> q = p;
not_null<MyBase*> q = &base;
q = p; // allowed with heterogeneous copy ctor
CHECK(q == p);
#ifdef CONFIRM_COMPILATION_ERRORS
q = u; // no viable conversion possible between MyBase* and Unrelated*
p = q; // not possible to implicitly convert MyBase* to MyDerived*
not_null<Unrelated*> r = p;
not_null<Unrelated*> s = reinterpret_cast<Unrelated*>(p);
#endif