![](/img/trans.png)
[英]Can someone explain the special std::function template parameter list syntax(this strange Type(Types…))?
[英]Can someone explain this template function declaration syntax
我不理解boost :: python庫中的以下模板聲明(准確地說是... / boost_1_51 / boost / python / detail / msvc_typeinfo.hpp的第47行):
template< typename T > T&(* is_ref_tester1(type<T>) )(type<T>) { return 0; }
其中type
是template <class T> struct type {};
它似乎在功能上等同於:
template<typename T>
struct func_type_getter {
typedef T&(*func_type)(type<T>);
};
template< typename T >
typename func_type_getter<T>::func_type is_ref_tester1(type<T>) { return 0; }
這些是等同的嗎,它只是一個簡寫,還是有人可以解釋這些差異?
是的,這兩個是等價的。 這是如何閱讀單行內容:
template< typename T > T&(* is_ref_tester1(type<T>) )(type<T>) { return 0; }
^ ^ ^ ^
| | | |
| | | 3. it's return type is a pointer to a function taking a type<T>
| | |
| | 2. it's a function taking a type<T>
| |
| 1. this is the declared identifier
|
4. this is the return type of the function whose pointer is returned
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.