stevelauwh / sgi-stl Goto Github PK
View Code? Open in Web Editor NEW剖析 STL 是一种享受的过程!
剖析 STL 是一种享受的过程!
Why __default_alloc_template has no deconstruct function.
SGI-STL/SGI-STL V3.3/stl_iterator.h
Line 224 in be34aac
Why not ?
template <class _BidirectionalIterator, class _Tp, class _Reference, class _Distance> inline _Tp value_type(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, _Reference, _Distance>&) { return _Tp(); }
STL
SGI-STL/SGI-STL V3.3/stl_alloc.h
Lines 450 to 456 in be34aac
I think this logic is only correct when __bytes_left is a multiple of 8,
otherwise, __bytes_left would be less than the chunk size of the computed slot.
For example, if __bytes_left is 5, the computed slot is 0, with chunk size of 8, if caller function requests 7 bytes of memory, normally allocator returns 8 bytes of memory, but this chunk has only 5, which would be not enough.
SGI-STL/SGI-STL V3.3/stl_iterator.h
Line 224 in be34aac
Why not ?
template <class _BidirectionalIterator, class _Tp, class _Reference, class _Distance> inline _Tp value_type(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, _Reference, _Distance>&) { return _Tp(); }
在你的test目录下面,这里调用的还是默认的stl的代码,并不是你仓库里面的sgi-stl的代码。test里面调用的应该是 /usr/include/c++/5.x 里面的代码吧?
请问,你有没有调用过仓库里面的sgi-stl的的源码?
下面是你的test文件
#include <iostream>
#include <vector>
using namespace std;
template <typename T>
void printVector(const vector<T>& vec)
{
for (auto x : vec) {
cout << x << " ";
}
cout << endl;
}
int main()
{
// 构造函数:四种形式
vector<string> iv(2, "hi");
// ....
}
// 直接将参数 __inst 指定为0
typedef __malloc_alloc_template<0> malloc_alloc;
我个人觉得这里应该是一个实例化。这个文件有的地方函数 = 0 应该是表示 = nullptr.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.