转自:http://www.cnblogs.com/mrblue/p/3141456.html

//array
#include <array>
void Foo1()
{
array<int, > a;
generate(a.begin(), a.end(), rand);
sort(a.begin(), a.end()); for (auto n:a)
{
cout<<n<<" ";
}
cout<<"sizeof(a) = "<<sizeof(a)<<endl;
}
//regex
#include <regex>
void Foo2()
{
if( regex_match("Hello World!", regex("Hello World!")) )
{
cout<<"Math!"<<endl;
} if (regex_search("321Hello World!765", std::regex("Hello")) )
{
cout<<"Search!"<<endl;
}
}
//thread
#include <thread>
void Foo3()
{
thread t1([]
{
for (int i = ; i < ; i++)
{
cout<<"t1:"<<i<<endl;
}
}
); thread t2([]
{
for (int i = ; i < ; i++)
{
cout<<"t2:"<<i<<endl;
}
}
); t1.join();
t2.join();
}
//future  (暂时没理解)
#include <future>
int Test(int a, int b)
{
cout<<"Test("<<a<<","<<b<<")"<<endl;
return a+b;
}
void Foo4()
{
future<int> f1 = async(Test,,);
cout<<"f1"<<endl; future<int> f2 = async(Test,,);
cout<<"f2"<<endl; future<int> f3 = async(Test,,);
cout<<"f3"<<endl; cout<<f1.get()<<endl<<f2.get()<<endl<<f3.get()<<endl;
}
//enum class
void Foo5()
{
#define MAKE_STR(s) #s
enum class Type
{
I = ,
II,
III,
IV,
V
}; if( ==(int)Type::V )
cout<<MAKE_STR(Type::V)<<endl;
}
//auto
#include <vector>
void Foo6()
{
auto a = ;
cout<<a<<endl; auto b = 20.0f;
cout<<b<<endl; auto& c = a;
c++;
cout<<a<<endl; vector<int> vec; for(int i = ; i<; i++)
{
vec.push_back(i);
} for(auto i = vec.cbegin(); i!=vec.cend(); i++)
{
cout<<*i<<endl;
} auto pF = [&c](int i)->int{ return c+=i; };
cout<<pF()<<endl;
cout<<a<<endl;
}
//lambda
#include <functional>
void Foo7()
{
int a = ;
int b = ;
function<int(int)> pA = [&a,b](int i)->int{ return a+=b+i; };
cout<<pA(a)<<endl;
cout<<a<<endl; //function<int(int)> pB = [&a,b](int i)->int{ return b+=a+i; };
//compile error : 'b': a by-value capture cannot be modified in a non-mutable lambda
cout<<b<<endl; auto pC = [&](int i)->int{ return pA(i); };
cout<<pC()<<endl;
}

最新文章

  1. java 单例
  2. dragdrop 修改版
  3. Linux 下从头再走 GTK+-3.0 (五)
  4. 理解MySQL数据库覆盖索引
  5. 模拟创建类变量,static变量加类方法,单例
  6. linux网卡设置详解
  7. centos 关闭不使用的服务
  8. OpenJudge计算概论-细菌的战争
  9. 清理vs工程文件(python2.7)
  10. VS2013 MVC Web项目使用内置的IISExpress支持局域网内部机器(手机、PC)访问、调试
  11. bzoj 1188 : [HNOI2007]分裂游戏 sg函数
  12. media queries(练习)
  13. express学习点滴- session()和cookieSession()的区别
  14. 原创-angularjs2不同组件间的通信
  15. [uwsgi]使用建议(类似最佳实践)
  16. 由odoo源不稳定想到的,一个非常简单但是有效的方式解决yum源不稳定的问题,实现无限重试
  17. ionic hidden scroll bar
  18. HOWTO For iSCSI-SCST &amp;&amp; Gentoo HOWTO For iSCSI-SCST
  19. LG3809 【模板】后缀排序
  20. .NET跨平台实践:用C#开发Linux守护进程-Daemon

热门文章

  1. Hadoop编码解码【压缩解压缩】机制具体解释(1)
  2. 地形混合shader
  3. DP(正解完全背包+容斥)
  4. shu7-19【背包和母函数练习】
  5. PHP自定义函数: 下载远程文件
  6. 添加启动项及常用Windows+R
  7. 3.16课&#183;&#183;&#183;&#183;&#183;&#183;&#183;&#183;&#183;C#小结
  8. 装箱问题【STL】
  9. jenkins实现自动部署
  10. 《程序员代码面试指南》第三章 二叉树问题 Tarjan算法与并查集解决二叉树节点间最近公共祖先的批量查询问题