shared_ptr shared std ptr
Incomplete types and shared_ptr / unique_ptr
If the object being deleted has incomplete class type at the point of deletion and the complete class has a non-trivial destructor or a deallocation f ......
C++ Windows.h max宏与std::max冲突问题解决
C语言引入的宏支持了一定程度的元编程,但它仅仅是简单的字符串替换,这种“六亲不认”的操作很容易导致一些编译错误。 这篇文章介绍了一种场景:项目同时引入了老的C头文件,里面用宏定义了一些宏函数;还引入了C++的头文件,里面用其他方式定义了一些同名函数。具体到问题本身,这个老的头文件是Windows.h ......
std::atomic store load std::memory_order_seq_cst
#include <atomic> #include <chrono> #include <ctime> #include <fstream> #include <future> #include <iomanip> #include <iostream> #include <map> #inclu ......
cmake设置gcc将shared library 改为生成 executeable
## 前文 - ubuntu下, 同一份代码, 使用 `gcc` 和 `clang` 编译结果不相同。 gcc 编译结果, 生成的程序为 `type` 为 shared libary, 而 `clang` 编译生成的程序的type 为 `executeable`. ## 解决方案 - 为`cmake ......
关于std::vector<bool>的一些细节
std::vector<T>是我们经常用到的STL容器,但是std::vector<bool>比较特殊,其特殊之处在于operato[]返回的元素类型是std::vector<bool>::reference(一个嵌套于std::vector<bool>中的类)。 std::vector<bool> ......
[ERROR] Can't find error-message file '/data/mysql/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
1. MySQL5.7.21启动时报错: [ERROR] Can't find error-message file '/data/mysql/3307/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir ......
error while loading shared libraries: libreadline.so.5: cannot open shared object file:
错误信息: ftp: error while loading shared libraries: libreadline.so.5: cannot open shared object file: No such file or directory 解决办法: yum install -y read ......
C++智能指针:weak_ptr
weak_ptr虽然是智能指针,但实际上是作为shared_ptr的辅助指针使用。weak_ptr通常不单独使用,一般用于查看对应的shared_ptr的信息。weak_ptr没有重载*,->等指针运算符。weak_ptr对象不会影响shared_ptr对象的引用计数。 #include<iostr ......
C++智能指针:shared_ptr、unique_ptr
C++内存资源管理不当。比如:(1) 有些内存资源已经被释放,但指向它的指针并没有改变指向(成为了野指针),并且后续还在使用;(2) 有些内存资源已经被释放,后期又试图再释放一次(重复释放同一块内存会导致程序运行崩溃);(3) 没有及时释放不再使用的内存资源,造成内存泄漏,程序占用的内存资源越来越多 ......
std::vector push_back 基本数据类型、cv::Mat
[全局]std::vector存储[局部作用域]的基本数据类型:在push_back的时候,会将局部数据的值拷贝到vector的指定的内存区域,之后局部数据在生命周期结束后释放。【参考】(9条消息) 关于全局std::vector和局部变量存储的总结_局部变量vector_疯花正猫的博客-CSDN博 ......
c++ 智能指针std::shared_ptr
c++11中常用的智能指针有shared_ptr,unique_ptr与weak_ptr。 unique_ptr是独占型指针,其计数永远为1,无拷贝构造函数,但可以使用std::move转移资源所有权。 weak_ptr没有资源所有权,一般用来辅助shared_ptr使用,多使用于多线程,循环等场景 ......
关于 using namespace std
我刚接触c++,写Hello, World 是这个样子的 #include <bits/stdc++.h> using namespace std; int main() { cout << "Hello, World" << endl; return 0; } 但是一直令我不解的是 using n ......
[犯病记] DPDK报错Symbol `rte_eth_devices' has different size in shared object, consider re-linking
# [犯病记] DPDK报错Symbol `rte_eth_devices' has different size in shared object, consider re-linking > 背景:有一天,我犯了个病,试图在一个机器上安装DOCA,然后安装程序就下了一堆库,把机器上的环境搞得一团 ......
Qt 中将std::cout 重定向到 qDebug
#include <QtCore>#include <iostream> void customMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg){ QByteArray loca ......
使用 PostMessage 函数来发送带有 std::vector 作为参数的消息
使用 PostMessage 函数来发送带有 std::vector 作为参数的消息,您可以将 std::vector 的地址封装进 LPARAM 类型的指针中,并将其传递给 PostMessage 函数的 lParam 参数。在接收方,您需要使用 reinterpret_cast 将 LPARAM ......
设计shared_ptr
###my_shared_ptr.h ``` #include #include template class my_shared_ptr { private: T* m_ptr = nullptr; unsigned int* ref_count = nullptr; void swap(my_s ......
jenkins share library
第一步,创建一个存放groovy配置文件的共享仓库 第二步,在这个共享仓库里必须要有src和vars目录,其实有个vars就行,src中我放了一些共享工具,方便在vars中调用 第三步,在src/org/devops下有如下内容 [root@master1 jenkins_shared]# cat ......
[C++特性]对std::move和std::forward的理解
左值、右值、左值引用以及右值引用 std::move和std::forward这两个API主要服务于左值引用和右值引用的转化和转发,因此再了解这两个API之前,需要先弄清楚这几个概念。 左值:一般指的是在内存中有对应的存储单元的值,最常见的就是程序中创建的变量 右值:和左值相反,一般指的是没有对应存 ......
C++-shared_ptr
C++-shared_ptr #include <iostream> #include <memory> #include <vector> class A { public: A(){ std::cout<<"A cc."<<std::endl; }; ~A(){ std::cout<<"A dd ......
安装SQL Server累积版本更新包,提示“Not Clustered or the Cluster service is up and online”和 There are no SQL Server Instances or shared features that can be updated on this computer
1. Not Clustered or the Cluster service is up and online 起因是服务器SQL Server之前有开启SQL Server AlwaysOn High availability feature and installed Failover Clu ......
How to mount a shared folder in VirtualBox
How to mount a shared folder in VirtualBox https://www.pragmaticlinux.com/2021/02/how-to-mount-a-shared-folder-in-virtualbox/ Background VirtualBox co ......
一统天下 flutter - 存储: shared_preferences - 用于操作 android 的 SharedPreferences, ios 的 NSUserDefaults, web 的 LocalStorage
一统天下 flutter - 存储: shared_preferences - 用于操作 android 的 SharedPreferences, ios 的 NSUserDefaults, web 的 LocalStorage ......
cpp multi thread std::lock_guard,mutex
#include <atomic> #include <chrono> #include <cmath> #include <condition_variable> #include <ctime> #include <fstream> #include <functional> #include ......
cpp multi thread sync via std::atomic<bool>
#include <atomic> #include <chrono> #include <cmath> #include <condition_variable> #include <ctime> #include <fstream> #include <functional> #include ......
c++11:std::forward,完美转发
目录 1、不完美转发 2、完美转发 2.1、引用折叠 2.2、std::forward 1、不完美转发所谓完美转发,是指在函数模板中,完全按照模板的参数的类型,将参数传递给函数模板中调用的另一个函数。比如: template <typename T>void IamForwording(T t){ ......
C++-std::this_thread::get_id()-获取线程id
C++-std::this_thread::get_id()-获取线程id std::this_thread::get_id() 头文件:<thread> 函数:std::this_thread::get_id() 用例:std::thread::id thread_id = std::this_t ......
shared_ptr,unique_ptr和make_shared,make_unique
std::shared_ptr<widget> p(new widget()); auto p=std::make_shared<int>(widget); 两者的不同: 1.使用make_shared的时候widget只写了一次, 2.当遇到函数传参时,由于编译器执行顺序的不同,如果使用share ......
GLIBCXX_3.4.20 not found 问题解决【Unable to load shared library 'lib**.so'】
前因: 问题:在调用别人的so时,出现了如下问题【GLIBCXX_3.4.20 not found】 Unable to load shared library 'libdbc.so' or one of its dependencies. In order to help diagnose loa ......
c++11 std::forward使用场景以及作用
不使用 std::forward时,下述代码G不管传入什么类型的参数,只会最终调用 void F(int& a); using namespace std; void F(int& a) { cout << "int& version " <<a <<endl; } void F(int&& a) ......
C++ shared_ptr 虚析构函数 特殊
class a{ public: ~a(){cout<<"a"<<endl; } class b:public a{ public: ~b(){cout<<"b"<<endl; } void main(){ shared_ptr A; { shared_ptr B(new b());//智能指针内部 ......