mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-14 04:23:35 +08:00
String constructor for Array<>
This commit is contained in:
@@ -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>());
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user