Template typedefs - What's your work around?

后端 未结 3 593
梦谈多话
梦谈多话 2020-11-29 00:22

C++ 0x has template aliases (sometimes referred to as template typedefs). See here. Current spec of C++ does not.

What do you like to use as work around ? Container

3条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 00:57

    template 
    struct my_string_map : public std::map 
    {
    };
    

    You shouldn't inherit from classes that do not have a virtual destructor. It's related to destructors in derived classes not being called when they should be and you could end up with unallocated memory.

    That being said you could *****probably***** get away with it in the instance above because you're not adding any more data to your derived type. Note that this is not an endorsement. I still advice you don't do it. The fact that you can do it doesn't mean you should.

    EDIT: Yes, this is a reply to ShaChris23's post. I probably missed something because it showed up above his/her message instead of below.

提交回复
热议问题