随笔分类 -  C/C++

摘要:#pragma once #include <cstddef> #include <cstring> #include <algorithm> #include <stdexcept> // namespace M { class string { public: static const size 阅读全文
posted @ 2025-11-16 14:05 墨尔基阿德斯 阅读(8) 评论(0) 推荐(0)
摘要:在传统C++程序中,如果函数的返回值是一个对象的话,可能需要对函数中的局部对象进行拷贝。如果该对象很大的话,则程序的效率会降低。在C++ 11以后,出现的移动语义(Move Semantic)及拷贝优化(Copy Elision)都是解决这个问题的方法。本文试图以一个最简单的例子来说明这个问题。 案 阅读全文
posted @ 2024-08-22 11:12 墨尔基阿德斯 阅读(182) 评论(0) 推荐(0)
摘要:如何使用dlopen API动态地加载C++函数和类 - 简书 (jianshu.com) Problem 有些时候你想在运行时加载一个lib或者function or class,这种事情经常发生在你开发一个plugin或者module时遇到。 在C语言里,你可以轻松的利用dlopen, dlsy 阅读全文
posted @ 2024-07-25 09:59 墨尔基阿德斯 阅读(76) 评论(0) 推荐(0)
摘要:转自https://www.cnblogs.com/c9080/p/17509268.html,在 C++11 中,可以使用 <chrono> 头文件中的 std::chrono::system_clock 类来获取当前时间戳。它提供了多种精度和分辨率的时钟类型,其中最常用的是系统时钟。 以下是一个 阅读全文
posted @ 2024-07-16 15:39 墨尔基阿德斯 阅读(581) 评论(0) 推荐(0)
摘要:转自:https://blog.csdn.net/niceniuniu/article/details/65629401 Mock是什么? 在单元测试、模块的接口测试时,当这个模块需要依赖另外一个或几个类,而这时这些个类还没有开发好,这时我们就可以定义了Mock对象来模拟那些类的行为。 也就是自己实 阅读全文
posted @ 2023-04-18 17:08 墨尔基阿德斯 阅读(172) 评论(0) 推荐(0)
摘要:https://blog.csdn.net/guyongqiangx/article/details/120405585 阅读全文
posted @ 2023-04-18 14:47 墨尔基阿德斯 阅读(152) 评论(0) 推荐(0)
摘要:https://zhuanlan.zhihu.com/p/83535678 https://zhuanlan.zhihu.com/p/83537599 阅读全文
posted @ 2023-03-09 11:05 墨尔基阿德斯 阅读(15) 评论(0) 推荐(0)
摘要:fnmatch(pattern, str, FNM_NOESCAPE) 头文件:https://github.com/gcc-mirror/gcc/blob/master/include/fnmatch.h 源文件:https://github.com/gcc-mirror/gcc/blob/mas 阅读全文
posted @ 2023-03-03 17:08 墨尔基阿德斯 阅读(68) 评论(0) 推荐(0)
摘要:#define SYS_SET_BIT(x,y) ((x)|=(1<<y)) //将X的第Y位置1 #define SYS_CLR_BIT(x,y) ((x)&=~(1<<y)) //将X的第Y位清0 #define SYS_GET_BIT(x,y) ((x)&(1<<y)) //将X的第Y位清0 阅读全文
posted @ 2023-03-03 09:07 墨尔基阿德斯 阅读(286) 评论(0) 推荐(0)
摘要:求指针ptr所在的结构体实例的首地址, #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #define container_of(ptr, type, member) ({ \ const typeof( ((type * 阅读全文
posted @ 2023-02-27 11:47 墨尔基阿德斯 阅读(287) 评论(0) 推荐(0)
摘要:https://github.com/kehengzhong/adif 阅读全文
posted @ 2023-02-25 19:59 墨尔基阿德斯 阅读(26) 评论(0) 推荐(0)
摘要:转自:https://zhuanlan.zhihu.com/p/26599934 红黑树(Red-Black Tree,RBT)是一种平衡的二叉查找树,前面的红黑树原理与实现这篇文章中详细介绍了红黑树的细节。在Linux的内核源代码中已经给我们实现了一棵红黑树,我们可以方便地拿过来进行使用。本文将参 阅读全文
posted @ 2023-02-25 19:55 墨尔基阿德斯 阅读(118) 评论(0) 推荐(0)
摘要:转自:https://www.cnblogs.com/hellokitty2/p/15362596.html 另外可参考:https://zhuanlan.zhihu.com/p/26599934 一、学习笔记 1. rbtree 简介 rbtree,全称是 Red-Black Tree,又称为“红 阅读全文
posted @ 2023-02-25 10:38 墨尔基阿德斯 阅读(75) 评论(0) 推荐(0)
摘要:转自:https://www.cnblogs.com/hellokitty2/p/15362630.html 1. 什么是红黑树,它们有什么用? 红黑树是一种自平衡二叉搜索树,用于存储可排序的 键/值 数据对。 这不同于 基数树(用于有效地存储稀疏数组,因此使用长整数索引来插入/访问/删除节点)和哈 阅读全文
posted @ 2023-02-25 10:32 墨尔基阿德斯 阅读(118) 评论(0) 推荐(0)
摘要:https://www.php1.cn/detail/c_YuYanHuoQuDang_c0079976.html Linux 函数名: getcwd 功 能: 取得当前的工作目录 用 法: char *getcwd(char *buf, size_t size); 函数说明: getcwd()会将 阅读全文
posted @ 2023-01-02 19:22 墨尔基阿德斯 阅读(1799) 评论(0) 推荐(0)
摘要:https://www.zhihu.com/question/421214887 1 void test(int); 2 int main(void){ 3 void (*fp)(int); 4 fp=test; 5 (*fp)(9); 6 7 fp(9); 8 return 0; 9 } 10 v 阅读全文
posted @ 2022-12-02 10:31 墨尔基阿德斯 阅读(188) 评论(0) 推荐(0)
摘要:https://cloud.tencent.com/developer/article/1703257 https://cloud.tencent.com/developer/article/2045107?from=article.detail.1703257 阅读全文
posted @ 2022-12-02 10:03 墨尔基阿德斯 阅读(19) 评论(0) 推荐(0)