随笔分类 -  C++/STL

摘要:Asio Portable networking, including sockets, timers, hostname resolution and socket iostreams. Author(s) Chris Kohlhoff First Release 1.35.0 Standard Build & Link Categories Concurrent Programmi... 阅读全文
posted @ 2010-09-23 11:49 史莱姆 阅读(229) 评论(0) 推荐(0)
摘要:1、"stdafx.cpp"文件的预编译选项永远是“Create Precompiled Headers (/Yc)”; 2、工程的预编译选项一般为“Use Precompiled Headers (/Yu)”。 阅读全文
posted @ 2010-08-10 02:09 史莱姆 阅读(258) 评论(0) 推荐(0)
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--/*Trace.h*/#ifndef__TRACE_H__#define__TRACE_H__#include<crtdbg.h>#include<stdarg.h>#incl... 阅读全文
posted @ 2010-08-06 03:58 史莱姆 阅读(2038) 评论(0) 推荐(0)
摘要:前天用OOP方式写的一个小程序--------------------------------------------------------------------------------------------------------------------------------Problem Description: MARS ROVERS Squads of robotic rove... 阅读全文
posted @ 2010-08-03 00:38 史莱姆 阅读(439) 评论(0) 推荐(0)
摘要:1)算法部分 CLRS(Introduction.to.Algorithms.Second.Edition) http://download.csdn.net/source/2001574 算法导论中文版(南大校内发行的,书名虽然不对,不过内容确实是第一版的算法导论) http://download.csdn.net/source/2003404 http://download.csdn.net... 阅读全文
posted @ 2010-07-15 22:55 史莱姆 阅读(276) 评论(0) 推荐(0)
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--#ifndef_PERF_TIMER_H_#define_PERF_TIMER_H_#ifdef_WIN32#include<windows.h>#else#include<sys/... 阅读全文
posted @ 2010-06-26 04:06 史莱姆 阅读(365) 评论(0) 推荐(0)
摘要:awtools.h代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--#ifndefAWTOOLS_H_#defineAWTOOLS_H_#include<sstream>namespaceAWTookit{ template<cla... 阅读全文
posted @ 2010-06-26 03:50 史莱姆 阅读(696) 评论(0) 推荐(0)
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--/**main.cpp**Createdon:Feb9,2010*Author:weiyuwang*/#include<signal.h>#include<unistd.h>#... 阅读全文
posted @ 2010-06-26 03:44 史莱姆 阅读(419) 评论(0) 推荐(0)
摘要:http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?part=1&chap=3Content: The ProblemWhat is PIC?What are "relocations"?Case 1: Broken compilerCase 2: Broken `-fPIC' support checks in config... 阅读全文
posted @ 2010-06-23 02:50 史莱姆 阅读(742) 评论(0) 推荐(0)
摘要:http://stackoverflow.com/questions/620137/do-the-parentheses-after-the-type-name-make-a-difference-with-newif 'Test' is an ordinary class, is there any difference between:Sometimes the memory returned... 阅读全文
posted @ 2010-06-14 22:48 史莱姆 阅读(194) 评论(0) 推荐(0)
摘要:std::endl 会调用 std::flush(), 这个操作在我的机器上平均 20 macros"\n" 不会调用std::flush(),这个操作在我的机器上平均 5 macros 而 close 操作也会调用flush ,所以最好尽可能的减少std::endl的调用 阅读全文
posted @ 2010-04-30 01:06 史莱姆 阅读(311) 评论(0) 推荐(0)
摘要:http://www.glenmccl.com/perf_006.htmIs stream I/O slower than C-style standard I/O? This question is a bit hard to answer. For a simple case like: #ifdef CPPIO #include <iostream.h> #else #incl... 阅读全文
posted @ 2009-11-11 01:17 史莱姆 阅读(380) 评论(0) 推荐(0)
摘要:原文 http://www.tommti-systems.de/go.html?http://www.tommti-systems.de/main-Dateien/reviews/languages/benchmarks.html很古老的一篇文章,但是结果很有启发性, 指出了几种语言性能差别到底在什么地方, 不过测试版本都比较老, 所以只节选了前面一段。测试环境AMD Athlon XP 2200... 阅读全文
posted @ 2009-11-11 00:28 史莱姆 阅读(5686) 评论(1) 推荐(0)
摘要:find (find_if) 搜索等于某值的第一个元素 adjacent_find 搜索连续两个相等的元素 find_first_of 搜索等于某个数值之一的第一个元素 find_end 搜索某个子区间最后出现的位置 search 搜索某个子区间第一次出现的位置 search_n 搜索具有某个特性的第一段n个连续元素 binary_search 判断某个区间内是否包含某个元素 ... 阅读全文
posted @ 2009-11-09 03:03 史莱姆 阅读(359) 评论(0) 推荐(0)
摘要:构造函数1)initialization list2)异常保护,资源泄漏检查3)this指针的使用4)其他构造函数调用5)虚函数调用6)拷贝构造函数7)隐式类型转换 析构函数1)异常保护2)虚函数调用 成员变量1)compiler - firewall idiom2)访问权限3)traits4)资源管理与智能指针5)引用计数与Copy-On-Write6)const / mutable / vol... 阅读全文
posted @ 2009-11-09 02:59 史莱姆 阅读(185) 评论(0) 推荐(0)
摘要:返回值如何实现? 【实现模型1】cfont的实现采用了双阶段转化。1.首先声明一个额外的参数,类型上类对象的引用,用来存放返回结果。2.对这个参数利用返回值进行拷贝初始化。过程类似于参数传递,也是要定义一个临时对象,用来保存返回值,然后在函数内部调用拷贝构造函数用那个return值进行初始化。 X bar() { X xx; // process xx ... return xx; } 编译器转化... 阅读全文
posted @ 2009-11-09 02:58 史莱姆 阅读(407) 评论(0) 推荐(0)
摘要:Copy-On-Write 使用了“引用计数” 如果使用拷贝构造和operator=初始化对象, 则该对象只是简单增加引用计数, 而在当前类对象改变时, 他会去查看引用计数, 如果有其他类对象共享使用当前的对象, 那么把需要更改的类进行拷贝。 阅读全文
posted @ 2009-11-09 02:58 史莱姆 阅读(181) 评论(0) 推荐(0)
摘要:1)纯虚析构函数,如果不提供定义, 子类不能被实例化。 2)明确使用缺省行为 3)提供部分行为 4)应付功能不足的编译器诊断程序 阅读全文
posted @ 2009-11-09 02:57 史莱姆 阅读(328) 评论(0) 推荐(0)
摘要:标准形式 T& operator++(); // ++ 前缀T& operator --(); // -- 前缀const T operator++(int); // ++ 后缀const T operator--(int); // -- 后缀// l 是 list<int>, i 是合法的迭代器 1)l.erase(i++); OK 2)l.erase(i)... 阅读全文
posted @ 2009-11-09 02:57 史莱姆 阅读(228) 评论(0) 推荐(0)
摘要:1)在函数调用之前,对函数的所有参数的求值必须全部完成 2)一旦一个函数开始执行, 调用者函数中的表达式将不会开始求值,或继续求值,直至被调用函数执行结束,函数执行永远不会交叉进行. 3)如果函数参数是表达式,这些表达式通常可以按任何次序求值,包括交叉求值. 对于f(expr1, expr2) 编译器可能先对expr1 求值,也可能后对expr1求值,或者让expr1 和 expr2 的求值交叉进... 阅读全文
posted @ 2009-11-09 02:56 史莱姆 阅读(314) 评论(0) 推荐(0)