- 博客(5)
- 收藏
- 关注
原创 c++11 智能指针
share_ptr首先来看shared_ptr,先贴一小部分vs2013里的实现// TEMPLATE CLASS shared_ptr template<class _Ty> class shared_ptr : public _Ptr_base<_Ty> { // class for reference counted resource management public: typede
2017-06-11 17:42:30
389
原创 c++类实例对象内存布局
下面对几种情况分别讨论单一简单类class father { public: father(){}; ~father(){}; public: void doSomething(){}; static void sDoSomething(){}; private: char a; int b; static int c; };对他进行编译,我们
2017-06-04 20:14:24
634
原创 定位(placement) new
在c++中使用new表达式时实际是执行了3步 1. new表达式调用一个名为 operator new(或者 operator new[])的标准库函数。该函数分配一块足够大的、原始的、未命名的内存空间以便存储特定类型的对象(或者对象数组) 2. 编译器运行相应的构造函数以构造这些对象,并为其传入初始值 3. 对象被分配了空间并构造完成,返回一个只想该对象的指针使用delete表达式时实际执行
2017-05-14 22:55:21
371
原创 c++11 union
虽然c++11标准允许union中含有定义了构造函数或拷贝控制成员的类类型成员,然而在vs2013中仍然不允许中union含有。看来对这个的需求优先级很低,先搁置,有待考察。
2017-05-14 15:24:05
389
原创 c++11 生产者和消费者模型
一段简单的事例代码#include <iostream> #include <thread> #include <mutex> #include <condition_variable> int i = 0; std::mutex mtx; std::condition_variable condition_in, condition_out; void in(int id) { while
2017-05-07 20:43:31
528
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