当前位置: 首页 > news >正文

免费网站入口网站免费进网站建设的培训班

免费网站入口网站免费进,网站建设的培训班,中国设计网址,wordpress汉化安装C 实现一个type list 模板#xff0c;在编译期计算。这个type list主要有构造#xff0c;列表头类型#xff0c;列表尾类型#xff0c;concat操作#xff0c;去除列表元素重复#xff0c;获取指定元素#xff0c;删除指定元素的操作。实现代码贴在下面#xff1a; #pr…C 实现一个type list 模板在编译期计算。这个type list主要有构造列表头类型列表尾类型concat操作去除列表元素重复获取指定元素删除指定元素的操作。实现代码贴在下面 #pragma once #include iostream #include typeinfonamespace type_list {// Step 1: 基础类型列表定义// 定义空列表template typename ...Typesstruct list {};// 非空列表的递归定义template typename Type, typename ...Typesstruct listType, Types... {using head Type;using tail listTypes...;};// 定义空列表类型using empty_list list;// Step 2: 获取列表头部类型template typename TypeListusing head_t typename TypeList::head;// 获取列表尾部类型template typename TypeListusing tail_t typename TypeList::tail;// 构造新列表template typename Head, typename Tailstruct construct;template typename Head, typename Tailusing construct_t typename constructHead, Tail::type;template typename Head, typename ...Typesstruct constructHead, listTypes... {using type listHead, Types...;};///templatetypename TypeListstruct size;// 模板辅助类templatetypename TypeListconstexpr size_t size_v sizeTypeList::value;//size的模板特化继承了std::integral_constanttemplatetypename...Typesstruct sizelistTypes... : std::integral_constantstd::size_t, sizeof...(Types) {};templateclass TypeListconstexpr bool empty_v (size_vTypeList 0);templateclass TypeListstruct empty : std::bool_constantempty_vTypeList {};templateclass TypeListconstexpr bool empty_s emptyTypeList::value;/// 查找模板的制定索引的value//声明一个模板;templatestd::size_t Index, class TypeListstruct get;templatestd::size_t Index, class TypeListusing get_t typename getIndex, TypeList::type;templatestd::size_t Index, class TypeListstruct get {using type get_tIndex - 1, tail_tTypeList;};templateclass TypeListstruct get0, TypeList {using type head_tTypeList;};/// concattemplatetypename TypeList1, typename TypeList2class concat;templatetypename T, typename Uusing concat_t typename concatT, U::type;templatetypename ...T, typename ...Uclass concatlistT..., listU... {public:using type listT..., U...;};// delete specific typetemplatetypename TypeList, typename Typeclass remove_all;templatetypename TypeList, typename Typeusing remove_all_t typename remove_allTypeList, Type::type;templatetypename TypeList, typename Typeclass remove_all {public:using head head_tTypeList;using tail tail_tTypeList;using clean_tail remove_all_ttail, Type;using type std::conditional_tstd::is_same_vhead, Type, clean_tail, construct_thead, clean_tail;};templatetypename Typeclass remove_allempty_list, Type {public:using type empty_list;};// get the last typetemplatetypename TypeListclass last;templatetypename TypeListusing last_t typename lastTypeList::type;templatetypename TypeListclass last {public:using type last_ttail_tTypeList;};// 递归终止templatetypename Typeclass lastlistType {public:using type Type;};// distinct list typetemplatetypename TypeListclass distinct;templatetypename TypeListusing distinct_t typename distinctTypeList::type;template typename TypeListclass distinct{public:using type construct_thead_tTypeList,distinct_tremove_all_ttail_tTypeList, head_tTypeList;};// 递归终止template struct distinctempty_list {using type empty_list;};// print listtemplatetypename Tvoid print_type() {int status;std::cout typeid(T).name() std::endl;}// 打印类型列表template typename TypeListstruct print_list;template typename TypeListvoid print_list_func() {print_listTypeList::print();}// 主模板递归地打印类型列表template typename TypeListstruct print_list {static void print() {print_typehead_tTypeList();print_list_functail_tTypeList();}};// 终止递归的特化版本template struct print_listempty_list {static void print() {// 空列表不打印任何内容}};} // namespace type_list测试代码 #pragma once#include type_list.h #include iostreamusing namespace std;void test_type_list() {//1.define listusing MyList type_list::listint, double, char;using AnotherList type_list::listfloat, int;using EmptyList type_list::list;//2. get the head and tail type of listusing MyListHead type_list::head_tMyList;using MyListTail type_list::tail_tMyList;static_assert(std::is_same_vMyList::tail, type_list::listdouble,char, MyList head shoud be int);static_assert(std::is_same_vMyListTail, type_list::listdouble, char, MyList head shoud be int);static_assert(std::is_same_vMyListHead, int, MyList head shoud be int);static_assert(std::is_same_vMyList::head, int, MyList head shoud be int);//3. get list sizeconstexpr std::size_t listSize type_list::size_vMyList;std::cout listSize std::endl;// 4. emptystatic_assert(type_list::empty_sEmptyList, is empty);static_assert(type_list::empty_vEmptyList, is empty);// 5. get index posusing FirstType type_list::get_t1, MyList;static_assert(std::is_same_vFirstType, double, not equal);// 6.concat listusing ConcatList type_list::concat_tMyList, AnotherList;using ConcatListHead type_list::head_tConcatList;static_assert(std::is_same_vConcatListHead, int, head should be int);static_assert(std::is_same_vConcatList::head, int, head should be int);constexpr std::size_t concat_list_size type_list::size_vConcatList;cout concat_list_size : concat_list_size endl;// 6.delete list typeusing RemoveIntList type_list::remove_allMyList, int;static_assert(std::is_same_vtype_list::head_tRemoveIntList, int, the list head shoud not be int);// 6.delete list typeusing LastType type_list::last_tMyList;static_assert(std::is_same_vLastType, char, the last type should be char);// distinct list typeusing RepeatList type_list::listint, double, char, int, double, char, int,int,int;using DistType type_list::distinct_tRepeatList;std::cout -------------------------- endl;type_list::print_list_funcRepeatList();std::cout -------------------------- endl;type_list::print_list_funcDistType();std::cout -------------------------- endl;}
http://www.w-s-a.com/news/144881/

