diff --git a/src/lib/opaque-holder.hpp b/src/lib/opaque-holder.hpp index 1a09fc057..ab637f082 100644 --- a/src/lib/opaque-holder.hpp +++ b/src/lib/opaque-holder.hpp @@ -35,7 +35,7 @@ ** interface, the inner container keeps track of the actual type by means ** of a vtable. OpaqueHolder can be empty; but re-accessing the concrete ** object requires knowledge of the actual type, similar to boost::any - ** (but the latter uses heap storage). + ** (but contrary to OpaqueHolder the latter uses heap storage). ** ** Using this approach is bound to specific stipulations regarding the ** properties of the contained object and the kind of access needed. @@ -63,7 +63,6 @@ namespace lib { using lumiera::error::LUMIERA_ERROR_WRONG_TYPE; using util::isSameObject; - using util::AccessCasted; using util::unConst; @@ -202,6 +201,9 @@ namespace lib { + + /* === internal interface for managing the storage === */ + Buffer& buff() { @@ -213,6 +215,7 @@ namespace lib { return *reinterpret_cast (&storage_); } + void killBuffer() { buff().~Buffer(); @@ -233,7 +236,8 @@ namespace lib { { ref.buff().clone (storage_); } - + + public: ~OpaqueHolder() @@ -334,13 +338,13 @@ namespace lib { return actual->get(); // second try: maybe we can perform a - // dynamic upcast or direct conversion on the - // concrete target object. But we need to exclude a + // dynamic downcast or direct conversion to the + // actual target type. But we need to exclude a // brute force static cast (which might slice or reinterpret) if (!util::use_static_downcast::value) { BA* asBase = &(buff().get()); - SUB* content = AccessCasted::access (asBase); + SUB* content = util::AccessCasted::access (asBase); if (content) return *content; } diff --git a/tests/40components.tests b/tests/40components.tests index 109611c46..06cfc0073 100644 --- a/tests/40components.tests +++ b/tests/40components.tests @@ -272,6 +272,11 @@ END TEST "inline type erasure" OpaqueHolder_test <()); list.push_back (DD<7>()); return list; - } + } //note: copy static void