10 2021 档案

摘要:在C++primer p618中介绍了递归实现的版本,主要的形式: template<typname ARGS> void print(const T&t,const ARGS&... rest) { print(t); print(t,rest...); } template<typename T 阅读全文
posted @ 2021-10-30 12:43 manch1n 阅读(114) 评论(0) 推荐(0)
摘要:看了cpp reference的文档还是一头雾水,以致于写不出我能够深刻理解的样例与解释。 简要的说就是编译器的优化还有处理器的并行执行可能会导致指令的乱序执行,在单线程下这是可以的,然而在多线程下的顺序逻辑处理可能就会出现问题。 老老实实的用mutex与默认的coherent consistenc 阅读全文
posted @ 2021-10-27 11:06 manch1n 阅读(273) 评论(0) 推荐(0)
摘要:inline在c++的两个作用 曾经我很疑惑为什么定义在头文件且类外的成员函数为什么要加inline,现在找到了答案。 参考:https://stackoverflow.com/questions/9734175/why-are-class-member-functions-inlined?nore 阅读全文
posted @ 2021-10-05 10:07 manch1n 阅读(203) 评论(0) 推荐(0)
摘要:模板实参推断与bind,ref总结 template <typename T> func(T arg) 模板形参没有任何引用,会忽略顶层const,比如传入const int,则T的参数仍为int 不会忽略底层const,比如传入const int* const,则T的参数为const int* 忽 阅读全文
posted @ 2021-10-03 16:39 manch1n 阅读(65) 评论(0) 推荐(0)