How to resolve pointer alias issues?

后端 未结 2 2059
孤城傲影
孤城傲影 2021-01-22 14:18

Careless use of templates can cause bloat. One way to avoid that bloat is to have a thin typesafe template that wraps non-typesafe non-template code. To do this, the wrapper nee

2条回答
  •  一向
    一向 (楼主)
    2021-01-22 14:44

    Careless use of templates CAN cause bloat. But you're totally missing the point here.

    • Templates cause bloat when used carelessly, not carefully.
    • The quantity of runtime errors avoided by templates is massive.
    • The speed of templated code is far greater than non-templated code.
    • The size of the executable is absolutely trivial unless you run on an embedded system.
    • The STL provides a map container (which is a binary search tree) for your use.

    You just haven't thought this through properly at all. The advantages templates offer far outweigh a few kb in executable size.

    It's also worth noting that the code works as expected on Visual Studio 2010.

提交回复
热议问题