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 "lib/util.hpp"
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace lib {
|
namespace lib {
|
||||||
|
|
@ -266,7 +267,8 @@ namespace lib {
|
||||||
explicit
|
explicit
|
||||||
Buff (SUB const& obj)
|
Buff (SUB const& obj)
|
||||||
{
|
{
|
||||||
REQUIRE (siz >= sizeof(SUB));
|
BOOST_STATIC_ASSERT (siz >= sizeof(SUB));
|
||||||
|
|
||||||
new(Buffer::ptr()) SUB (obj);
|
new(Buffer::ptr()) SUB (obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -613,6 +615,8 @@ namespace lib {
|
||||||
void
|
void
|
||||||
placeDefault()
|
placeDefault()
|
||||||
{
|
{
|
||||||
|
BOOST_STATIC_ASSERT (siz >= sizeof(DEFAULT));
|
||||||
|
|
||||||
new(&buf_) DEFAULT();
|
new(&buf_) DEFAULT();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -640,7 +644,8 @@ namespace lib {
|
||||||
destroy(); \
|
destroy(); \
|
||||||
try \
|
try \
|
||||||
{ \
|
{ \
|
||||||
REQUIRE (siz >= sizeof(TY)); \
|
BOOST_STATIC_ASSERT (siz >= sizeof(TY));\
|
||||||
|
\
|
||||||
return *new(&buf_) _CTOR_CALL_; \
|
return *new(&buf_) _CTOR_CALL_; \
|
||||||
} \
|
} \
|
||||||
catch (...) \
|
catch (...) \
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,7 @@
|
||||||
#include "lib/meta/duck-detector.hpp"
|
#include "lib/meta/duck-detector.hpp"
|
||||||
|
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/utility/enable_if.hpp>
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace lib {
|
namespace lib {
|
||||||
|
|
@ -384,7 +385,8 @@ namespace lib {
|
||||||
template<class IMP>
|
template<class IMP>
|
||||||
PolymorphicValue (IMP*)
|
PolymorphicValue (IMP*)
|
||||||
{
|
{
|
||||||
REQUIRE (siz >= sizeof(IMP));
|
BOOST_STATIC_ASSERT (siz >= sizeof(IMP));
|
||||||
|
|
||||||
new(&buf_) IMP();
|
new(&buf_) IMP();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,8 +103,10 @@ namespace mobject {
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum {
|
enum
|
||||||
SPEC_SIZ = mp::maxSize<
|
{ VTABLE = sizeof(size_t)
|
||||||
|
, SPEC_SIZ = VTABLE
|
||||||
|
+ mp::maxSize<
|
||||||
mp::Types< PID, lumiera_uid, uint>::List>::value
|
mp::Types< PID, lumiera_uid, uint>::List>::value
|
||||||
};
|
};
|
||||||
typedef lib::OpaqueHolder<TargetSpec, SPEC_SIZ> SpecBuff;
|
typedef lib::OpaqueHolder<TargetSpec, SPEC_SIZ> SpecBuff;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue