- 博客(9)
- 收藏
- 关注
原创 std::addressof的实现理解
文章目录std::addressof的实现怎么理解std::addressof的实现标准库中有一个std::addressof, 这个东西存在的目的是当存在operator&的重载时, 依然能够获得变量的地址. gcc(4.7.1)下的实现如下:template<typename __Tp>inline __Tp* __addressof(_Tp& __r) ...
2019-04-29 21:30:13 3919 1
原创 warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
文章目录ProblemBasic meaning and syntaxConstant expressionsSo when do I actually have to use `constexpr`?When can I/should I use both, const and constexpr together?Fixing the problemProblemIf you ever w...
2019-04-22 20:14:22 2868
原创 Symmetric Multiprocessors
文章目录定义优势图例定义SMP可以认为使有一下特性的单机系统:有2个或2个以上的相同能力的处理器这些处理器共享主内存和I/O设备. 通过总线或其他内部连接方式, 因此每个处理器内存访问时间基本一致所有处理器通过相同通道或不同通道来访问相同的I/O设备所有处理器的功能相同任务,文件,数据等通过操作系统来协调交互优势SMP相对于单处理器的优势如下:性能. 由于并行处理的优势,...
2019-04-21 23:00:42 305
转载 RValue Reference in C++
(转)RValue Reference文章目录IntroductionMove SemanticsRvalue ReferencesForcing Move SemanticsIs an Rvalue Reference an Rvalue?Move Semantics and Compiler OptimizationsPerfect Forwarding: The ProblemPerfec...
2019-04-18 21:08:47 445
原创 Pure virtual destructor in C++
文章目录Can a destructor be pure virtual in C++?WarningAnother peculiar thingCan a destructor be pure virtual in C++?标准c++允许纯虚构函数的存在, 但是前提是必须提供定义. 这个就有点矛盾. 纯虚函数还要定义? 原因因为子类的虚函数是按逆序执行的, 最后肯定会调用基类的虚构函数, 如...
2019-04-17 22:55:53 284
转载 Revenge of the Nerds
文章目录Catching Up with MathWhat Made Lisp DifferentWhere Languages MatterCentripetal ForcesThe Cost of Being AverageA RecipeAppendix: PowerNotes(转)Revenge of the NerdsMay 2002"We were after the C++ p...
2019-04-13 22:52:17 785
原创 error: expected type-specifier before 'ClassName'
什么情况如果写出如下代码// a.cppclass A{public: A(int h = 0) : height(h) {}private: int height;};// main.cppint main(int argc, char* argv[]){ A a; return 0;}gcc编译, 你就会碰到error: expected type-spec...
2019-04-12 21:45:31 15488 1
原创 passing 'const xxx ' as 'this' argument discards qualifiers [-fpermissive]
文章目录什么情况原因什么情况如果写出如下代码class A{public: A(int h = 0) : height(h) {} int getHeight() { return height; }private: int height;};int main(int argc, char* argv[]){ const A a; int height = a.ge...
2019-04-11 23:09:58 11310 1
原创 Type List
文章目录后面再补, 先上码测试解释后面再补, 先上码#ifndef TYPELIST_H#define TYPELIST_Hclass NullType {};template<class T, class U>struct Typelist{ typedef T Head; typedef U Tail;};namespace TL{#d...
2019-04-09 22:32:42 264
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人