相关文章:

  • 软件发布网站源码中国企业公示信息网
  • flash 的网站网站型销售怎么做
  • 营销型网站单页网站的域名和密码
  • 建网站保定seo自动发布外链工具
  • 做公众号关注网站做课件用这15大网站
  • 怎么制作公司自己网站店铺设计软件手机版
  • 深圳网站关键词优化公司哪家好怎么选择锦州网站建设
  • 标准网站优势项目合作网站
  • 无人机东莞网站建设wordpress站群管理破解版
  • 深圳企业官网网站建设教育培训学校
  • 医疗网站建设及优化西安网站建设开发公司
  • 网站建设详细流程ydg wordpress theme
  • 湖北黄石域名注册网站建设编程网站项目做哪个比较好
  • 旺道网站排名优化咸阳建设网站
  • 建设一个类似淘宝的网站律师做推广宣传的网站
  • 东阳网站建设方案网站建设asp
  • 模板网站建设一条龙平面设计师招聘信息
  • 制作一个网站流程企业建设网站的母的
  • 九州建网站网页游戏平台代理
  • 培训课程网站网上下载的网站模板怎么用
  • 重庆山艺网站建设塘厦理工学校
  • 做网站的人叫什么软件玩具网站设计
  • 网站说服力营销型网站策划 pdf深圳有什么公司名称
  • 做物流的可以在那些网站找客户男生晚上正能量你懂我意思
  • 宁德市城乡住房建设厅网站教育机构logo
  • 做定制网站价格有网站了怎么做app
  • 做网站和制作网页的区别北京朝阳区最好的小区
  • 网站策划 ppt北京装修公司排名推荐
  • 郑州网站建设公司哪家专业好如何注册一家公司
  • 证券投资网站做哪些内容滨州论坛网站建设