C++11之 新特性概述

C++版本测试
#include <iostream>
using namespace std;

int main()
{
	cout << __cplusplus << endl;

	system("pause");
	return 0;
}
常见的新增头文件
#include <type_traits>
#include <unordered_set>
#include <forward_list>
#include <array>
#include <tuple>
#include <regex>
#include <thread>
#include <chrono>

语言重要新特性:
Variadic Templates
Move Semantics
auto
Range-base for loop
Initializer list
Lambdas

标准库重要新特性:
type_traits
Unordered容器
forward_list
array
tuple
Con-currency
Regex


Variadic Template 可以很方便的实现递归   注意需要一个递归基
#include <iostream>
#include <bitset>
using namespace std;

void print() {}

template < typename... Types>
void print(const Types& ... args)
{
	cout<<"LINE = "<<__LINE__<<", left args: "<<sizeof...(args)<<endl;
	print(args...);
}


template <typename T, typename... Types>
void print(const T& firstArg, const Types& ...args) {
	cout<<"LINE = "<<__LINE__<<", left args: "<<sizeof...(args)<<endl;
	cout<<firstArg<<endl;
	print(args...);
}

int main()
{
	print(5.0,"hello,world.",bitset<32>(16),12);
	return 0;
}

转载于:https://www.cnblogs.com/bitsstitcher/p/11532435.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值