本文整理汇总了C++中boost::optional::value_or方法的典型用法代码示例。如果您正苦于以下问题:C++ optional::value_or方法的具体用法?C++ optional::value_or怎么用?C++ optional::value_or使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::optional
的用法示例。
在下文中一共展示了optional::value_or方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
ValidatorList::ValidatorList (
ManifestCache& validatorManifests,
ManifestCache& publisherManifests,
TimeKeeper& timeKeeper,
beast::Journal j,
boost::optional<std::size_t> minimumQuorum)
: validatorManifests_ (validatorManifests)
, publisherManifests_ (publisherManifests)
, timeKeeper_ (timeKeeper)
, j_ (j)
, quorum_ (minimumQuorum.value_or(1)) // Genesis ledger quorum
, minimumQuorum_ (minimumQuorum)
{
}
示例2: transactionFromSQL
Transaction::pointer Transaction::transactionFromSQL (
boost::optional<std::uint64_t> const& ledgerSeq,
boost::optional<std::string> const& status,
Blob const& rawTxn,
Validate validate)
{
std::uint32_t const inLedger =
rangeCheckedCast<std::uint32_t>(ledgerSeq.value_or (0));
SerialIter it (makeSlice(rawTxn));
auto txn = std::make_shared<STTx> (it);
std::string reason;
auto tr = std::make_shared<Transaction> (txn, validate, reason);
tr->setStatus (sqlTransactionStatus (status));
tr->setLedger (inLedger);
return tr;
}
示例3: toggle
void Manager::toggle(boost::optional<bool> &setting, const bool current)
{
setting = !setting.value_or(current);
setChange(*setting == current ? -1 : 1);
}