STATIC_ASSERT to verify guessed size

... and we indeed had an error: vector<bool>
is way larger than normal vectors!
This commit is contained in:
Fischlurch 2011-12-28 05:44:57 +01:00
parent 962c789a05
commit cd3c633fc0
2 changed files with 17 additions and 9 deletions

View file

@ -48,6 +48,7 @@
#include "lib/error.hpp"
#include "lib/format-string.hpp"
#include <boost/static_assert.hpp>
#include <boost/format.hpp>
#include <iostream>
@ -66,6 +67,8 @@ namespace util {
/** */
_Fmt::_Fmt (string formatString)
{
BOOST_STATIC_ASSERT (sizeof(boost::format) <= FORMATTER_SIZE);
UNIMPLEMENTED ("create the embedded boost::format object");
}

View file

@ -64,6 +64,7 @@ namespace meta {
//-------------------------------------mimicked-definitions--
typedef std::vector<size_t> Vector;
typedef std::vector<bool> BVector;
struct CompatAllocator
: std::allocator<char>
@ -102,6 +103,8 @@ namespace meta {
char * _M_out_end;
Locale _M_buf_locale;
virtual ~BasicStringbuf() { }
};
struct BasicAltstringbuf
@ -115,12 +118,12 @@ namespace meta {
struct BoostFormat
{
Vector items_;
Vector bound_;
int style_;
int cur_arg_;
int num_args_;
bool dumped_;
Vector items_;
BVector bound_; // note: differs in size
int style_;
int cur_arg_;
int num_args_;
mutable bool dumped_;
std::string prefix_;
unsigned char exceptions;
BasicAltstringbuf buf_;
@ -131,9 +134,11 @@ namespace meta {
public:/* ===== Interface: size constants ===== */
enum {
STRING = sizeof(std::string)
, VECTOR = sizeof(std::vector<size_t>)
enum { ALIGNMENT = sizeof(size_t)
, STRING = sizeof(std::string)
, VECTOR = sizeof(Vector)
, BVECTOR = sizeof(BVector)
, BOOST_FORMAT = sizeof(BoostFormat)
};