C++
lsaejn
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
muduo库源码学习(base)AsyncLogging
//前端写缓冲区,2块缓冲,不够就写到容器。后端两块缓冲区,加上一个容器,用于和前端的容器swapclass AsyncLogging : boost::noncopyable { public: AsyncLogging(const string& basename, size_t rollSize,//log文件临界大小,存下之后超出它的话,则滚动文件原创 2017-09-28 19:56:56 · 498 阅读 · 0 评论 -
C++标准库算法 next_permutation
我们从C++参考上找到一个可能的实现。http://zh.cppreference.com/w/cpp/algorithm/next_permutation template<class BidirIt> bool next_permutation(BidirIt first, BidirIt last) { if (first == last) return false;//...原创 2018-03-28 23:31:02 · 596 阅读 · 0 评论 -
将模板类写在头文件里
如果要将声明和实现,分开,你需要这么做 //MyClass.h template class MyClass { public: MyClass(T x); ~MyClass(); private: T x; }; //MyClass.cpp template MyClass::MyClass(T x) { } template MyClass::~MyClass(原创 2017-11-22 22:02:56 · 1131 阅读 · 0 评论 -
muduo库源码学习(base):WeakCallback
// Copyright 2010, Shuo Chen. All rights reserved. // http://code.google.com/p/muduo/ // // Use of this source code is governed by a BSD-style license // that can be found in the License file. // //原创 2017-11-14 21:32:08 · 1546 阅读 · 1 评论 -
使用VS2017的跨平台项目进行linux开发
以编译base为例,基本过程如下: 搭建好Linux平台环境,安装boost等,(好像需要拷贝linux下的头文件到windows下,这个忘了) 代码里的头文件全部改成“./*.h”(试过不修改代码,但是添加目录的方法全失败了,我也不知道为什么) 项目类型选择静态库.a 然后。。。。编译通过,如此简单,以至于没什么可写的。 接下来像windows一样,使用这个库。过程如下原创 2017-09-13 17:25:12 · 11830 阅读 · 0 评论 -
muduo库源码学习(base):Logfile
本文件使用的是C++17版本 #ifndef MUDUO_BASE_LOGFILE_H #define MUDUO_BASE_LOGFILE_H #include #include #include namespace muduo { namespace FileUtil { class AppendFile; } class LogFile : noncopyable//文件日原创 2017-11-14 19:13:51 · 445 阅读 · 0 评论 -
muduo库源码学习(base)ThreadLocalSingleton
// Use of this source code is governed by a BSD-style license // that can be found in the License file. // // Author: Shuo Chen (chenshuo at chenshuo dot com) #ifndef MUDUO_BASE_THREADLOCALSINGLETON_原创 2017-11-05 00:41:49 · 278 阅读 · 0 评论 -
muduo库源码学习(base)ThreadLocal
// Use of this source code is governed by a BSD-style license // that can be found in the License file. // // Author: Shuo Chen (chenshuo at chenshuo dot com) #ifndef MUDUO_BASE_THREADLOCAL_H #define原创 2017-11-05 00:34:37 · 254 阅读 · 0 评论 -
muduo库源码学习(base)Date
muduo在时间上选择的是tm和timeSpec struct tm; namespace muduo { // // Date in Gregorian calendar. // // This class is immutable. // It's recommended to pass it by value, since it's passed in register on x64.原创 2017-10-26 12:07:04 · 413 阅读 · 0 评论 -
muduo库源码学习(base)Thread和CurrentThread
//CurrentThread,定义了一些辅助函数 namespace muduo { namespace CurrentThread { // internal extern __thread int t_cachedTid; extern __thread char t_tidString[32]; extern __thread int t_tidStringLength;原创 2017-10-26 11:38:02 · 1276 阅读 · 0 评论 -
muduo库源码学习(base)Condition
#ifndef MUDUO_BASE_CONDITION_H #define MUDUO_BASE_CONDITION_H #include "./Mutex.h" #include #include namespace muduo { class Condition : boost::noncopyable { public: explicit Condition(MutexL原创 2017-10-25 14:55:09 · 262 阅读 · 0 评论 -
muduo库源码学习(base)BlockingQueue和BoundBlockingQueue
#include "./Condition.h" #include "./Mutex.h" #include #include #include namespace muduo { template class BlockingQueue : boost::noncopyable//为多线程准备的队列 { public: BlockingQueue() : mutex_(原创 2017-10-25 13:52:52 · 261 阅读 · 0 评论 -
muduo库源码学习(base)singleton
/* SFINAE的意思是这样的,假如有一个特化会导致编译时错误(即出现编译失败),只要还有别的选择可以被选择, 那么就无视这个特化错误而去选择另外的可选选择。 这个示例中,如果我们给传的参数T类型为POD类型, 当调用detail::has_no_destroy::value时,T参数会在has_no_destroy类中实例化模板, 由于是POD类型,不具备no_destroy方法,不原创 2017-10-31 22:32:31 · 552 阅读 · 0 评论 -
muduo库源码学习(base)mutex
class MutexLock : boost::noncopyable//最常用的类.就是std::mutex,对应的还是lock_guard和unique_lock { public: MutexLock() : holder_(0) { MCHECK(pthread_mutex_init(&mutex_, NULL)); } ~MutexLock()原创 2017-10-31 22:24:14 · 306 阅读 · 0 评论 -
muduo库源码学习(base)FileUtil
class ReadSmallFile : boost::noncopyable { public: ReadSmallFile(StringArg filename); ~ReadSmallFile(); // return errno template int readToString(int maxSize,//最大的长度 Str原创 2017-10-31 21:31:03 · 411 阅读 · 0 评论 -
muduo库源码学习(base)Exception
class Exception : public std::exception { public: explicit Exception(const char* what); explicit Exception(const string& what); virtual ~Exception() throw(); virtual const char* what() const原创 2017-10-31 21:22:14 · 284 阅读 · 0 评论 -
二叉树的各种非递归遍历
struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; using node = TreeNode;/*先序遍历//根-左-右,修改入栈顺序可以变成 根-右-左,然后将结果逆序,就是后序遍历了。*///先序遍历的第一种写法。...原创 2018-05-20 02:31:17 · 261 阅读 · 0 评论
分享