String constructor for Array<>

This commit is contained in:
Pavel Kirienko
2015-05-03 13:29:53 +03:00
parent 5633cb8bdb
commit a439c62532
2 changed files with 24 additions and 0 deletions
@@ -667,6 +667,20 @@ public:
static_cast<unsigned>(RawValueType::MaxBitLen) * static_cast<unsigned>(MaxSize)
};
/**
* Default constructor zero-initializes the storage even if it consists of primitive types.
*/
Array() { }
/**
* String constructor - only for string-like arrays.
* Refer to @ref operator+=(const char*) for details.
*/
Array(const char* str) // Implicit
{
operator+=(str);
}
static int encode(const SelfType& array, ScalarCodec& codec, const TailArrayOptimizationMode tao_mode)
{
return array.encodeImpl(codec, tao_mode, BooleanType<IsDynamic>());
+10
View File
@@ -768,6 +768,16 @@ TEST(Array, Strings)
ASSERT_STREQ("Our sun is dying. 123456-789", a8_2.c_str());
ASSERT_STREQ("Our sun is dying. 123456-789", a8.c_str());
ASSERT_STREQ("456", a7.c_str());
/*
* String constructor
*/
A8 a8_3("123");
A7 a7_3 = "456";
ASSERT_EQ(3, a8_3.size());
ASSERT_EQ(3, a7_3.size());
ASSERT_STREQ("123", a8_3.c_str());
ASSERT_STREQ("456", a7_3.c_str());
}