c++ - Template alias for another alias -
this question has answer here:
i have problem 'using' keyword in c++11. piece of code should create alias pointer type.
template <typename t> class someclass { typedef typename std::add_pointer<t>::type pointer; template <typename u> using rebind_pointer = typename std::pointer_traits<pointer>::rebind<u>; } someclass<int> obj;
but in gcc 4.7 i've got compile error:
typename std::pointer_traits<int*>::rebind
namestemplate<class _up> using rebind = _up*
, not type
i found out pointer_traits::rebind template alias maybe problem ?
you need tell compiler parse rebind
template:
template <typename u> using rebind_pointer = typename std::pointer_traits<pointer>::template rebind<u>; // ^^^^^^^^
this necessary because std::pointer_traits<pointer>
dependent on template parameter (t
).
see this question more details when , why need use template
keyword.
Comments
Post a Comment