RAII(resource acquisition is initialization):资源获取时便是初始化时机。不论控制流如何离开执行的区域块,其析构函数被调用,资源被释放。为防止内存泄露使用auto_ptr或shared_ptr();auto_ptr sp(new class)+shared_...
分类:
其他好文 时间:
2014-08-11 17:22:02
阅读次数:
204
摘要:在很多中情况下,我们需要这样的运算:给vector中每个元素进行相似的处理(每个元素+1,或者其他).一般情况下,我们会选用for循环,然后然后对每个元素进行处理。实际上,C++ 11提供了了lamda表达式,结合for_each,可以写出更加简洁和高效的代码。
1.for_each.简介
for_each是C++中的模板,具体用法可以参考这里:http://www.cplusp...
分类:
编程语言 时间:
2014-08-11 15:05:52
阅读次数:
218
新建表ClubsCREATE TABLE `Clubs` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(30) CHARACTER SET utf8 NOT NULL DEFAULT '', PRIMARY KEY (`id`...
分类:
数据库 时间:
2014-08-11 14:34:42
阅读次数:
204
1.简单的说,常规流向的块级元素,width为auto时,会尽量充满父元素的内容宽度,而height为auto时,则是由其内部的不浮动的子元素的高度决定(无浮动,绝对定位)。2.width:100%;width:auto 1如果是width:100%,则说明p的width会得到600px就已经充满d...
分类:
Web程序 时间:
2014-08-11 00:00:40
阅读次数:
303
发送端#include "DBProc1.h"#include #include #include using namespace boost::interprocess;PLUG_COMPONENT_AUTO_REG(DBProc1)//DO NOT EDIT THISstruct MyStruc...
分类:
其他好文 时间:
2014-08-10 15:29:30
阅读次数:
289
1,使用 mysqlslap 进行压力测试
mysqlslap --defaults-file=/etc/my.cnf --concurrency=200 --iterations=1 --number-int-cols=1 --auto-generate-sql --auto-generate-sql-load-type=write --engine=myisam,innodb --n...
分类:
数据库 时间:
2014-08-10 13:06:00
阅读次数:
368
要设置 IP 和 DNS 解析服务器,编辑 /etc/network/interfaces:# interfaces(5) file used by ifup(8) and ifdown(8)auto loiface lo inet loopbackauto eth0iface eth0 inet ...
分类:
其他好文 时间:
2014-08-09 21:05:49
阅读次数:
227
内存管理一直是令C++程序员最头疼的工作,C++继承了C那高效而又灵活的指针,使用起来稍微不小心就会导致内存泄露、野指针、越界访问等访问。虽然C++标准提供了只能指针std::auto_ptr,但是并没有解决所有问题。boost的smart_ptr库是对C++98标准的绝佳补充。它提供了六种智能.....
分类:
其他好文 时间:
2014-08-09 18:41:18
阅读次数:
386
import java.math.*;import java.util.*;import java.io.*;public class hdu1753 { public static void main(String[] args) { // TODO Auto-generate...
分类:
其他好文 时间:
2014-08-09 18:35:28
阅读次数:
175
1. 线程的移动语义实现
基于前面几章介绍的移动语义,我们用它来实现线程。
#include
#include
#include
#include
#include
int main()
{
std::vector workers;
for (int i = 0; i < 5; i++) {
auto t = std::thread([i]()
{
std::...
分类:
移动开发 时间:
2014-08-09 11:36:27
阅读次数:
276