no struct init

The C struct initializer is not standard C++.
GCC and Clang handle this (at least in some versions) but some
compilers might not.
This commit is contained in:
Christopher Dunn 2015-03-03 01:22:13 -06:00
parent 0c91927da2
commit 24f544996f

View File

@ -195,19 +195,23 @@ void Value::CommentInfo::setComment(const char* text, size_t len) {
Value::CZString::CZString(ArrayIndex index) : cstr_(0), index_(index) {} Value::CZString::CZString(ArrayIndex index) : cstr_(0), index_(index) {}
Value::CZString::CZString(char const* str, unsigned length, DuplicationPolicy allocate) Value::CZString::CZString(char const* str, unsigned length, DuplicationPolicy allocate)
: cstr_(allocate == duplicate ? duplicateStringValue(str) : str), : cstr_(allocate == duplicate ? duplicateStringValue(str) : str)
storage_({allocate, length}) {
{} storage_.policy_ = allocate;
storage_.length_ = length;
}
Value::CZString::CZString(const CZString& other) Value::CZString::CZString(const CZString& other)
: cstr_(other.storage_.policy_ != noDuplication && other.cstr_ != 0 : cstr_(other.storage_.policy_ != noDuplication && other.cstr_ != 0
? duplicateStringValue(other.cstr_) ? duplicateStringValue(other.cstr_)
: other.cstr_), : other.cstr_)
storage_({(other.cstr_ {
storage_.policy_ = (other.cstr_
? (other.storage_.policy_ == noDuplication ? (other.storage_.policy_ == noDuplication
? noDuplication : duplicate) ? noDuplication : duplicate)
: other.storage_.policy_), other.storage_.length_}) : other.storage_.policy_);
{} storage_.length_ = other.storage_.length_;
}
Value::CZString::~CZString() { Value::CZString::~CZString() {
if (cstr_ && storage_.policy_ == duplicate) if (cstr_ && storage_.policy_ == duplicate)