本文整理汇总了C++中Lazy::find方法的典型用法代码示例。如果您正苦于以下问题:C++ Lazy::find方法的具体用法?C++ Lazy::find怎么用?C++ Lazy::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lazy
的用法示例。
在下文中一共展示了Lazy::find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
LLVM_ATTRIBUTE_ALWAYS_INLINE
static const Metadata *findHashableBaseTypeImpl(const Metadata *type) {
// Check the cache first.
if (HashableConformanceEntry *entry =
HashableConformances->find(HashableConformanceKey{type})) {
return entry->baseTypeThatConformsToHashable;
}
if (!KnownToConformToHashable &&
!swift_conformsToProtocol(type, &_TMps8Hashable)) {
// Don't cache the negative response because we don't invalidate
// this cache when a new conformance is loaded dynamically.
return nullptr;
}
// By this point, `type` is known to conform to `Hashable`.
const Metadata *baseTypeThatConformsToHashable = type;
while (true) {
const Metadata *superclass =
_swift_class_getSuperclass(baseTypeThatConformsToHashable);
if (!superclass)
break;
if (!swift_conformsToProtocol(superclass, &_TMps8Hashable))
break;
baseTypeThatConformsToHashable = superclass;
}
HashableConformances->getOrInsert(HashableConformanceKey{type},
baseTypeThatConformsToHashable);
return baseTypeThatConformsToHashable;
}