自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

-.-嘻嘻

记录下平时所学的东东

  • 博客(62)
  • 资源 (7)
  • 收藏
  • 关注

原创 boost asio 单线程的异步

#include <boost/asio/io_service.hpp>#include <boost/asio/steady_timer.hpp>#include <chrono>#include <thread>#include <iostream>using namespace boost::asio;int main(){ io_service ioservice;

2015-11-01 12:36:19 1169

原创 boost asio的异步事件处理函数是在执行异步事件的run函数所在的线程里面执行的

#include <boost/asio/io_service.hpp>#include <boost/asio/steady_timer.hpp>#include <chrono>#include <thread>#include <iostream>using namespace boost::asio;int main(){ io_service ioservice;

2015-10-31 14:10:25 1014

原创 boost asio

#include #include #include #include #include #include using namespace boost::asio::ip;class Session : public std::enable_shared_from_this{public: Session(boost::asio::io_service &ios) : soc

2015-10-27 19:55:57 468

原创 boost asio 异步

#include <iostream>#include <memory>#include <boost/bind.hpp>#include <boost/asio.hpp>#include <boost/system/system_error.hpp>using namespace boost::asio::ip;class Session : public std::enable_sha

2015-10-27 15:24:06 591

原创 c++ thread detach

#include <iostream>#include <thread>int main(){ for (int i = 0; i < 1; ++i) { std::thread([]() { std::cout << "thread" << std::endl; }).detach(); } f

2015-10-25 16:54:35 625

原创 boost asio client

#include #include #include #include #include using namespace boost::asio::ip;const int max_length = 1024;char request_buffer[max_length] = {};char reply_buffer[max_length] = {};int main(){

2015-10-25 13:05:43 502

原创 boost asio 同步阻塞

#include #include #include #include #include #include #include #include //using namespace boost::asio;const int max_length = 1024;using Socket = boost::asio::ip::tcp::socket;using SocketP

2015-10-22 14:56:39 1003

原创 boost asio

#include #include #include #include  void handler1(){ for (int i = 0; i  20; ++i) { std::cout  "handler1"  std::endl; } std::cout  "5 s"  std::endl;} void handler2(){ std::cout  "10 s

2015-10-19 09:17:11 355

原创 python metaclass

欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl

2015-09-07 10:02:30 390

原创 boost asio streambuf与Boost 序列化库

在http://www.godebug.org/index.php/archives/105/的基础上改了一点.客户端:#include <cstdlib>#include <cstring>#include <iostream>#include <boost/asio.hpp>#include "protocal.h"void read_buf(boost::asio::ip::tcp::

2015-05-24 21:19:03 2398

原创 std::find_if_not

函数定义(VS2013): 参数及返回值: first,last分别指向一个序列中初始及末尾位置的输入迭代器。这个范围即 [first,last) ,包括 first 到 last 间的所有元素,包括 first 指向的元素,但不包括 last 指向的元素。pred一元谓词(Unary)函数,以范围中的一个元素为参数,然后返回一个可转换成 bool 类型的值。其返回值表明指定元素是否满足当前函数

2015-05-21 10:44:17 423

原创 std::none_of

函数定义(VS2013): 检测在给定范围中是否不存在元素满足给定的条件。 参数及其返回值: first,last分别指向一个序列中初始及末尾位置的输入迭代器。这个范围即 [first,last) ,包括 first 到 last 间的所有元素,包括 first 指向的元素,但不包括 last 指向的元素。pred一元谓词(Unary)函数,以范围中的一个元素为参数,然后返回一个可转换成 bo

2015-05-20 21:28:56 1041

原创 std::any_of

函数定义(VS2013): 参数及其返回值: first,last分别指向一个序列中初始及末尾位置的输入迭代器。这个范围即 [first,last) ,包括 first 到 last 间的所有元素,包括 first 指向的元素,但不包括 last 指向的元素。pred一元谓词(Unary)函数,以范围中的一个元素为参数,然后返回一个可转换成 bool 类型的值。其返回值表明指定元素是否满足当前函

