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:
parent
962c789a05
commit
cd3c633fc0
2 changed files with 17 additions and 9 deletions
|
|
@ -48,6 +48,7 @@
|
||||||
#include "lib/error.hpp"
|
#include "lib/error.hpp"
|
||||||
#include "lib/format-string.hpp"
|
#include "lib/format-string.hpp"
|
||||||
|
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
@ -66,6 +67,8 @@ namespace util {
|
||||||
/** */
|
/** */
|
||||||
_Fmt::_Fmt (string formatString)
|
_Fmt::_Fmt (string formatString)
|
||||||
{
|
{
|
||||||
|
BOOST_STATIC_ASSERT (sizeof(boost::format) <= FORMATTER_SIZE);
|
||||||
|
|
||||||
UNIMPLEMENTED ("create the embedded boost::format object");
|
UNIMPLEMENTED ("create the embedded boost::format object");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ namespace meta {
|
||||||
//-------------------------------------mimicked-definitions--
|
//-------------------------------------mimicked-definitions--
|
||||||
|
|
||||||
typedef std::vector<size_t> Vector;
|
typedef std::vector<size_t> Vector;
|
||||||
|
typedef std::vector<bool> BVector;
|
||||||
|
|
||||||
struct CompatAllocator
|
struct CompatAllocator
|
||||||
: std::allocator<char>
|
: std::allocator<char>
|
||||||
|
|
@ -102,6 +103,8 @@ namespace meta {
|
||||||
char * _M_out_end;
|
char * _M_out_end;
|
||||||
|
|
||||||
Locale _M_buf_locale;
|
Locale _M_buf_locale;
|
||||||
|
|
||||||
|
virtual ~BasicStringbuf() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BasicAltstringbuf
|
struct BasicAltstringbuf
|
||||||
|
|
@ -116,11 +119,11 @@ namespace meta {
|
||||||
struct BoostFormat
|
struct BoostFormat
|
||||||
{
|
{
|
||||||
Vector items_;
|
Vector items_;
|
||||||
Vector bound_;
|
BVector bound_; // note: differs in size
|
||||||
int style_;
|
int style_;
|
||||||
int cur_arg_;
|
int cur_arg_;
|
||||||
int num_args_;
|
int num_args_;
|
||||||
bool dumped_;
|
mutable bool dumped_;
|
||||||
std::string prefix_;
|
std::string prefix_;
|
||||||
unsigned char exceptions;
|
unsigned char exceptions;
|
||||||
BasicAltstringbuf buf_;
|
BasicAltstringbuf buf_;
|
||||||
|
|
@ -131,9 +134,11 @@ namespace meta {
|
||||||
|
|
||||||
public:/* ===== Interface: size constants ===== */
|
public:/* ===== Interface: size constants ===== */
|
||||||
|
|
||||||
enum {
|
enum { ALIGNMENT = sizeof(size_t)
|
||||||
STRING = sizeof(std::string)
|
|
||||||
, VECTOR = sizeof(std::vector<size_t>)
|
, STRING = sizeof(std::string)
|
||||||
|
, VECTOR = sizeof(Vector)
|
||||||
|
, BVECTOR = sizeof(BVector)
|
||||||
|
|
||||||
, BOOST_FORMAT = sizeof(BoostFormat)
|
, BOOST_FORMAT = sizeof(BoostFormat)
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue