本文整理汇总了C++中type::constructors方法的典型用法代码示例。如果您正苦于以下问题:C++ type::constructors方法的具体用法?C++ type::constructors怎么用?C++ type::constructors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类type
的用法示例。
在下文中一共展示了type::constructors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: t
custom_attribute::custom_attribute(std::nullptr_t, metadata::custom_attribute_token const& attribute, core::internal_key)
{
core::assert_initialized(attribute);
metadata::custom_attribute_row const attribute_row(row_from(attribute));
static metadata::binding_flags const flags(metadata::binding_attribute::all_instance);
_attribute = attribute;
switch (attribute_row.type().table())
{
case metadata::table_id::method_def:
{
metadata::method_def_token const ctor_token(attribute_row.type().as<metadata::method_def_token>());
metadata::type_def_token const owner_token(metadata::find_owner_of_method_def(ctor_token).token());
type const t(owner_token, core::internal_key());
auto const constructors(t.constructors(flags));
auto const constructor_it(core::find_if(constructors, [&](method const& ctor)
{
return ctor.metadata_token() == ctor_token.value();
}));
if (constructor_it == end(constructors))
throw core::runtime_error(L"failed to find constructor for attribute");
_reflected_type = constructor_it->reflected_type().context(core::internal_key());
_constructor.get() = &constructor_it->context(core::internal_key());
break;
}
case metadata::table_id::member_ref:
{
metadata::member_ref_row const ref_row(row_from(attribute_row.type().as<metadata::member_ref_token>()));
metadata::member_ref_parent_token const owner_token(ref_row.parent());
switch (owner_token.table())
{
case metadata::table_id::type_ref:
{
type const t(owner_token.as<metadata::type_ref_token>(), core::internal_key());
if (ref_row.name() == L".ctor")
{
// TODO Correct detection of contructors
if (t.constructors(flags).empty())
core::assert_not_yet_implemented();
detail::loader_context const& root(detail::loader_context::from(owner_token.scope()));
metadata::signature_comparer const compare(&root);
auto const constructors(t.constructors(flags));
auto const constructor_it(core::find_if(constructors, [&](method const& ctor)
{
return compare(
ref_row.signature().as<metadata::method_signature>(),
ctor.context(core::internal_key()).member_signature());
}));
if (constructor_it == end(constructors))
throw core::runtime_error(L"failed to find constructor for attribute");
_reflected_type = constructor_it->reflected_type().context(core::internal_key());
_constructor.get() = &constructor_it->context(core::internal_key());
break;
}
else
{
core::assert_not_yet_implemented();
}
}
default:
{
core::assert_not_yet_implemented();
}
}
break;
}
default:
{
core::assert_unreachable();
}
}
}