c++ vector source code

后端 未结 4 2190
眼角桃花
眼角桃花 2021-02-20 10:44

I am trying to get the vector source code to see how the standard std or stl vector is implemented.

This is for learning purpose. Now the question is where can i find t

4条回答
  •  温柔的废话
    2021-02-20 11:28

    Different runtime has different implementation.

    But I guess this is what you want, the widely used gcc implementation: https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/std/vector

    It is the main header file, and the implementation is in https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/stl_vector.h and https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/stl_bvector.h

    It use MACRO to make the code run in good performance and fit in variable situation, but make it hard to read, wish you good luck.

提交回复
热议问题