perfer STATIC_ASSERT to check for suitable placement-New buffer size
Still incomplete, but already this small change detected an error in the output-designation. Cough.
This commit is contained in:
parent
cd3c633fc0
commit
dbb63ffc08
3 changed files with 21 additions and 12 deletions
|
|
@ -73,6 +73,7 @@
|
|||
#include "lib/util.hpp"
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
|
||||
namespace lib {
|
||||
|
|
@ -266,7 +267,8 @@ namespace lib {
|
|||
explicit
|
||||
Buff (SUB const& obj)
|
||||
{
|
||||
REQUIRE (siz >= sizeof(SUB));
|
||||
BOOST_STATIC_ASSERT (siz >= sizeof(SUB));
|
||||
|
||||
new(Buffer::ptr()) SUB (obj);
|
||||
}
|
||||
|
||||
|
|
@ -613,6 +615,8 @@ namespace lib {
|
|||
void
|
||||
placeDefault()
|
||||
{
|
||||
BOOST_STATIC_ASSERT (siz >= sizeof(DEFAULT));
|
||||
|
||||
new(&buf_) DEFAULT();
|
||||
}
|
||||
|
||||
|
|
@ -640,13 +644,14 @@ namespace lib {
|
|||
destroy(); \
|
||||
try \
|
||||
{ \
|
||||
REQUIRE (siz >= sizeof(TY)); \
|
||||
return *new(&buf_) _CTOR_CALL_; \
|
||||
} \
|
||||
catch (...) \
|
||||
{ \
|
||||
placeDefault(); \
|
||||
throw; \
|
||||
BOOST_STATIC_ASSERT (siz >= sizeof(TY));\
|
||||
\
|
||||
return *new(&buf_) _CTOR_CALL_; \
|
||||
} \
|
||||
catch (...) \
|
||||
{ \
|
||||
placeDefault(); \
|
||||
throw; \
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@
|
|||
#include "lib/meta/duck-detector.hpp"
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
|
||||
namespace lib {
|
||||
|
|
@ -384,7 +385,8 @@ namespace lib {
|
|||
template<class IMP>
|
||||
PolymorphicValue (IMP*)
|
||||
{
|
||||
REQUIRE (siz >= sizeof(IMP));
|
||||
BOOST_STATIC_ASSERT (siz >= sizeof(IMP));
|
||||
|
||||
new(&buf_) IMP();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,10 +103,12 @@ namespace mobject {
|
|||
};
|
||||
|
||||
private:
|
||||
enum {
|
||||
SPEC_SIZ = mp::maxSize<
|
||||
enum
|
||||
{ VTABLE = sizeof(size_t)
|
||||
, SPEC_SIZ = VTABLE
|
||||
+ mp::maxSize<
|
||||
mp::Types< PID, lumiera_uid, uint>::List>::value
|
||||
};
|
||||
};
|
||||
typedef lib::OpaqueHolder<TargetSpec, SPEC_SIZ> SpecBuff;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue