I'm trying to write template class that inherits from T
and to correctly implement one part, I need to know what data type is this T
working with. Fortunately, all valid substitutions for T have member method GetOutput
which returns the expected data type. However, the method have two overloads: GetOutput()
and GetOutput(int)
. I was trying to extract the type using this answer but am failing to get the overload resolution working:
using OutputType = typename std::result_of<decltype(&T::GetOutput)(T)>::type;
Is what I'm trying possible and if so, what is the correct way to get there?
如果GetOutput
的两个重载返回相同的类型,您可以只选择其中之一并使用其返回类型:
using OutputType = decltype(std::declval<T&>().GetOutput());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.