Add support for function types
This commit is contained in:
parent
0eb14d8cab
commit
8bb6268626
4 changed files with 95 additions and 44 deletions
|
|
@ -11,23 +11,6 @@ namespace cppast
|
|||
{
|
||||
enum class cpp_entity_kind;
|
||||
|
||||
/// \exclude
|
||||
namespace detail
|
||||
{
|
||||
void check_entity_cast_impl(const cpp_entity& e, cpp_entity_kind expected_kind);
|
||||
|
||||
template <typename T>
|
||||
void check_entity_cast(const cpp_entity& e)
|
||||
{
|
||||
check_entity_cast_impl(e, T::kind());
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void check_entity_cast<cpp_entity>(const cpp_entity&)
|
||||
{
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
/// A basic reference to some kind of [cppast::cpp_entity]().
|
||||
template <typename T, typename Predicate>
|
||||
class basic_cpp_entity_ref
|
||||
|
|
@ -57,7 +40,8 @@ namespace cppast
|
|||
auto entity = idx.lookup(target_);
|
||||
if (!entity)
|
||||
return type_safe::nullopt;
|
||||
detail::check_entity_cast<T>(entity.value());
|
||||
DEBUG_ASSERT(Predicate{}(entity.value()), detail::precondition_error_handler{},
|
||||
"predicate not fulfilled");
|
||||
return static_cast<const T&>(entity.value());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue