09 2021 档案
摘要:std::optional 1. vlaue_or 函数使用 1 #include <iostream> 2 #include <optional> 3 #include <string> 4 5 std::optional<std::string> create(bool b) 6 { 7 if(
阅读全文
摘要:退出正在调试的函数 #include <stdio.h> int func(void) { int i = 0; i += 2; i *= 10; return i; } int main(void) { int a = 0; a = func(); printf("%d\n", a); retur
阅读全文
摘要:前序遍历 思路:前序遍历算法先访问树的根节点,然后遍历左子树,最后遍历右子树。 解法1 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * Tr
阅读全文
摘要:coredump 1. 在终端中输入ulimit -c 如果结果为0,说明当程序崩溃时,系统并不能生成core dump。可以使用命令 ulimit -c unlimited 来开启 core dump 功能,并且不限制 core dump 文件的大小; 如果需要限制文件的大小,将 unlimite
阅读全文
摘要:enable_if SFINAE 是 substitution failure is not an error 的缩写,即匹配失败不是错误。就是说,匹配重载的函数 / 类时如果匹配后会引发编译错误,这个函数 /或类就不会作为候选。这是一个 C++11 的新特性,也是 enable_if 最核心的原理
阅读全文
摘要:std::declval (c++11 only) 函数模板 template<typename T> typename add_rvalue_reference<T>::type declval() noexcept; 功能描述: 返回一个类型的右值引用,不管是否有没有默认构造函数或该类型不可以创
阅读全文
摘要:折叠表达式 表格4.1列出所有可能的表达式: #include <iostream> #include <string> template <typename ... Ts> auto sum(Ts ... ts) { return (... + ts); } int main() { std::c
阅读全文
摘要:参考资料 1. windows安装OpenSSH支持SSH
阅读全文
摘要:开根号 #include <iostream> #include <stdio.h> using namespace std; double myqrt(double x) { if (x < 0) return -1; constexpr auto eps = 1e-8; double low,
阅读全文
摘要:sizeof : 获取内存存储的大小。alignof : 获取地址对其的大小,POD里面最大的内存对其的大小。 1 struct A{ //non-POD type 2 int avg; 3 int avg2; 4 double c; 5 A(int a,int b):avg((a+b)/2){ 6
阅读全文
摘要:智能指针shared_ptr与unique_ptr unique_ptr支持动态数组,而shared_ptr不能直接支持动态数组: std::unique_ptr<int []> ptr(new int[10]); //合法, std::shared_ptr<int []> ptr(new int[
阅读全文
摘要:coredumpctl命令 1. 调用gdb展开函数调用栈: coredumpctl gdb [pid] 参考资料 1. coredumpctl中文手册
阅读全文
摘要:ceph fs命令 tyds fs dump ceph fs ls
阅读全文

浙公网安备 33010602011771号