本文整理汇总了C++中Nullable::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Nullable::clear方法的具体用法?C++ Nullable::clear怎么用?C++ Nullable::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nullable
的用法示例。
在下文中一共展示了Nullable::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testNullable
void CoreTest::testNullable()
{
Nullable<int> i;
Nullable<double> f;
Nullable<std::string> s;
assert (i.isNull());
assert (f.isNull());
assert (s.isNull());
i = 1;
f = 1.5;
s = "abc";
assert (!i.isNull());
assert (!f.isNull());
assert (!s.isNull());
assert (i == 1);
assert (f == 1.5);
assert (s == "abc");
i.clear();
f.clear();
s.clear();
assert (i.isNull());
assert (f.isNull());
assert (s.isNull());
Nullable<int> n1;
assert (n1.isNull());
assert (n1.value(42) == 42);
assert (n1.isNull());
assert (!(0 == n1));
assert (0 != n1);
assert (!(n1 == 0));
assert (n1 != 0);
try
{
int tmp = n1.value();
fail("null value, must throw");
}
catch (Poco::NullValueException&)
{
}
n1 = 1;
assert (!n1.isNull());
assert (n1.value() == 1);
Nullable<int> n2(42);
assert (!n2.isNull());
assert (n2.value() == 42);
assert (n2.value(99) == 42);
assert (!(0 == n2));
assert (0 != n2);
assert (!(n2 == 0));
assert (n2 != 0);
n1 = n2;
assert (!n1.isNull());
assert (n1.value() == 42);
std::ostringstream str;
str << n1;
assert (str.str() == "42");
n1.clear();
assert (n1.isNull());
str.str(""); str << n1;
assert (str.str().empty());
n2.clear();
assert (n1 == n2);
n1 = 1; n2 = 1;
assert (n1 == n2);
n1.clear();
assert (n1 < n2);
assert (n2 > n1);
n2 = -1; n1 = 0;
assert (n2 < n1);
assert (n2 != n1);
assert (n1 > n2);
NullType nd;
assert (n1 != nd);
assert (nd != n1);
n1.clear();
assert (n1 == nd);
assert (nd == n1);
}