类型擦除示例

#include <mutex> #include <queue> #include <memory> #include <string> #inclu…

限制对象在堆上创建

struct Example{ class token{ private: token(){} friend Example; }; …

hierarchical mutex

class hierarchical_mutex { std::mutex internal_mutex; unsigned long const hierarchy_value; un…

std::forward demo

#include <iostream> using namespace std; // 接收左值的函数 f() template<typename T> void f(T &…

实现c++ 不可继承类:FinallyClass

#include <iostream> template<typename T> class MakeFinally { private: MakeFinally()…

达夫设备,循环展开

#include "stdio.h" #include "string.h" void Strncpy(char *to, const char *from…

【Google面试题】有四个线程1、2、3、4同步写入数据…C++11实现

Google面试题 有四个线程1、2、3、4。线程1的功能就是输出1,线程2的功能就是输出2,以此类推…现在有四个文件ABCD。初始都为空。现要让四个文件呈如下格式: A:1 2 3 4 1 2… …

实现两个线程交替计算合数 or 素数

题目:实现两个线程交替计算1-10000内的合数 or 素数 // method 1 #include <thread> #include <cmath> #includ…

模版检查类中是否有某个成员函数

//例子1 template<typename T> struct has_no_destroy { template <typename C> static char t…

zsh theme

# vim:ft=zsh ts=2 sw=2 sts=2 # # agnoster's Theme - https://gist.github.com/3712874 # A Powerlin…