- 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.
- 老“碼”識途
- R大數據分析實用指南
- Statistical Application Development with R and Python(Second Edition)
- Visual Basic程序設計習題與上機實踐
- Python Machine Learning Blueprints:Intuitive data projects you can relate to
- Learning iOS Security
- 虛擬現實建模與編程(SketchUp+OSG開發技術)
- 網頁設計與制作
- MySQL從入門到精通
- Learning Perforce SCM
- Pandas入門與實戰應用:基于Python的數據分析與處理
- Illustrator CS6中文版應用教程(第二版)
- 三步學Python
- Scratch編程入門與算法進階(第2版)
- Learning Adobe Muse