Linux
Mr FF
世界上只有一种英雄主义,那就是在认识到生活的真相之后依然热爱生活。
展开
-
如何在host上快速尝试FAST-DDS-GEN
快速尝试FAST-DDS-GEN原创 2022-08-31 10:28:51 · 256 阅读 · 0 评论 -
使用链式调用风格来增加C++代码的可阅读性
使用链式调用风格来增加C++代码的可阅读性原创 2022-08-13 15:07:19 · 361 阅读 · 0 评论 -
C++11 std::async 结合 lambda, std::function<>的例子
std::async std::function lambda原创 2022-08-12 23:49:46 · 903 阅读 · 0 评论 -
服务器相关的指标解释
TPS、QPS、RPS、PV、UV这些指标的理解转载 2022-07-18 11:16:46 · 330 阅读 · 0 评论 -
std::bind与std::function的一些应用
typeid std::bind std::function的一些应用原创 2022-07-13 14:15:02 · 167 阅读 · 0 评论 -
使用-Wall清除代码隐患
使用编译参数清除代码隐患原创 2022-06-06 23:14:26 · 124 阅读 · 0 评论 -
小技巧-彻底删除U盘中的文件
安全清理U盘的小技巧原创 2022-06-06 19:47:53 · 2855 阅读 · 0 评论 -
malloc和new之间的不同-实战篇
很多人在面试时都会被问malloc和new之间的不同,有些人会说一下。但很多人可能并没有真正的遇到过因其不同而带来的问题。1 new会调用构造函数,malloc不会。这句话的真正意思是,new会给struct的成员分配空间,而malloc其实则不一定。struct Data { string name; int id;};struct Data* pData = (Data*) malloc(sizeof(Data));if (pData == nullptr) {原创 2022-05-17 16:14:24 · 142 阅读 · 0 评论 -
子类调用父类构造函数的时机
子类调用父类构造函数的时机原创 2022-02-05 19:43:05 · 1197 阅读 · 0 评论 -
C++中如何在一个类中初始化其它类
#include <iostream>using namespace std;class GPU {public: GPU(int id) : m_gpuId(id) { cout << "GPU" << endl; }private: int m_gpuId;};class Memory {public: Memory(int mem) : m_memSize(mem) { .原创 2022-01-27 21:34:53 · 2507 阅读 · 0 评论 -
现代C++中如何检测new的失败
C++和C,在分配动态内存时,分别用new和malloc,但检查其结果的方式完全不同。在C中,一般是检查返回指针是否为NULL,但这在C++中可能行不通。#include <iostream>using namespace std;struct GPU { string m_name; uint64_t m_serialNumber;};int main(){ struct GPU* pGpu = nullptr; try {原创 2022-01-27 21:04:26 · 1222 阅读 · 0 评论 -
谈谈为何需要将类的成员函数声明为private
1 析构函数声明为私有, 有些资源必须要在析构前释放掉,则将析构函数声明为私有,然后另外再定义一个公有的destroy函数,先做释放资源操作,再调用析构函数。 delete this.2 当类成员中有文件描述符,锁之类的系统资源时,因为这些资源不具备可复制性。所以要防止使用者复制使用它们。此时的做法是将copy构造函数、赋值操作符声明为private3 析构函数声明为私有,则在创建该类的对象时必须是在堆上创建,如果是在栈上创建会导致编译不过。#include <iostream>原创 2022-01-26 18:03:59 · 895 阅读 · 0 评论 -
C++ map中使用私有类型做key为什么必须要重载<
使用自定义类型作为容器map中的key,必须要重载原创 2022-01-26 16:02:11 · 957 阅读 · 0 评论 -
socket编程二:使用select
tcp_server.c#include <unistd.h>#include <stdio.h>#include <stdlib.h>#include <sys/socket.h>#include <sys/types.h>#include <sys/select.h>#include <sys/time.h>#include <netinet/in.h>#include <arpa原创 2022-01-18 17:42:15 · 286 阅读 · 0 评论 -
socket编程一:使用fork()实现最基础的并发模式
tcp_server.c#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <sys/socket.h>#include <unistd.h>#include <netinet/in.h>#include <arpa/inet.h>int main(int argc, char **argv){ // crea原创 2022-01-17 15:30:26 · 508 阅读 · 0 评论 -
使用C++11 可变参数模板计算
#include <iostream>using namespace std;template<typename T>T Calculate(T t){ return t;}template<typename T, typename ... Args>T Calculate(T first, Args... rest){ return first * (1 << sizeof...(rest)) + Calculate&.原创 2021-12-18 17:37:41 · 614 阅读 · 0 评论 -
回调使用lambda
// lambda_callable.cpp#include <iostream>using namespace std;template <typename T, typename Func>void ForEach(T* begin, T* end, const Func& func){ while (begin != end) { func(*begin++); }}int main(int argc, char .原创 2021-12-07 20:53:34 · 512 阅读 · 0 评论 -
operator() 用法之一
#include <iostream>using namespace std;template <typename T>struct Print { void operator() (const T& msg) const { cout << msg << " "; }};template <typename T, typename Func>void ForEach(T* beg.原创 2021-12-07 20:44:09 · 183 阅读 · 0 评论 -
重载operator()
#include <iostream>using namespace std;class A {public: A(string msg) : m_msg(msg) { cout << "A constructor:" << msg << endl; } virtual ~A() { cout << "A destructor" << endl; .原创 2021-12-07 20:33:28 · 193 阅读 · 0 评论 -
类模板中的成员函数能否声明为虚函数
#include <iostream>using namespace std;template<typename T>class A {public: A(T a):m_a(a) { cout << "A::a" << endl; } virtual void b(T bb) { cout << "A::b" << endl; }priva.原创 2021-12-06 18:49:01 · 175 阅读 · 0 评论 -
虚函数能否声明为内联
#include <iostream>using namespace std;class A { public: virtual inline void a() { cout << "A::a" << endl; }; inline virtual void b() { cout << "A::b" << endl; }};int main().原创 2021-12-06 18:44:58 · 62 阅读 · 0 评论 -
子类成员直接调用父类的函数
#include <iostream>using namespace std;class A {public: virtual void a() { cout << "A::a" <<endl; }};class B : public A {public: virtual void a() { cout << "B::b" << endl; A *aa = .原创 2021-12-06 18:42:06 · 504 阅读 · 0 评论 -
deque用法测试
#include <deque>#include <iostream>using namespace std;class Event {public: Event(int type, string data) : m_eventType(type), m_eventData(data) { cout << "construct Event:" << m_eventType << ", " <&l.原创 2021-11-16 11:27:04 · 602 阅读 · 0 评论 -
emplace_back与push_back的真实效率比较
我测下的结果,反而是push_back耗时更小些。这个明显和大家的结论不一致。#include <vector>#include <iostream>#include <sys/time.h>using namespace std;int64_t GetSysTimeMicros(){ timeval tv; gettimeofday(&tv, 0); return (int64_t)tv.tv_sec * 100000原创 2021-11-10 20:33:43 · 545 阅读 · 2 评论 -
centos6.8上编译安装PHP7.4.12时遇到的问题解决思路
每个人的环境不同这里不穷举所有的例子,此处仅分享解决问题的思路。1 configure时遇到sqlite3 onig等库确实,使用yum install安装后重新configure,如过提示还是无法找到,仔细看提示。根据提示设置环境变量即可。#how to fix the oniguruma dependency issueexport ONIG_CFLAGS="/usr/bin/onig-config"export ONIG_LIBS="/usr/lib64/"2 make时遇到u.原创 2020-11-13 23:58:27 · 1099 阅读 · 0 评论 -
php7.3与httpd结合的方式
背景:如果自己选择安装7.X版本的php,安装完成之后需要配置httpd.conf.配置方法如下:原创 2020-11-11 00:08:46 · 310 阅读 · 1 评论 -
wordpress中解决页面未找到的问题
1 在根目录下新建.htaccess2 写入如下配置# BEGIN WordPress<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule转载 2020-10-15 21:39:55 · 2057 阅读 · 0 评论 -
centos 命令行中提示信息中文乱码的解决方案
修改: ~/.bash_profile文件vim ~/.bash_profile将LANG和LC_ALL 改成en_US即可。#export LANG=zh_CN.GB18030export LANG=en_US#export LC_ALL=zh_CN.GB18030export LC_ALL=en_US原创 2020-10-15 21:12:27 · 478 阅读 · 0 评论 -
关于git各种操作与文件对应的状态和仓库的关联。
下面这篇文章是讲的比较清楚的。https://www.cnblogs.com/qdhxhz/p/9757390.html转载 2020-09-29 14:15:46 · 144 阅读 · 2 评论 -
如何配置地址
ifconfig // 找到自己的网卡设备名ifconfig [devicename] [ip address] // 配置地址ping [ip address] // 测试配置原创 2020-09-18 11:15:36 · 691 阅读 · 0 评论