Embedded C++ : to use STL or not?

后端 未结 11 2151
北荒
北荒 2020-11-30 18:29

I have always been an embedded software engineer, but usually at Layer 3 or 2 of the OSI stack. I am not really a hardware guy. I have generally always done telecoms product

11条回答
  •  旧时难觅i
    2020-11-30 19:18

    Let me start out by saying I haven't done embedded work for a few years, and never in C++, so my advice is worth every penny you're paying for it...

    The templates utilized by STL are never going to generate code you wouldn't need to generate yourself, so I wouldn't worry about code bloat.

    The STL doesn't throw exceptions on its own, so that shouldn't be a concern. If your classes don't throw, you should be safe. Divide your object initialization into two parts, let the constructor create a bare bones object and then do any initialization that could fail in a member function that returns an error code.

    I think all of the container classes will let you define your own allocation function, so if you want to allocate from a pool you can make it happen.

提交回复
热议问题