本文整理汇总了C++中Iter::search_below_dst方法的典型用法代码示例。如果您正苦于以下问题:C++ Iter::search_below_dst方法的具体用法?C++ Iter::search_below_dst怎么用?C++ Iter::search_below_dst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Iter
的用法示例。
在下文中一共展示了Iter::search_below_dst方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
// Call this function when searching below a dst_type node. This function searches
// for a path to (static_ptr, static_type) and for paths to one or more dst_type nodes.
// If it finds a static_type node, there is no need to further search base classes
// above.
// If it finds a dst_type node it should search base classes using search_above_dst
// to find out if this dst_type points to (static_ptr, static_type) or not.
// Either way, the dst_type is recorded as one of two "flavors": one that does
// or does not point to (static_ptr, static_type).
// If this is neither a static_type nor a dst_type node, continue searching
// base classes above.
// All the hoopla surrounding the search code is doing nothing but looking for
// excuses to stop the search prematurely (break out of the for-loop). That is,
// the algorithm below is simply an optimization of this:
// void
// __vmi_class_type_info::search_below_dst(__dynamic_cast_info* info,
// const void* current_ptr,
// int path_below) const
// {
// typedef const __base_class_type_info* Iter;
// if (this == info->static_type)
// process_static_type_below_dst(info, current_ptr, path_below);
// else if (this == info->dst_type)
// {
// // Record the most public access path that got us here
// if (info->path_dynamic_ptr_to_dst_ptr != public_path)
// info->path_dynamic_ptr_to_dst_ptr = path_below;
// bool does_dst_type_point_to_our_static_type = false;
// for (Iter p = __base_info, e= __base_info + __base_count; p < e; ++p)
// {
// p->search_above_dst(info, current_ptr, current_ptr, public_path);
// if (info->found_our_static_ptr)
// does_dst_type_point_to_our_static_type = true;
// // break out early here if you can detect it doesn't matter if you do
// }
// if (!does_dst_type_point_to_our_static_type)
// {
// // We found a dst_type that doesn't point to (static_ptr, static_type)
// // So record the address of this dst_ptr and increment the
// // count of the number of such dst_types found in the tree.
// info->dst_ptr_not_leading_to_static_ptr = current_ptr;
// info->number_to_dst_ptr += 1;
// }
// }
// else
// {
// // This is not a static_type and not a dst_type.
// for (Iter p = __base_info, e = __base_info + __base_count; p < e; ++p)
// {
// p->search_below_dst(info, current_ptr, public_path);
// // break out early here if you can detect it doesn't matter if you do
// }
// }
// }
void
__vmi_class_type_info::search_below_dst(__dynamic_cast_info* info,
const void* current_ptr,
int path_below,
bool use_strcmp) const
{
typedef const __base_class_type_info* Iter;
if (is_equal(this, info->static_type, use_strcmp))
process_static_type_below_dst(info, current_ptr, path_below);
else if (is_equal(this, info->dst_type, use_strcmp))
{
// We've been here before if we've recorded current_ptr in one of these
// two places:
if (current_ptr == info->dst_ptr_leading_to_static_ptr ||
current_ptr == info->dst_ptr_not_leading_to_static_ptr)
{
// We've seen this node before, and therefore have already searched
// its base classes above.
// Update path to here that is "most public".
if (path_below == public_path)
info->path_dynamic_ptr_to_dst_ptr = public_path;
}
else // We have haven't been here before
{
// Record the access path that got us here
// If there is more than one dst_type this path doesn't matter.
info->path_dynamic_ptr_to_dst_ptr = path_below;
// Only search above here if dst_type derives from static_type, or
// if it is unknown if dst_type derives from static_type.
if (info->is_dst_type_derived_from_static_type != no)
{
// Set up flags to record results from all base classes
bool is_dst_type_derived_from_static_type = false;
bool does_dst_type_point_to_our_static_type = false;
// We've found a dst_type with a potentially public path to here.
// We have to assume the path is public because it may become
// public later (if we get back to here with a public path).
// We can stop looking above if:
// 1. We've found a public path to (static_ptr, static_type).
// 2. We've found an ambiguous cast from (static_ptr, static_type) to a dst_type.
// This is detected at the (static_ptr, static_type).
// 3. We can prove that there is no public path to (static_ptr, static_type)
// above here.
const Iter e = __base_info + __base_count;
for (Iter p = __base_info; p < e; ++p)
{
// Zero out found flags
//.........这里部分代码省略.........