activate the new test, some comments

This commit is contained in:
Fischlurch 2009-07-05 02:26:59 +02:00
parent 6e3bfb08e6
commit 4d1f45fc43
3 changed files with 19 additions and 10 deletions

View file

@ -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<const Buffer *> (&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<BA*,SUB*>::value)
{
BA* asBase = &(buff().get());
SUB* content = AccessCasted<SUB*>::access (asBase);
SUB* content = util::AccessCasted<SUB*>::access (asBase);
if (content)
return *content;
}

View file

@ -272,6 +272,11 @@ END
TEST "inline type erasure" OpaqueHolder_test <<END
out: 1
out: 3
out: 5
out: 7
out: sizeof\( .+ \) = .*[12468]{1,2}
return: 0
END

View file

@ -67,8 +67,8 @@ namespace test{
struct DD : Base
{
DD() : Base(ii) { }
~DD() { _checksum -= ii; }
};
~DD() { _checksum -= ii; } // doing the decrement here
}; // verifies the correct dtor is called
struct Special
@ -82,7 +82,7 @@ namespace test{
{ }
bool
isValid () const
isValid () const ///< custom boolean "validity" check
{
return myVal_ % 2;
}
@ -138,7 +138,7 @@ namespace test{
list.push_back (DD<5>());
list.push_back (DD<7>());
return list;
}
} //note: copy
static void