普通C++程序员 VS 文艺C++程序员
2011-12-12 14:19
821 查看
原贴最初发表在QQ空间:普通C++程序员 VS 文艺C++程序员,http://user.qzone.qq.com/31731705/blog/1323153107
BBS上看到一个讲C++的帖子, C++ 这孩子 是不是误入歧途了?,让我想起了普通青年和文艺青年。
看这个经典的NB
程序,求一个数有多少bit
。J
普通C++
程序员
文艺C++
程序员
还有文青的unit test,
第三类C++
程序员
BBS上看到一个讲C++的帖子, C++ 这孩子 是不是误入歧途了?,让我想起了普通青年和文艺青年。
看这个经典的NB
程序,求一个数有多少bit
。J
普通C++
程序员
namespace traditional { int bits_of(int remain) { if (remain) return 1+bits_of( remain>>1 ); return 0; } int bits_of(void) { return bits_of(~(int)0); } }
文艺C++
程序员
namespace modern { template<int,typename THEN, typename ELSE> struct IF { typedefTHEN type; }; template<typename THEN, typename ELSE> struct IF<0,THEN,ELSE> { typedef ELSE type; }; template<typename T, T X> struct zero { static const Tvalue = X; }; template<typename T, T X> struct bits_of { typedef typenameIF<X, bits_of<T,(X>>1)>, zero<T,0> >::type type; static const Tvalue = type::value + !!X; }; }
还有文青的unit test,
typedef int a0[bits_of<int,0>::value==0? 1: -1]; typedef int a1[bits_of<int,1>::value==1? 1: -1]; typedef int a2[bits_of<int,2>::value==2? 1: -1]; typedef int a3[bits_of<int,3>::value==2? 1: -1]; typedef int a4[bits_of<int,4>::value==3? 1: -1]; typedef int a7[bits_of<int,7>::value==3? 1: -1]; typedef int a8[bits_of<int,8>::value==4? 1: -1]; typedef int a15[bits_of<int,15>::value==4? 1: -1]; typedef int a16[bits_of<int,16>::value==5? 1: -1];
第三类C++
程序员
namespace third_party { // 您确定您能看懂? }
相关文章推荐
- c++普通程序员/文艺程序员/二逼程序员
- C++ sort和for_each算法的普通、文艺和2B用法
- 普通程序员、文艺程序员、2B程序员
- 普通程序员、文艺程序员、2B程序员
- 普通程序员、文艺程序员和2B程序员的区别
- 你是普通程序员、文艺程序员还是2B程序员?
- C++ 中的单例模式(普通,2B,文艺)
- swap - 普通程序员、文艺程序员、2B程序员
- VS2013中普通C++项目添加属性表后出错解决方法
- 普通青年VS文艺青年VS2B青年,爆笑语录!
- <C++精英内参-程序员高效指南>-4搭配VS的好用工具
- C++ 中的单例模式 普通,2B, 文艺
- C++之类的成员函数的调用 vs. 普通函数的调用
- 程序员需要更强的沟通协调能力-对普通员工、有效的沟通能力可能比技术能力更重要
- 第五十七篇:VS2015建立一个完整的c++工程:头文件.h 源文件.cpp,自动生成类
- 国外程序员整理的 C++ 资源大全
- 给c++程序员的一份礼物——常用工具集 选择自 thesecondwoodstock 的 Blog (收藏)
- C++程序员经常问的11个问题
- 利用VS根据文件目录结构创建C++工程自己简单实现的方法
- C/C++程序员应聘常见面试题深入剖析