2015-05-20 21:07:24 3178

原创 std::all_of

函数定义如下(VS2013): first,last分别指向一个序列中初始及末尾位置的输入迭代器。这个范围即 [first,last) ,包括 first 到 last 间的所有元素,包括 first 指向的元素,但不包括 last 指向的元素。pred一元谓词(Unary)函数,以范围中的一个元素为参数,然后返回一个可转换成 bool 类型的值。其返回值表明指定元素是否满足当前函数所检测的条件。

2015-05-20 20:34:59 1918 1

原创 boost asio学习笔记(2) echo 客户端

#include <iostream>#include <memory>#include <array>#include <boost/asio.hpp>using namespace std;using namespace boost::asio;const int MAX_MESS_SIZE = 4096;class Session : public enable_shared_fro

2015-05-20 16:59:07 485

原创 boost asio学习笔记(1) echo服务端

#include <iostream>#include <memory>#include <array>#include <boost/asio.hpp>const int MAX_MESS_SIZE = 4096;class Session : public std::enable_shared_from_this < Session >{public: Session(boos

2015-05-19 21:23:08 651

翻译 抽象工厂模式

#include #include class ProductA{public: virtual void show() = 0;};class ProductA1 : public ProductA{public: void show() { std::cout << "Product A1" << std::endl; }};class ProductA2

2015-02-15 13:50:44 385

翻译 工厂方法模式

#include #include class Product{public: virtual void show() = 0;};class ProductA : public Product{public: void show() { std::cout << "Product A" << std::endl; }};class ProductB : pu

2015-02-15 11:36:27 398

翻译 简单工厂模式

#include #include enum FactoryType { A, B, C };class Product{public: virtual void show() = 0;};class ProductA : public Product{public: void show() { std::cout << "Product A" << std::e

2015-02-13 21:11:12 533 2

原创 c++命名规则(抄袭google)

命名约定1. 通用命名规则(General Naming Rules)函数命名、变量命名、文件命名应具有描述性,不要过度缩写,类型和变量应该是名词, 函数名可以用“命令性”动词。如何命名:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!尽可能给出描述性

2014-12-09 20:06:53 522

原创 template template parameter2

#include using namespace std;template class TestClass{public: TestClass() = default; ~TestClass() = default; TestClass(T value) : x(value){} T get_value() { return x; }private: T x =

2014-11-10 10:25:28 501

原创 template template parameter

#include #include #include #include #include #include template > class CONT = std::deque>class Stack {private: CONT elems; // elementspublic: void push(T const&); // push eleme

2014-11-09 21:49:22 604

原创 成员模板2

#include #include #include #include using namespace std;template >class Stack{private: CONT elems; // elementspublic: void push(T const&); // push element void pop();

2014-11-08 20:48:33 451

原创 成员模板

#include #include template class Stack {private: std::deque elems; // elementspublic: void push(T const&); // push element void pop(); // pop element T top() const;

2014-11-07 22:26:19 436

原创 乱七八糟

#include using namespace std;int main(){ //int *p = nullptr; ////const int *ptr = p; // OK ////const int* &pptr = p; // error: 无法用 "int *" 类型的值初始化 "const int *&" 类型的引用(非常量限定) ////int *const pt

2014-11-05 13:31:34 449

原创 杂七杂八

#include using namespace std;class TestClass{ friend ostream& operator<<(ostream&, TestClass&);public: TestClass(int *ptr) :p(ptr){} TestClass(const TestClass &value) : p(new int(*(value.p)))

2014-11-04 12:40:50 441

原创 单例

#include using namespace std;template class Singleton{public: int get_data(); static Singleton* &get_ptr();public: int m_data; static Singleton *m_ptr;private: Singleton(){ m_data = 10;

2014-11-03 18:50:30 456

