学习让我快乐

争于世, 不争于势;简洁, 高效, 赏心悦目

FBString 源码分析

COW 机制 首先 COW 机制是有一点优点的,主要是大尺度字符串下,如: { std::string str (10 * 1024 * 1024,'c'); std::string str1 = str; PP_QQ_LOG_D("std::string: %s",str1.data() == str.data() ? "采用 COW" ...

总在需要的时候使用 noexcept

总是在需要的时候使用noexcept(true)来标识你的函数.这样可能会提升性能! 不使用noexcept(true)来标识函数 #include <stdio.h> #include <vector> struct X { X() = default; X(const ...

C++11-原子操作

基本概念 memory location memory location;或者是 scalar type 类型对象,或者是具有非0宽的位域最长序列. 多个线程同时读写多个 memory location 是线程安全的;多个线程以只读的方式访问同一 memory location 也是线程安全.仅当多个线程以同时以读写的方式访问同一 memory location(并且没有做任何...

C++并发编程实践

同步并发操作

等待未来事件 现实世界中的需求 未来事件;(这是我瞎诌的一个概念),在未来某个时间点发生;并且只会发生一次;而且发生时可能会携带数据, 也可能不会. 在编程中经常会碰到,一个线程需要等待未来事件发生后才能继续执行;或者多个线程等待同一个未来事件发生. C++ future,shared_future 设施 future<T>,shared_future<...

C++11 标准阅读

Storage Class Specifiers

前言 根据storage_duration总结而来. Storage Class Specifiers 是声明语法的一部分;指定了标识符2个独立的属性:storage duration;linkage; static;指定了标识符具有 static/thread storage duration;并且具有 internal linkage 属性. extern;指定了...