- 博客(4)
- 收藏
- 关注
原创 c++11 std::future获取异步线程函数的返回值
1 #include<iostream> 2 #include<future> 3 #include<thread> 4 #include<chrono> 5 6 int func(int arv) 7 { 8 std::this_thread::sleep_for(std::chrono::seconds(...
2019-05-19 14:52:03
2251
原创 lambda的链式调用 c++11实现
#include#include#includetemplateclass Task;templateclass Task{public: Task(std::function&& f):m_fn(std::move(f)){} Task(std::function& f):m_fn(f){} R
2018-01-14 15:20:34
631
原创 创建对象的工厂函数 c++11实现
在C++11中用可变模板参数可以消除重复,同时去掉参数个数的限制,代码很简洁: template T* Instance(Args... args) { return new T(args...); }在上面的实现代码T* Instance(Args... args)中, Args是值拷贝的,存在性能损耗,可以通过完美转发来消除损耗,优化后的代码如
2018-01-07 14:47:55
1813
转载 C++ std::string用法总结
转自:http://blog.youkuaiyun.com/lanyzh0909/article/details/6957649在平常工作中经常用到了string类,本人记忆了不好用到了的时候经常要去查询。在网上摘抄一下总结一下,为以后的查询方便:string类的构造函数:string(const char *s); //用c字符串s初始化string(int n,cha
2017-04-07 22:38:38
711
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人