STL - does every compiler implement it differently?

前端 未结 5 1676
臣服心动
臣服心动 2020-12-18 13:48

It was said to me that the standard template library is differently implemented by every compiler, is this correct?

How can computational complexity (both in time an

5条回答
  •  佛祖请我去吃肉
    2020-12-18 14:23

    Every C++ compiler comes with an implementation of the C++ standard library. Some implementations are based on others while some are independent.

    However, they all must implement the standard. And the standard has certain complexity specifications that it requires from various functions. A set cannot be implemented purely as a linked-list and still meet those guarantees. Thus, if a C++ standard library implements set as a linked-list, then it is in violation of the standard. This is no different from a a C++ compiler implementing if wrong.

提交回复
热议问题