翻译 weak_ptr解决循环引用问题demo

#include #include class Woman;class Man{private: std::weak_ptr _wife; //std::shared_ptr _wife; public: void setWife(std::shared_ptr &woman){ _wife = woman; } void doSomthing(){ if

2014-10-20 12:08:34 851

原创 list (仿sgi stl)

#include #include #include #include using namespace std;template // 结点结构struct __list_node { typedef void* void_pointer; void_pointer prev; void_pointer next; T data;};template

2014-09-23 08:38:19 544

原创 vector (仿sgi stl)

// 参考侯捷大大的《STL源码剖析》尝试自己写一个vector调高下代码水平 // VS2013下编译 基本模仿sgi stl // by : 李嘉图.M.统 #include #include #include #include using namespace std;// 空间配置器默认用allocator sgi-STL里面用的simple_alloctemp

2014-09-18 15:07:48 742

原创 红黑树(算法导论)

测试代码所用的例子为算导第三版p179图的

2014-09-07 20:32:17 631

原创 AVL树(算法导论)

#include #include using namespace std;struct node{ node *left; node *right; node *parent; int data; int h; node() : left(nullptr), right(nullptr), parent(nullptr), data(0), h(0){} node(i

2014-09-03 11:16:13 825

原创 priority_queue (仿sgi stl) 纯手打 累死TMD

#include #include //#include #include // 内含 _Val_type _Dist_type#include // 内含 less 函数对象using namespace std;template void __push_heap(RandomAccessIterator first, Distance holeIndex, Distanc

2014-08-31 21:15:20 597

转载 内存对齐

内存对齐主要有2大步骤:成员对齐和结构对齐 成员对齐规则:结构体第一个成员从位移0开始存储 eg:int [0-3]       从第二个成员开始,都要从min(pack值,this member size)的整数倍的位移开始存储                eg: #pragma pack(2) int成员  min(2,sizeof(int))= 2   所以从2的整数倍

2014-08-31 08:45:12 429

原创 queue(仿sgi stl)

#include #include using namespace std;template >class queue{ friend bool operator==(const queue &x, const queue &y); friend bool operator<(const queue &x, const queue &y);public: typedef ty

2014-08-28 14:45:30 469

原创 stack(仿sgi stl)

#include #include using namespace std;template >class stack // stack内部使用默认容器deque { friend bool operator==(const stack &x, const stack &y); friend bool operator<(const stack &x, const st

2014-08-27 20:29:16 471

原创 二叉搜索树(算法导论)

#include using namespace std;struct tree_node // 树节点{ tree_node(int x) : data(x), lchild(nullptr), rchild(nullptr), parent(nullptr){} int data; tree_node *lchild; tree_node *rchild; tree_nod

2014-08-27 17:41:20 501

原创 kmp

#include #include using namespace std;int Brute_force_string_matching(string &s, string &p) // 字符串暴力匹配{ size_t i = 0; size_t j = 0; size_t slen = s.size(); size_t plen = p.size(); if (slen

2014-08-12 16:40:16 483

原创 二分法及其拓展

//二分查找及其扩展实现#include #include #include #include using namespace std;// 二分寻找值为value的元素int binary_search(vector &array, int left, int right, int value) //left right不能小于0 {if (array.empty()) { return -1;

2014-08-11 23:23:28 561

原创 hash表 拉链法 仿sgi stl 非模板简单实现

#include #include #include using namespace std;typedef struct hashtable_node // 节点{ hashtable_node *next; size_t value;}node, *pnode;enum{stl_num_primes = 28}; // 素数表大小static const unsig

2014-08-08 11:17:20 688

Effective morden c++

2014年scott meyers最新书 讲述c++11 &c++14 正式版!

2014-12-15

VA_X_10.8_2043

破解版

2014-12-15

你必须知道的495个C语言问题

你必须知道的495个C语言问题

2014-11-26

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除