MyTinySTL icon indicating copy to clipboard operation
MyTinySTL copied to clipboard

Achieve a tiny STL in C++11

Results 49 MyTinySTL issues
Sort by recently updated
recently updated
newest added

- 在insert函数中 ``` // 在 pos 处插入 n 个元素 template typename basic_string::iterator basic_string:: insert(const_iterator pos, size_type count, value_type ch) { iterator r = const_cast(pos); if (count == 0) return r;...

[请看代码](https://github.com/Alinshans/MyTinySTL/blob/acc07e025f521a28773ff82c4d11e249911ddcb2/MyTinySTL/functional.h#L143), 此处实例化是否应当为: ```cpp template struct identity : public unarg_function { const T &operator()(const T &x) const { return x; } }; ``` 即将父类模板的第二个模板参数实例化为`T`而非`bool`。

Test\algorithm_test.h(722,66): error C2059: 语法错误:“)”

Fixes #133. 策略: - 如果编译器支持 `__builtin_addressof` 则使用; - 否则,使用 SFINAE - 对函数使用内建 `operator&`; - 对对象使用 `reinterpret_cast` 到字节类型再取地址的策略(与 `constexpr` 不兼容)。 为了避免 `addressof(42)` 之类取临时对象的代码通过编译,对右值提供被删除的重载(实现 [LWG2598](https://cplusplus.github.io/LWG/issue2598))。

在 ` rb_tree:: find(const key_type& key) const ` 函数定义中: 最后一行: `return ( j == end() || key_comp_(key, value_traits::get_key(*j)) ) ? end() : j; ` 出现报错 ` error: operands to ?:...

``` using std::string; mystl::vector v3; ``` 如上代码所示,当定义v3变量时,编译器报错: ``` In template: call to function 'destroy' that is neither visible in the template definition nor found by argument-dependent lookup ``` 即在如下位置: https://github.com/Alinshans/MyTinySTL/blob/acc07e025f521a28773ff82c4d11e249911ddcb2/MyTinySTL/construct.h#L62...

template ::type = 0> hashtable(Iter first, Iter last, size_type bucket_count, const Hash& hash = Hash(), const KeyEqual& equal = KeyEqual()) :size_(mystl::distance(first, last)), mlf_(1.0f), hash_(hash), equal_(equal) { init(mystl::max(bucket_count, static_cast(mystl::distance(first, last)))); }...

// 删除 [first, last) 的元素 template typename basic_string::iterator basic_string:: erase(const_iterator first, const_iterator last) { if (first == begin() && last == end()) { clear(); return end(); } const size_type n...