Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/GSL.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKern Handa <kern.handa@gmail.com>2015-09-28 10:35:18 +0300
committerKern Handa <kern.handa@gmail.com>2015-09-28 10:35:18 +0300
commit783eaabf9d7b40403540f2164fb096c3150d4c94 (patch)
tree23b3a50f50c33328c0b0784a3a5dce9de0e24fb8 /tests/notnull_tests.cpp
parentbad8545eeec2e00dc2edd73318b72ad7b97af20e (diff)
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.
Diffstat (limited to 'tests/notnull_tests.cpp')
-rw-r--r--tests/notnull_tests.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/notnull_tests.cpp b/tests/notnull_tests.cpp
index 7232840..46011b6 100644
--- a/tests/notnull_tests.cpp
+++ b/tests/notnull_tests.cpp
@@ -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