- Expert C++
- Vardan Grigoryan Shunguang Wu
- 135字
- 2021-06-24 16:33:52
Concepts
Concepts are a major feature in C++20 that provides a set of requirements for types. The basic idea behind concepts is the compile-time validation of template arguments. For example, to specify that the template argument must have a default constructor, we use the default_constructible concept in the following way:
template <default_constructible T>
void make_T() { return T(); }
In the preceding code, we missed the typename keyword. Instead, we set a concept that describes the T parameter of the template function.
We can say that concepts are types that describe other types – meta-types, so to speak. They allow the compile-time validation of template parameters along with a function invocation based on type properties. We will discuss concepts in detail in Chapter 3, Details of Object-Oriented Programming, and Chapter 4, Understanding and Designing Templates.
- Python科學計算(第2版)
- Monkey Game Development:Beginner's Guide
- C/C++算法從菜鳥到達人
- HTML5 移動Web開發從入門到精通(微課精編版)
- Java開發入行真功夫
- Mastering C# Concurrency
- C++ 從入門到項目實踐(超值版)
- 用戶體驗增長:數字化·智能化·綠色化
- 劍指MySQL:架構、調優與運維
- Multithreading in C# 5.0 Cookbook
- Tableau 10 Bootcamp
- OpenMP核心技術指南
- Learning JavaScript Data Structures and Algorithms(Second Edition)
- Lift Application Development Cookbook
- Go語言從入門到精通