0

In some base class of a std::list<> The following typedef is found

typedef typename _Alloc::template rebind<_Ty>::other _Alty;

I am having hard time breaking the above declaration to understand. How to read the above easily and

  1. Why is there a :: template after _Alloc?
  2. What is std::rebind?
user438383
  • 5,716
  • 8
  • 28
  • 43
Test
  • 564
  • 3
  • 12
  • 2
    Does this answer your question? [what does (template) rebind<> do?](https://stackoverflow.com/questions/14148756/what-does-template-rebind-do) – BZKN Jan 11 '22 at 20:45
  • @BKN - I went through that but didn't get much clarity to break down the declaration and understand. Hence posted the above question. – Test Jan 11 '22 at 20:46
  • 3
    In this context, `_Alloc` is a template type parameter, so the compiler doesn't know what `_Alloc::rebind` is yet. The word `template` is there to tell the compiler that `rebind` should be interpreted as a template. Without it, the compiler will think that the `<` is a less-than operator rather than a template parameter marker. – Raymond Chen Jan 11 '22 at 20:52
  • @Test You deleted the other question, you were \*this* close to getting the solution you wanted. I posted it https://chat.stackoverflow.com/rooms/240991/rotating-boost-polygon with an explanation. Please undelete the post so other people can benefit from that too? – sehe Jan 12 '22 at 11:51
  • @sehe - how do I see the questions I deleted? I am unable to locate the same. – Test Jan 12 '22 at 12:30
  • @Test I think you can click the "Recently deleted" link at the bottom of [this page](https://stackoverflow.com/users/16224437/Test?tab=questions). Likely this link should work for you when logged in: https://stackoverflow.com/users/recently-deleted-questions/16224437 – sehe Jan 12 '22 at 13:11
  • @sehe - I have enabled back that question. thanks – Test Jan 12 '22 at 14:18

0 Answers0