Extending std::list

后端 未结 8 2110
小蘑菇
小蘑菇 2021-01-31 13:00

I need to use lists for my program and needed to decide if I use std::vector or std::list. The problem with vector is that there is no remove method and with list that there is

相关标签:
8条回答
  • 2021-01-31 13:29

    The obvious stuff has already been described in details:

    But the methods you choose to implement??

    • Destructor.
      • Not required compiler will generate that for you.
    • The two different versions of operator[] are pointless
      • Also you should be uisng std::list::size_type as the index
      • Unless you intend to support negative indexes.
    • There are no const versions of operator[]
    • If you are going to implement [] you should also do at()
    • You missed out all the different ways of constructing a list.
    • Containers should define several types internally
      • see http://www.sgi.com/tech/stl/Container.html
    0 讨论(0)
  • You have to move all your template code into header.

    0 讨论(0)
提交回复
热议问题