原创 使用VS2017的跨平臺項目進行linux開發

以編譯base爲例,基本過程如下:linux安裝boost(反正你是寫C++的,你乾脆windows和linux都裝吧),拷貝linux下的頭文件到VS的文件夾下(我的vs是社區版,注意不要光會複製粘貼),以防萬一,將原來的include

原创 muduo庫源碼學習(base):Logfile

本文件使用的是C++17版本 #ifndef MUDUO_BASE_LOGFILE_H #define MUDUO_BASE_LOGFILE_H #include <muduo/base/Mutex.h> #include <muduo

原创 二叉樹的各種非遞歸遍歷

struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; usi

原创 muduo庫源碼學習(base)Date

muduo在時間上選擇的是tm和timeSpec struct tm; namespace muduo { // // Date in Gregorian calendar. // // This class is immutable

原创 muduo庫源碼學習(base)ThreadLocalSingleton

// Use of this source code is governed by a BSD-style license // that can be found in the License file. // // Author: S

原创 將模板類寫在頭文件裏

如果要將聲明和實現,分開,你需要這麼做 //MyClass.h template<class T=int> class MyClass { public: MyClass(T x); ~MyClass(); priva

原创 muduo庫源碼學習(base):WeakCallback

// Copyright 2010, Shuo Chen. All rights reserved. // http://code.google.com/p/muduo/ // // Use of this source code is

原创 C++標準庫算法 next_permutation

我們從C++參考上找到一個可能的實現。http://zh.cppreference.com/w/cpp/algorithm/next_permutation template<class BidirIt> bool next_permut

原创 muduo庫源碼學習(base)Exception

class Exception : public std::exception { public: explicit Exception(const char* what); explicit Exception(const s

原创 VS2017錯誤:未將對象引用設置到對象的實例

裝完python模塊之後運行程序就出現這個錯誤。網上搜了一堆方法都是改註冊表。 知乎上有個解決方法:打開--C:\Users\用戶名\AppData\Local\Microsoft\VisualStudio\,把文件全部刪了,再打開vs就

原创 muduo庫源碼學習(base)ThreadLocal

// Use of this source code is governed by a BSD-style license // that can be found in the License file. // // Author: S

原创 muduo庫源碼學習(base)Atomic

template<typename T> class AtomicIntegerT : boost::noncopyable { public: AtomicIntegerT() : value_(0) { }

原创 muduo庫源碼學習(base)FileUtil

class ReadSmallFile : boost::noncopyable { public: ReadSmallFile(StringArg filename); ~ReadSmallFile(); // retu

原创 muduo庫源碼學習(base)mutex

class MutexLock : boost::noncopyable//最常用的類.就是std::mutex,對應的還是lock_guard和unique_lock { public: MutexLock() : hol

原创 muduo庫源碼學習(base)Condition

#ifndef MUDUO_BASE_CONDITION_H #define MUDUO_BASE_CONDITION_H #include "./Mutex.h" #include <boost/noncopyable.hpp> #