In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to use C++ template parameters to achieve Length and TypeAt in Loki, the editor thinks it is very practical, so share it with you for reference. I hope you can get something after reading this article.
First, the simulation implementation of Length and TypeAt in the original Loki is as follows
1, template file
# ifndef _ SZYU_LOKI__#define _ SZYU_LOKI__#include # include template class TypeList {public: typedef T Head; typedef U Tail;}; class NullType # define TYPELIST_1 (type1) TypeList#define TYPELIST_2 (type1, type2) TypeList#define TYPELIST_3 (type1, type2) Type3) TypeList/* Loki Length***/template class Length Template class Length {public: enum {value = 1 + Length::value};}; template class Length {public: enum {value = 0};} / * Loki TypeAt***/template class TypeAt;template class TypeAt {public: typedef typename TypeAt::Result Result;}; template class TypeAt {public: typedef T Result;} # endif
2, test cases
/ * Author: szyu** Date: 17 / 7 / # include "loki.h" voidtest1 () {std::cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.