
STL源码剖析学习
如题
kakakadela
这个作者很懒,什么都没留下…
展开
-
空间配置器
c++标准库在许多地方采用特殊对象处理内存的分配和回收,这种对象称为分配器或者配置器,最初配置器是作为STL的一部分引入,当前作为运用某种内存模型方案的基础。c++标准库提供了默认的分配器namespace std { template<class T>class allocator;}举例:vector的定义namespace std { template<typename T,typename Allocator=allcator<T>...原创 2020-05-12 01:06:56 · 151 阅读 · 0 评论 -
函数调用操作符()重载
即理解为仿函数#include <iostream>using namespace std;template<class T>struct Plus{ T operator()(const T& x, const T& y) { return x + y; }};template<class T>struct Minus{ T operator()(const T& x, cons...原创 2020-05-08 22:50:54 · 174 阅读 · 0 评论 -
函数返回值常量
const修饰函数返回值注:此处只讨论语法,实用性暂不考虑返回非常量复杂类型的值则可以为左值,返回为int,即使不是const也不可以为左值,返回类或者结构体可以为左值(此处可能是因为复杂类型有默认的赋值函数)不可为左值,可以赋值给变量,不可赋值给非常量引用举例:#include <iostream>#include <vector>#include <string>using namespace std;template<class原创 2020-05-08 22:41:27 · 1031 阅读 · 0 评论 -
静态常量成员变量的初始化
static const修饰的成员变量只有整数类型的可以在类内初始化,其他不行#include<iostream>#include<algorithm>#include<vector>using namespace std;class test{public: static const double a = 2.0; //编译不通过 static const float b = 2.0; //编译不通过 static const c...原创 2020-05-08 19:23:17 · 522 阅读 · 0 评论 -
临时对象
一种无名对象,制造临时对象的方法在类型别名后边加一对小括号,写入初值,如:int(8),相当 于调用类型的的构造函数,但不指定对象名主要引用场景是应用于仿函数与算法的搭配举例:#include<iostream>#include<algorithm>#include<vector>using namespace std;template<class T>class test{ T a;public: test<T...原创 2020-05-08 18:43:34 · 128 阅读 · 0 评论 -
STL六大组件
1.容器2.算法3.迭代器4.仿函数5.配接器6.配置器原创 2020-05-08 18:09:30 · 106 阅读 · 0 评论 -
STL源码剖析学习笔记
记两次内部转岗面试之后,对c++基础知识了解太少,尝试写博文记笔记来提升自己的c++基础,先从c++primer和stl源码解析开始学起,夯实基础原创 2020-04-22 21:02:55 · 127 阅读 · 0 评论