|
04 2020 档案
摘要:7.2 Passing by Reference 7.2 按引用传递 Now let’s discuss the different flavors of passing by reference. In all cases, no copy gets created (because the pa
阅读全文
摘要:Chapter 7: By Value or by Reference? 第7章 按值传递或按引用传递? Since the beginning, C++ has provided call-by-value and call-by-reference, and it is not always e
阅读全文
摘要:6.5 Using Concepts to Simplify enable_if<> Expressions 6.5 使用Concepts简化enable_if<>表达式 Even when using alias templates, the enable_if syntax is pretty
阅读全文
摘要:6.4 Using enable_if<> 6.4 使用enable_if<> We can use enable_if<> to solve our problem with the constructor template introduced in Section 6.2 on page 95
阅读全文
摘要:6.3 Disable Templates with enable_if<> 6.3 使用enable_if<>来禁用模板 Since C++11, the C++ standard library provides a helper template std::enable_if<> to ign
阅读全文
摘要:6.2 Special Member Function Templates 6.2 特殊成员函数模板 Member function templates can also be used as special member functions, including as a constructor,
阅读全文
摘要:Chapter 6: Move Semantics and enable_if<> 第6章 移动语义和enable_if<> One of the most prominent features C++11 introduced was move semantics. You can use it
阅读全文
摘要:5.7 Template Template Parameters 5.7 模板模板参数 It can be useful to allow a template parameter itself to be a class template. Again, our stack class templ
阅读全文
摘要:5.6 Variable Templates 5.6 变量模板 Since C++14, variables also can be parameterized by a specific type. Such a thing is called a variable template. 从C++1
阅读全文
摘要:5.5 Member Templates 5.5 成员模板 Class members can also be templates. This is possible for both nested classes and member functions. The application and
阅读全文
摘要:5.4 Templates for Raw Arrays and String Literals 5.4 原生数组和字符串字面量的模板 When passing raw arrays or string literals to templates, some care has to be taken
阅读全文
摘要:5.3 Using this-> 5.3 this->的使用 For class templates with base classes that depend on template parameters, using a name x by itself is not always equiva
阅读全文
摘要:5.2 Zero Initialization 5.2 零初始化 For fundamental types such as int, double, or pointer types, there is no default constructor that initializes them wi
阅读全文
摘要:Chapter 5:Tricky Basics 第5章 技巧性基础知识 This chapter covers some further basic aspects of templates that are relevant to the practical use of templates: a
阅读全文
摘要:4.3 Application of Variadic Templates 4.3 可变参数模板的应用 Variadic templates play an important role when implementing generic libraries, such as the C++ sta
阅读全文
摘要:4.2 Fold Expressions 4.2 折叠表达式 Since C++17, there is a feature to compute the result of using a binary operator over all the arguments of a parameter
阅读全文
摘要:Chapter 4:Variadic Templates 第4章 可变参数模板 Since C++11, templates can have parameters that accept a variable number of template arguments. This feature a
阅读全文
摘要:3.4 Template Parameter Type auto 3.4 模板参数类型auto Since C++17, you can define a nontype template parameter to generically accept any type that is allowe
阅读全文
摘要:3.3 Restrictions for Nontype Template Parameters 3.3 非类型模板参数的限制 Note that nontype template parameters carry some restrictions. In general, they can be
阅读全文
摘要:3.2 Nontype Function Template Parameters 3.2 非类型函数模板参数 You can also define nontype parameters for function templates. For example, the following funct
阅读全文
摘要:Chapter 3: Nontype Template Parameters 第3章 非类型模板参数 For function and class templates, template parameters don’t have to be types. They can also be ordi
阅读全文
摘要:2.11 Summary 2.11 小结 • A class template is a class that is implemented with one or more type parameters left open. 类模板是具有如下性质的类:在类的实现中,可以有一个或多个类型参数还没有
阅读全文
摘要:2.10 Templatized Aggregates 2.10 模板化聚合类 Aggregate classes (classes/structs with no user-provided, explicit, or inherited constructors, no private or p
阅读全文
摘要:2.9 Class Template Argument Deduction 2.9 类模板参数推导 Until C++17, you always had to pass all template parameter types to class templates(unless they have
阅读全文
摘要:2.8 Type Aliases 2.8 类型别名 You can make using a class template more convenient by defining a new name for the whole type. 通过为整个类型定义一个新的名字,可以让类模板的使用更加方便
阅读全文
摘要:2.7 Default Class Template Arguments 2.7 默认类模板实参 As for function templates, you can define default values for class template parameters. For example,
阅读全文
摘要:2.6 Partial Specialization 2.6 偏特化 Class templates can be partially specialized. You can provide special implementations for particular circumstances,
阅读全文
摘要:2.5 Specializations of Class Templates 2.5 类模板的特化 You can specialize a class template for certain template arguments. Similar to the overloading of fu
阅读全文
摘要:2.4 Friends 2.4 友元 Instead of printing the stack contents with printOn() it is better to implement toperator<< for the stack. However, as usual operat
阅读全文
摘要:2.3 Partial Usage of Class Templates 2.3 类模板的局部使用 A class template usually applies multiple operations on the template arguments it is instantiated fo
阅读全文
摘要:2.2 Use of Class Template Stack 2.2 类模板Stack的使用 To use an object of a class template, until C++17 you must always specify the template arguments expli
阅读全文
摘要:Chapter 2: Class Templates 第2章 类模板 Similar to functions, classes can also be parameterized with one or more types. Container classes, which are used t
阅读全文
摘要:1.6 But, Shouldn’t We …? 1.6 但是,难道我们不应该…? Probably, even these simple function template examples might raise further questions. Three questions are pr
阅读全文
摘要:1.5 Overloading Function Templates 1.5 重载函数模板 Like ordinary functions, function templates can be overloaded. That is, you can have different function
阅读全文
摘要:1.4 Default Template Arguments 1.4 默认模板参数 You can also define default values for template parameters. These values are called default template argumen
阅读全文
摘要:1.3 Multiple Template Parameters 1.3 多模板参数 As we have seen so far, function templates have two distinct sets of parameters: 到目前为止,我们己经看到函数模板具有两组不同的参数:
阅读全文
摘要:1.2 Template Argument Deduction 1.2 模板参数的推导 When we call a function template such as max() for some arguments, the template parameters are determined
阅读全文
摘要:Chapter 1: Function Templates 第1章 函数模板 This chapter introduces function templates. Function templates are functions that are parameterized so that the
阅读全文
|