diff --git a/src/lib/scoped-collection.hpp b/src/lib/scoped-collection.hpp index 0ff2d37ef..729c88495 100644 --- a/src/lib/scoped-collection.hpp +++ b/src/lib/scoped-collection.hpp @@ -132,12 +132,14 @@ namespace lib { -#define TYPE_SANITY_CHECK \ - BOOST_STATIC_ASSERT ((boost::is_base_of::value || boost::is_same::value)) +#define TYPE_AND_STORAGE_SANITY_CHECK \ + BOOST_STATIC_ASSERT (((boost::is_same::value \ + ||boost::is_base_of::value)\ + && sizeof(TY) <= siz)) /** Abbreviation for placement new */ #define EMBEDDED_ELEMENT_CTOR(_CTOR_CALL_) \ - TYPE_SANITY_CHECK; \ + TYPE_AND_STORAGE_SANITY_CHECK; \ return *new(&buf_) _CTOR_CALL_; \ @@ -205,8 +207,8 @@ namespace lib { { EMBEDDED_ELEMENT_CTOR ( TY(a1,a2,a3,a4,a5) ) } +#undef TYPE_AND_STORAGE_SANITY_CHECK #undef EMBEDDED_ELEMENT_CTOR -#undef TYPE_SANITY_CHECK }; diff --git a/tests/lib/scoped-collection-test.cpp b/tests/lib/scoped-collection-test.cpp index f112e79da..c2408d7dc 100644 --- a/tests/lib/scoped-collection-test.cpp +++ b/tests/lib/scoped-collection-test.cpp @@ -78,7 +78,7 @@ namespace test{ inline uint sum (uint n) { - return n*(n+1) / 2; + return n*(n+1) / 2; } }//(End) subversive test data @@ -89,7 +89,7 @@ namespace test{ using util::isnil; using lumiera::error::LUMIERA_ERROR_ITER_EXHAUST; - typedef ScopedCollection CollD; + typedef ScopedCollection CollD; /********************************************************************