TinySTL
TinySTL copied to clipboard
TinySTL is a subset of STL(cut some containers and algorithms) and also a superset of STL(add some other containers and algorithms)
Vector: 1. 按照STL标准,我认为Vector中使用erase函数,需要对对象进行移位操作后,还需进行销毁操作。 故我对erase(iterator first, iterator last)进行了修改。 2. erase(iterator position)函数中,原先操作为erase(position,position+1),当 3. position==finish,finish==end_of_storage情况下,position+1就不妥当了。 4. 在resize函数中,当n>size()时,需申请n个新空间,而不是申请(LengthOfInsert = n - capacity())个空间。 List: 1. 在重载==函数中,当数值不相等时可直接return false,不需要跳出循环再进行比较操作。 2. 如果两个List跳出循环时都是尾端,那么如此操作就会返回true,而不是正确值false。 String 1. find函数中,如果if (size() - pos...
Vector.h中`vector(vector&& v);`与`vector& operator = (vector&& v);`均没有声明为noexcept,是否增加后有助于编译器优化?
Allocator中destroy()函数没有对数据类型做萃取,全都调用了析构函数进行了析构,是不是需要结合Construct.h中destroy()函数对数据类型进行萃取之后再destroy(). 还有一个问题就是Construct.h中destroy()函数直接 `template inline void destroy(ForwardIt first,ForwardIt last){ typedef typename _type_traits::is_POD_type is_POD_type; _destroy(first,last,is_POD_type()); }`这样写是不是有点问题,是不是需要先萃取ForwardIt的value_type再_type_traits 一点小小的疑问
这个函数是这样的: ``` 1 template 2 inline void destroy(ForwardIterator first, ForwardIterator last) { 3 typedef typename _type_traits::is_POD_type is_POD_type; 4 _destroy(first, last, is_POD_type()); 5 } ``` 第 3 句用了 `_type_traits ::is_POD_type`。 这个版本的...
``` template inline void destroy(ForwardIterator first, ForwardIterator last){ typedef typename _type_traits::is_POD_type is_POD_type; _destroy(first, last, is_POD_type()); ``` 我的理解ForwardIterator 应该是表示迭代器? 那萃取的应该是*ForwardIterator,为什么是ForwardIterator?望赐教, Thx。
比如说都是DEBUG还是都是RELEASE,都是O3优化之类的??我觉得写得比STL快我是不相信的呀
g++ 4.2.1 > ../Utility.h:31:19: error: declaration of 'T1' shadows template parameter > template ``` template struct pair{ public: typedef T1 first_type; typedef T2 second_type; public: T1 first; T2 second; public:...
运行问题
VS2013需要别的设置吗?问什么运行各种问题,如下等 1>c:\users\administrator\desktop\tinystl-master\tinystl\Detail\Bitmap.impl.h(18): warning C4800: “uint8_t”: 将值强制为布尔值“true”或“false”(性能警告) 1> c:\users\administrator\desktop\tinystl-master\tinystl\Detail\Bitmap.impl.h(16): 编译类 模板 成员函数“void TinySTL::bitmap::setNthInInt8(uint8_t &,size_t,bool)”时 1> c:\users\administrator\desktop\tinystl-master\tinystl\Detail\Bitmap.impl.h(66): 参见对正在编译的函数 模板 实例化“void TinySTL::bitmap::setNthInInt8(uint8_t &,size_t,bool)”的引用 1> c:\users\administrator\desktop\tinystl-master\tinystl\Detail\Bitmap.impl.h(57): 编译类 模板 成员函数“TinySTL::bitmap::bitmap(void)”时 1> Test\BitmapTest.cpp(16): 参见对正在编译的函数 模板 实例化“TinySTL::bitmap::bitmap(void)”的引用...