小编Hen*_*yF1的帖子

__vector_base_common 是怎么回事?

我想看看 C++ 向量是如何制作的。我发现了这个,实现是 LLVM 编译器https://llvm.org/svn/llvm-project/libcxx/trunk/src/vector.cpp appleclang

src/vector.cpp:

#include "vector"

_LIBCPP_BEGIN_NAMESPACE_STD

template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __vector_base_common<true>;

_LIBCPP_END_NAMESPACE_STD
Run Code Online (Sandbox Code Playgroud)

实现https://llvm.org/svn/llvm-project/libcxx/trunk/include/vector appleclang LLVM。

包括/向量:

// .. deleted code

template <bool>
class __vector_base_common
{
protected:
    _LIBCPP_ALWAYS_INLINE __vector_base_common() {}
    _LIBCPP_NORETURN void __throw_length_error() const;
    _LIBCPP_NORETURN void __throw_out_of_range() const;
};

template <bool __b>
void
__vector_base_common<__b>::__throw_length_error() const
{
    _VSTD::__throw_length_error("vector");
}

template <bool __b>
void
__vector_base_common<__b>::__throw_out_of_range() const
{
    _VSTD::__throw_out_of_range("vector");
}

_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __vector_base_common<true>)

// .. deleted code

template <class _Tp, class _Allocator>
class __vector_base
    : protected __vector_base_common<true>

// .. …
Run Code Online (Sandbox Code Playgroud)

c++ libc++

5
推荐指数
1
解决办法
918
查看次数

标签 统计

c++ ×1

libc++ ×1