Why not include all the standard headers always?

后端 未结 7 789
攒了一身酷
攒了一身酷 2021-01-03 19:02

I am reading Herb Sutter\'s More Exceptional C++ and item 37 on forward declarations says:

Never #include a

7条回答
  •  情话喂你
    2021-01-03 19:47

    There is in principle nothing against it.

    The only thing that will happen is that your compile times will increase, unless of course you create a precompiled header of that standard_library.h, in which case the impact will be minimal.

    Note that most people prefer to minimize their header dependencies. This mostly applies to your own header files, in which case a small change in an unused, but included header in a source file may trigger an unnecessary recompile of said source file for no reason whatsoever, slowing down incremental builds a lot.

提交回复
热议问题