本文整理汇总了C++中boost::optional::front方法的典型用法代码示例。如果您正苦于以下问题:C++ optional::front方法的具体用法?C++ optional::front怎么用?C++ optional::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::optional
的用法示例。
在下文中一共展示了optional::front方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uassert
std::vector<std::string> Exchange::extractBoundaries(
const boost::optional<std::vector<BSONObj>>& obj, Ordering ordering) {
std::vector<std::string> ret;
if (!obj) {
return ret;
}
for (auto& b : *obj) {
// Build the key.
BSONObjBuilder kb;
for (auto elem : b) {
kb << "" << elem;
}
KeyString key{KeyString::Version::V1, kb.obj(), ordering};
std::string keyStr{key.getBuffer(), key.getSize()};
ret.emplace_back(std::move(keyStr));
}
uassert(50960, str::stream() << "Exchange range boundaries are not valid", ret.size() > 1);
for (size_t idx = 1; idx < ret.size(); ++idx) {
uassert(50893,
str::stream() << "Exchange range boundaries are not in ascending order.",
ret[idx - 1] < ret[idx]);
}
BSONObjBuilder kbMin;
BSONObjBuilder kbMax;
for (int i = 0; i < obj->front().nFields(); ++i) {
kbMin << "" << MINKEY;
kbMax << "" << MAXKEY;
}
KeyString minKey{KeyString::Version::V1, kbMin.obj(), ordering};
KeyString maxKey{KeyString::Version::V1, kbMax.obj(), ordering};
StringData minKeyStr{minKey.getBuffer(), minKey.getSize()};
StringData maxKeyStr{maxKey.getBuffer(), maxKey.getSize()};
uassert(50958,
str::stream() << "Exchange lower bound must be the minkey.",
ret.front() == minKeyStr);
uassert(50959,
str::stream() << "Exchange upper bound must be the maxkey.",
ret.back() == maxKeyStr);
return ret;
}