c++ - Can someone explain this template function declaration syntax -
i not understand following template declaration in boost::python library (line 47 of .../boost_1_51/boost/python/detail/msvc_typeinfo.hpp precise):
template< typename t > t&(* is_ref_tester1(type<t>) )(type<t>) { return 0; }
where type
template <class t> struct type {};
it seems functionally equivalent to:
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; }
are these equivalent, shorthand, or can explain differences?
yes, 2 equivalent. here is, how one-liner read:
template< typename t > t&(* is_ref_tester1(type<t>) )(type<t>) { return 0; } ^ ^ ^ ^ | | | | | | | 3. it's return type pointer function taking type<t> | | | | | 2. it's function taking type<t> | | | 1. declared identifier | 4. return type of function pointer returned
Comments
Post a Comment