Bug #2666059: cap buffer size to 126.
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@1001 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
a34780ce1e
commit
12a3a50e8e
1 changed files with 56 additions and 42 deletions
|
@ -74,6 +74,18 @@ class StoragePolicy
|
|||
#include <stdexcept>
|
||||
#include "flex_string_details.h"
|
||||
|
||||
namespace SmallStringOptImpl
|
||||
{
|
||||
// The threshold for SmallStringOpt cannot be greater than 126. See Loki bug #2666059 for more details:
|
||||
// https://sourceforge.net/tracker2/?func=detail&aid=2666059&group_id=29557&atid=396644
|
||||
template<int Expression> struct BufferSizeCannotBeGreaterThan126;
|
||||
template<> struct BufferSizeCannotBeGreaterThan126<true> { };
|
||||
|
||||
#define LOKI_FLEX_STRING_BUFFERSIZECANNOTBEGREATERTHAN126(expression) \
|
||||
{ SmallStringOptImpl::BufferSizeCannotBeGreaterThan126<((expression) != 0)> \
|
||||
bufferSizeCannotBeGreaterThan126; (void)bufferSizeCannotBeGreaterThan126; }
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class template SmallStringOpt
|
||||
// Builds the small string optimization over any other storage
|
||||
|
@ -131,8 +143,10 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
SmallStringOpt(const SmallStringOpt& s)
|
||||
SmallStringOpt(const SmallStringOpt& s)
|
||||
{
|
||||
LOKI_FLEX_STRING_BUFFERSIZECANNOTBEGREATERTHAN126(maxSmallString <= 126)
|
||||
|
||||
if (s.Small())
|
||||
{
|
||||
flex_string_details::pod_copy(
|
||||
|
|
Loading…
Reference in a new issue