浅墨浓香

想要天亮进城,就得天黑赶路。

导航

上一页 1 2 3 4 5 6 7 ··· 38 下一页

2020年4月15日

摘要: 2.6 Partial Specialization 2.6 偏特化 Class templates can be partially specialized. You can provide special implementations for particular circumstances, 阅读全文

posted @ 2020-04-15 22:32 浅墨浓香 阅读(363) 评论(0) 推荐(0) 编辑

摘要: 2.5 Specializations of Class Templates 2.5 类模板的特化 You can specialize a class template for certain template arguments. Similar to the overloading of fu 阅读全文

posted @ 2020-04-15 22:26 浅墨浓香 阅读(618) 评论(0) 推荐(0) 编辑

摘要: 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 阅读全文

posted @ 2020-04-15 22:23 浅墨浓香 阅读(240) 评论(0) 推荐(0) 编辑

摘要: 2.3 Partial Usage of Class Templates 2.3 类模板的局部使用 A class template usually applies multiple operations on the template arguments it is instantiated fo 阅读全文

posted @ 2020-04-15 22:19 浅墨浓香 阅读(255) 评论(0) 推荐(0) 编辑

摘要: 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 阅读全文

posted @ 2020-04-15 22:16 浅墨浓香 阅读(295) 评论(0) 推荐(1) 编辑

2020年4月14日

摘要: Chapter 2: Class Templates 第2章 类模板 Similar to functions, classes can also be parameterized with one or more types. Container classes, which are used t 阅读全文

posted @ 2020-04-14 11:33 浅墨浓香 阅读(479) 评论(0) 推荐(0) 编辑

摘要: 1.6 But, Shouldn’t We …? 1.6 但是,难道我们不应该…? Probably, even these simple function template examples might raise further questions. Three questions are pr 阅读全文

posted @ 2020-04-14 11:21 浅墨浓香 阅读(323) 评论(0) 推荐(0) 编辑

摘要: 1.5 Overloading Function Templates 1.5 重载函数模板 Like ordinary functions, function templates can be overloaded. That is, you can have different function 阅读全文

posted @ 2020-04-14 11:16 浅墨浓香 阅读(474) 评论(0) 推荐(1) 编辑

摘要: 1.4 Default Template Arguments 1.4 默认模板参数 You can also define default values for template parameters. These values are called default template argumen 阅读全文

posted @ 2020-04-14 11:07 浅墨浓香 阅读(396) 评论(0) 推荐(0) 编辑

摘要: 1.3 Multiple Template Parameters 1.3 多模板参数 As we have seen so far, function templates have two distinct sets of parameters: 到目前为止,我们己经看到函数模板具有两组不同的参数: 阅读全文

posted @ 2020-04-14 11:01 浅墨浓香 阅读(1105) 评论(0) 推荐(0) 编辑

摘要: 1.2 Template Argument Deduction 1.2 模板参数的推导 When we call a function template such as max() for some arguments, the template parameters are determined 阅读全文

posted @ 2020-04-14 10:53 浅墨浓香 阅读(639) 评论(0) 推荐(2) 编辑

摘要: Chapter 1: Function Templates 第1章 函数模板 This chapter introduces function templates. Function templates are functions that are parameterized so that the 阅读全文

posted @ 2020-04-14 10:47 浅墨浓香 阅读(711) 评论(0) 推荐(1) 编辑

2019年11月30日

摘要: 一. std::atomic_flag和std::atomic (一)std::atomic_flag 1. std::atomic_flag是一个bool类型的原子变量,它有两个状态set和clear,对应着flag为true和false。 2. std::atomic_flag使用前必须被ATO 阅读全文

posted @ 2019-11-30 23:01 浅墨浓香 阅读(13566) 评论(1) 推荐(1) 编辑

2019年11月20日

摘要: 一. 条件变量 (一)条件变量概述 多线程访问一个共享资源(或称临界区),不仅需要用互斥锁实现独享访问避免并发错误,在获得互斥锁进入临界区后,还需检查特定条件是否成立。当某个线程修改测试条件后,将通知其它正在等待条件的线程继续往下执行。 1. wait线程:如果不满足该条件,拥有条件变量的wait线 阅读全文

posted @ 2019-11-20 01:29 浅墨浓香 阅读(1579) 评论(0) 推荐(0) 编辑

2019年11月17日

摘要: 一. 互斥量 (一)Mutex系列类 1. std::mutex:独占的互斥量,不能递归使用。 2. std::recursive_mutex:递归互斥量。允许同一线程多次获得该互斥锁,可以用来解决同一线程需要多次获取互斥量时死锁的问题。 3. std::time_mutex和std::recurs 阅读全文

posted @ 2019-11-17 14:07 浅墨浓香 阅读(2156) 评论(0) 推荐(0) 编辑

2019年11月7日

摘要: 一. std::promise和std::package_task (一)共享状态、提供者和管理者 // CLASS TEMPLATE _Promise template <class _Ty> class _Promise { // class that implements core of pr 阅读全文

posted @ 2019-11-07 20:57 浅墨浓香 阅读(1156) 评论(0) 推荐(0) 编辑

2019年10月26日

摘要: 一. “共享状态” (一)“共享状态”对象 1. 用于保存线程函数及其参数、返回值以及新线程状态等信息。该对象通常创建在堆上,由std::async、std::promise和std::package_task等提供(Provider),并交由future/shared_future管理。 2. P 阅读全文

posted @ 2019-10-26 16:05 浅墨浓香 阅读(1411) 评论(0) 推荐(0) 编辑

2019年10月23日

摘要: 一. std::async函数模板 (一)std::async和std::thread的区别 1. 两者最明显的区别在于async采用默认启动策略时并不一定创建新的线程。如果系统资源紧张,那么std::thread创建线程可能失败,系统报告异常,整个程序可能崩溃。而std::async一般则不会,它 阅读全文

posted @ 2019-10-23 17:41 浅墨浓香 阅读(2592) 评论(0) 推荐(1) 编辑

2019年10月12日

摘要: 一. 线程的等待与分离 (一)join和detach函数 1. 线程等待:join() (1)等待子线程结束,调用线程处于阻塞模式。 (2)join()执行完成之后,底层线程id被设置为0,即joinable()变为false。同时会清理线程相关的存储部分, 这样 std::thread 对象将不再 阅读全文

posted @ 2019-10-12 10:34 浅墨浓香 阅读(6158) 评论(0) 推荐(1) 编辑

2019年10月8日

摘要: 一. std::thread类 (一)thread类摘要及分析 class thread { // class for observing and managing threads public: class id; using native_handle_type = void*; thread( 阅读全文

posted @ 2019-10-08 09:33 浅墨浓香 阅读(10862) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 ··· 38 下一页