本文整理汇总了C++中ContainerType::assign方法的典型用法代码示例。如果您正苦于以下问题:C++ ContainerType::assign方法的具体用法?C++ ContainerType::assign怎么用?C++ ContainerType::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContainerType
的用法示例。
在下文中一共展示了ContainerType::assign方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testColumnList
void DataTest::testColumnList()
{
typedef std::list<int> ContainerType;
typedef Column<ContainerType> ColumnType;
MetaColumn mc(0, "mc", MetaColumn::FDT_DOUBLE, 2, 3, true);
assert (mc.name() == "mc");
assert (mc.position() == 0);
assert (mc.length() == 2);
assert (mc.precision() == 3);
assert (mc.type() == MetaColumn::FDT_DOUBLE);
assert (mc.isNullable());
ContainerType* pData = new ContainerType;
pData->push_back(1);
pData->push_back(2);
pData->push_back(3);
pData->push_back(4);
pData->push_back(5);
ColumnType c(mc, pData);
assert (c.rowCount() == 5);
assert (c[0] == 1);
assert (c[1] == 2);
assert (c[2] == 3);
assert (c[3] == 4);
assert (c[4] == 5);
assert (c.name() == "mc");
assert (c.position() == 0);
assert (c.length() == 2);
assert (c.precision() == 3);
assert (c.type() == MetaColumn::FDT_DOUBLE);
try
{
int i; i = c[100]; // to silence gcc
fail ("must fail");
}
catch (RangeException&) { }
ColumnType c1 = c;
assert (c1.rowCount() == 5);
assert (c1[0] == 1);
assert (c1[1] == 2);
assert (c1[2] == 3);
assert (c1[3] == 4);
assert (c1[4] == 5);
ColumnType c2(c1);
assert (c2.rowCount() == 5);
assert (c2[0] == 1);
assert (c2[1] == 2);
assert (c2[2] == 3);
assert (c2[3] == 4);
assert (c2[4] == 5);
ContainerType vi;
vi.assign(c.begin(), c.end());
assert (vi.size() == 5);
ContainerType::const_iterator it = vi.begin();
ContainerType::const_iterator end = vi.end();
for (int i = 1; it != end; ++it, ++i)
assert (*it == i);
c.reset();
assert (c.rowCount() == 0);
assert (c1.rowCount() == 0);
assert (c2.rowCount() == 0);
ContainerType* pV1 = new ContainerType;
pV1->push_back(1);
pV1->push_back(2);
pV1->push_back(3);
pV1->push_back(4);
pV1->push_back(5);
ContainerType* pV2 = new ContainerType;
pV2->push_back(5);
pV2->push_back(4);
pV2->push_back(3);
pV2->push_back(2);
pV2->push_back(1);
Column<ContainerType> c3(mc, pV1);
Column<ContainerType> c4(mc, pV2);
Poco::Data::swap(c3, c4);
assert (c3[0] == 5);
assert (c3[1] == 4);
assert (c3[2] == 3);
assert (c3[3] == 2);
assert (c3[4] == 1);
assert (c4[0] == 1);
assert (c4[1] == 2);
assert (c4[2] == 3);
assert (c4[3] == 4);
assert (c4[4] == 5);
//.........这里部分代码省略.........