随笔分类 -  C/C++

STL概述
摘要:STL主要包括5大组件,分别是:1.容器(Containers),2.算法(Algorithms),3.迭代器(Iterators),4.仿函数(Functors),5.适配器(Adapters),空间配置器(Allocators).1. 容器: 包括序列容器(vector,list,deque,stack,queue,priority_que)和关联容器(map,set).而stack和queue完全是借助deque完成,故他们也是属于适配器.2. 适配器: 像stack和queue这种完全借助于其他容器实现的容器叫适配器,STL中的适配器主要有queue和stack3. 迭代器: 迭代器主 阅读全文

posted @ 2010-12-07 14:16 SammyLan 阅读(191) 评论(0) 推荐(0)

求一个整型的二进制表示中的所有1移到最左边所形成的数
摘要:template struct CBitMove { static unsigned int const res = 0x80000000|(CBitMove::res>>1); }; template struct CBitMove { static unsigned int const res = 0; }; unsigned int BitMove(unsigned int n) ... 阅读全文

posted @ 2010-12-01 15:30 SammyLan 阅读(203) 评论(0) 推荐(0)

模板元编程:求N的阶乘
摘要:求N的阶乘,要求不使用乘除法,for,while,if,else,switch,case等关键字以及条件判断语句?: 阅读全文

posted @ 2010-11-15 13:13 SammyLan 阅读(3108) 评论(0) 推荐(0)

如何让模板类跟友元模板函数一一对应起来
摘要:有时候我们需要让模板类的某个实例跟对应的友元函数的对应实例关联起来,对于这种情况,我们可以用<>让其进行关联,如下 阅读全文

posted @ 2010-11-08 12:46 SammyLan 阅读(261) 评论(0) 推荐(0)

如何获取重载了operator &的类对象的实际地址?
摘要:我们可以通过将reinterpret_cast将类对象强制转换成内置类型的引用,然后对其进行取地址操作如下代码 阅读全文

posted @ 2010-10-10 17:14 SammyLan 阅读(329) 评论(0) 推荐(0)

[转]How to export an instantiation of a template class
摘要:转自How to export an instantiation of a Standard Template Library (STL) class and a class that contains a data member that is an STL objectSUMMARY:This article discusses how to perform the following tas... 阅读全文

posted @ 2010-09-15 16:09 SammyLan 阅读(517) 评论(0) 推荐(0)

导航