Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename T> return_type fun_name();
- template<> return_type fun_name<int>(){/* blabla */}
- //-------------failed case-------------
- template <typename T>
- struct deduce{
- typedef T* type;
- };
- template <typename T>
- typename deduce<T>::type fun1();
- template <>
- typename deduce<float>::type fun1<float>() //error if no "<float>" after fun1
- {
- }
- //------------now the "Template Argument Deduction" works------------
- template <typename T>
- struct some_struct{
- T* p;
- };
- template <typename T>
- some_struct<T> fun2();
- template <>
- some_struct<float> fun2() // no error even if no "<float>" after fun2
- {
- }
- error: template-id βfun1<>β for βfloat* fun1()β does not match any template declaration
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement