Stack Overflow Asked by xmh0511 on November 4, 2021
template<typename T>
struct Test{};
template<typename Ret, typename...Args>
struct Test<Ret(*)(Args...)>{
using type = int;
};
void func(int){}
int main(){
Test<decltype(&func)>::type b;
}
If type P
is Ret(*)(Args...)
and the corresponding argument type A
is void(*)(int)
, the deduction attempt to deduce template argument from A
, however such form is not listed in the following list which specifies the what form of type can be deduced.
A template type argument T, a template template argument TT or a template non-type argument i can be deduced if P and A have one of the following forms:
- T
- cv-list T
- T*
- T&
- T&&
- T[integer-constant]
- template-name (where template-name refers to a class template)
- type(T)
- T()
- T(T)
- T type::*
- type T::*
- T T::*
- T (type::*)()
- type (T::*)()
- type (type::*)(T)
- type (T::*)(T)
- T (type::*)(T)
- T (T::*)()
- T (T::*)(T)
- type[i]
- template-name (where template-name refers to a class template)
- TT
- TT
- TT<>
The list specifies so much however pointer to function type is absent, only function type such as T(T)
is comprised, so why a pointer to function type is absent in this list, such type should be deducible.
A pointer-to-function type Ret(*)(Args...)
is nothing but a T*
where T
is Ret(Args...)
.
Edit: further examination has proven that this is not sufficient.
Answered by Quentin on November 4, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP