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 names template<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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -