本文整理汇总了C++中mozilla::Nothing方法的典型用法代码示例。如果您正苦于以下问题:C++ mozilla::Nothing方法的具体用法?C++ mozilla::Nothing怎么用?C++ mozilla::Nothing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozilla
的用法示例。
在下文中一共展示了mozilla::Nothing方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Lookup
explicit Lookup(SavedFrame& savedFrame)
: source(savedFrame.getSource()),
line(savedFrame.getLine()),
column(savedFrame.getColumn()),
functionDisplayName(savedFrame.getFunctionDisplayName()),
asyncCause(savedFrame.getAsyncCause()),
parent(savedFrame.getParent()),
principals(savedFrame.getPrincipals()),
framePtr(Nothing()),
pc(nullptr),
activation(nullptr)
{
MOZ_ASSERT(source);
}
示例2: DECLTYPE
static bool
TestBasicFeatures()
{
// Check that a Maybe<T> is initialized to Nothing.
Maybe<BasicValue> mayValue;
static_assert(IsSame<BasicValue, DECLTYPE(mayValue)::ValueType>::value,
"Should have BasicValue ValueType");
MOZ_RELEASE_ASSERT(!mayValue);
MOZ_RELEASE_ASSERT(!mayValue.isSome());
MOZ_RELEASE_ASSERT(mayValue.isNothing());
// Check that emplace() default constructs and the accessors work.
mayValue.emplace();
MOZ_RELEASE_ASSERT(mayValue);
MOZ_RELEASE_ASSERT(mayValue.isSome());
MOZ_RELEASE_ASSERT(!mayValue.isNothing());
MOZ_RELEASE_ASSERT(*mayValue == BasicValue());
MOZ_RELEASE_ASSERT(mayValue.value() == BasicValue());
static_assert(IsSame<BasicValue, DECLTYPE(mayValue.value())>::value,
"value() should return a BasicValue");
MOZ_RELEASE_ASSERT(mayValue.ref() == BasicValue());
static_assert(IsSame<BasicValue&, DECLTYPE(mayValue.ref())>::value,
"ref() should return a BasicValue&");
MOZ_RELEASE_ASSERT(mayValue.ptr() != nullptr);
static_assert(IsSame<BasicValue*, DECLTYPE(mayValue.ptr())>::value,
"ptr() should return a BasicValue*");
MOZ_RELEASE_ASSERT(mayValue->GetStatus() == eWasDefaultConstructed);
// Check that reset() works.
mayValue.reset();
MOZ_RELEASE_ASSERT(!mayValue);
MOZ_RELEASE_ASSERT(!mayValue.isSome());
MOZ_RELEASE_ASSERT(mayValue.isNothing());
// Check that emplace(T1) calls the correct constructor.
mayValue.emplace(1);
MOZ_RELEASE_ASSERT(mayValue);
MOZ_RELEASE_ASSERT(mayValue->GetStatus() == eWasConstructed);
MOZ_RELEASE_ASSERT(mayValue->GetTag() == 1);
mayValue.reset();
MOZ_RELEASE_ASSERT(!mayValue);
// Check that Some() and Nothing() work.
mayValue = Some(BasicValue(2));
MOZ_RELEASE_ASSERT(mayValue);
MOZ_RELEASE_ASSERT(mayValue->GetStatus() == eWasMoveConstructed);
MOZ_RELEASE_ASSERT(mayValue->GetTag() == 2);
mayValue = Nothing();
MOZ_RELEASE_ASSERT(!mayValue);
// Check that the accessors work through a const ref.
mayValue.emplace();
const Maybe<BasicValue>& mayValueCRef = mayValue;
MOZ_RELEASE_ASSERT(mayValueCRef);
MOZ_RELEASE_ASSERT(mayValueCRef.isSome());
MOZ_RELEASE_ASSERT(!mayValueCRef.isNothing());
MOZ_RELEASE_ASSERT(*mayValueCRef == BasicValue());
MOZ_RELEASE_ASSERT(mayValueCRef.value() == BasicValue());
static_assert(IsSame<BasicValue, DECLTYPE(mayValueCRef.value())>::value,
"value() should return a BasicValue");
MOZ_RELEASE_ASSERT(mayValueCRef.ref() == BasicValue());
static_assert(IsSame<const BasicValue&,
DECLTYPE(mayValueCRef.ref())>::value,
"ref() should return a const BasicValue&");
MOZ_RELEASE_ASSERT(mayValueCRef.ptr() != nullptr);
static_assert(IsSame<const BasicValue*,
DECLTYPE(mayValueCRef.ptr())>::value,
"ptr() should return a const BasicValue*");
MOZ_RELEASE_ASSERT(mayValueCRef->GetStatus() == eWasDefaultConstructed);
mayValue.reset();
return true;
}