
c++
时光在身后挡住去路
这个作者很懒,什么都没留下…
展开
-
C++的锁锁锁锁锁锁锁锁锁锁锁锁
std::lock_guard std::lock_guard 在构造函数中进行加锁,析构函数中进行解锁。 std::unique_lock 类 unique_lock 是通用互斥包装器,允许延迟锁定、锁定的有时限尝试、递归锁定、所有权转移和与条件变量一同使用。 unique_lock比lock_guard使用更加灵活,功能更加强大。 使用unique_lock需要付出更多的时间、性能成本。 st...原创 2019-11-18 16:39:44 · 523 阅读 · 0 评论 -
c++ 关键字 decltype
decltype简介 我们之前使用的typeid运算符来查询一个变量的类型,这种类型查询在运行时进行。RTTI机制为每一个类型产生一个type_info类型的数据,而typeid查询返回的变量相应type_info数据,通过name成员函数返回类型的名称。同时在C++11中typeid还提供了hash_code这个成员函数,用于返回类型的唯一哈希值。RTTI会导致运行时效率降低,且在泛型编程转载 2017-02-11 10:55:56 · 302 阅读 · 0 评论 -
c++: Difference between member and non member functions
There are several differences between a member function (which I will now call method) and a free function (which I will now call function). First, let's just state that they are not so different.转载 2017-02-12 12:50:18 · 500 阅读 · 0 评论 -
std::future,std::promise,std::packaged_task,std::sync用法
用C++11的std::async代替线程的创建 c++11中增加了线程,使得我们可以非常方便的创建线程,它的基本用法是这样的: void f(int n); std::thread t(f, n + 1); t.join(); 但是线程毕竟是属于比较低层次的东西,有时候使用有些不便,比如我希望获取线程函数的返回结果的时候,我就不能直接通过thread.join()得到结果,这时就必须定义一个变...转载 2019-04-04 11:16:38 · 971 阅读 · 1 评论 -
gperftool以lines的尺度进行profiling时行号为问好??:0的解决方法
gperftool以lines的尺度进行profiling时行号为问好??:0的解决方法 原因是由于缺少了调试信息,可以使用gdb进行运行,gdb会报错如下。 [Inferior 1 (process 27033) exited normally] Missing separate debuginfos, use: debuginfo-install gperftools-libs-2.4-8.e...原创 2019-06-26 16:30:18 · 401 阅读 · 0 评论