代码拉取完成,页面将自动刷新
//
// Created by light on 19-11-3.
//
#include <iostream>
#include <vector>
using namespace std;
// 第一种使用
// type alias
// 等价于typedef void(*func)(int, int);
using fun=void (*)(int, int);
void example(int, int) {}
// 第二种使用
template<typename T>
struct Container {
using value_type=T; // 等价于typedef T value_type;
};
template<typename Cn>
void func2(const Cn &cn) {
typename Cn::value_type n;
}
// 第三种使用
// alias template
template<typename CharT>
using string=basic_string<CharT, char_traits<CharT>>;
// 等价于 typedef basic_string<char> string;
// 综上:type alias等价于typedef,没有什么不同
// using 的所有用法拓展如下:
// 1.using-directives
// using namespace std; or using std::cout;
// 2. using-declaration
// protected:
// using _Base::_M_alloc;
// 3.c++2.0特性 type alias and alias template
int main() {
fun fn = example; // 函数指针
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。