本文整理汇总了C++中Optional::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Optional::begin方法的具体用法?C++ Optional::begin怎么用?C++ Optional::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Optional
的用法示例。
在下文中一共展示了Optional::begin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lookupFilename
StringRef HeaderMapImpl::lookupFilename(StringRef Filename,
SmallVectorImpl<char> &DestPath) const {
const HMapHeader &Hdr = getHeader();
unsigned NumBuckets = getEndianAdjustedWord(Hdr.NumBuckets);
// Don't probe infinitely. This should be checked before constructing.
assert(llvm::isPowerOf2_32(NumBuckets) && "Expected power of 2");
// Linearly probe the hash table.
for (unsigned Bucket = HashHMapKey(Filename);; ++Bucket) {
HMapBucket B = getBucket(Bucket & (NumBuckets-1));
if (B.Key == HMAP_EmptyBucketKey) return StringRef(); // Hash miss.
// See if the key matches. If not, probe on.
Optional<StringRef> Key = getString(B.Key);
if (LLVM_UNLIKELY(!Key))
continue;
if (!Filename.equals_lower(*Key))
continue;
// If so, we have a match in the hash table. Construct the destination
// path.
Optional<StringRef> Prefix = getString(B.Prefix);
Optional<StringRef> Suffix = getString(B.Suffix);
DestPath.clear();
if (LLVM_LIKELY(Prefix && Suffix)) {
DestPath.append(Prefix->begin(), Prefix->end());
DestPath.append(Suffix->begin(), Suffix->end());
}
return StringRef(DestPath.begin(), DestPath.size());
}
}
示例2: createExtract
SILValue SILValueProjection::createExtract(SILValue Base,
const Optional<NewProjectionPath> &Path,
SILInstruction *Inst,
bool IsValExt) {
// If we found a projection path, but there are no projections, then the two
// loads must be the same, return PrevLI.
if (!Path || Path->empty())
return Base;
// Ok, at this point we know that we can construct our aggregate projections
// from our list of address projections.
SILValue LastExtract = Base;
SILBuilder Builder(Inst);
Builder.setCurrentDebugScope(Inst->getFunction()->getDebugScope());
// We use an auto-generated SILLocation for now.
// TODO: make the sil location more precise.
SILLocation Loc = RegularLocation::getAutoGeneratedLocation();
// Construct the path!
for (auto PI = Path->begin(), PE = Path->end(); PI != PE; ++PI) {
if (IsValExt) {
LastExtract =
PI->createObjectProjection(Builder, Loc, LastExtract).get();
continue;
}
LastExtract =
PI->createAddressProjection(Builder, Loc, LastExtract).get();
}
// Return the last extract we created.
return LastExtract;
}
示例3: mergeVectors
static void mergeVectors(Optional<T> &Dest, const Optional<T> &Src) {
if (Src) {
if (Dest)
Dest->insert(Dest->end(), Src->begin(), Src->end());
else
Dest = Src;
}
}