获取重载函数模板的地址



我有一个getDescriptor有两个重载的函数模板。它们具有以下签名:

template <class _DescriptorType>
typename _DescriptorType::FeatureType getDescriptor
(const View & view, const _DescriptorType & desc);

template <class _DescriptorType>
typename _DescriptorType::FeatureType getDescriptor
(const Instance & instance, const _DescriptorType & desc);

我有一个不同的函数模板getEncoding其中我需要第一个getDescriptor函数的地址,以及来自 getEncoding_DescriptorType

template <class _DescriptorType>
Encoding getEncoding()
{
    auto ptr = static_cast<...>(getDescriptor);
    ...
}

我需要在static_cast中输入什么才能获取第二个重载getDescriptor模板的地址,并将_DescriptorType设置为 getEncoding 之一?

你去吧:

auto ptr = static_cast<
    typename _DescriptorType::FeatureType (*)(const Instance &, const _DescriptorType &)
>(getDescriptor<_DescriptorType>);

最新更新