原创 使用serialization 進行封包、解包

#include <boost/archive/binary_oarchive.hpp> #include <boost/archive/binary_iarchive.hpp> class CMyData   {   private:

原创 default,delete

class CTestEx { public:     CTestEx() = default;  //可以使用默認構造     CTestEx(c

原创 QueryPerformanceCounter/QueryPerformanceFrequency

INT64 EscapeTime() {     LARGE_INTEGER nFreq;     LARGE_INTEGER nBeginTime

原创 enable_if

1  導言 使用 enable_if 系列模板可以控制一個函數模板或類模板偏特化是否包含在基於模板參數屬性的一系列匹配函數或偏特化中。比如,我們可以定義一個只對某些類型(通過特徵類[traits class]定義)有效——當然也只匹配

原创 boost log

#include <boost/log/common.hpp>   #include <boost/log/expressions.hpp>   #

原创 VS 中捕獲內存泄露

內存泄露十分討厭,捕獲內存泄露更加令人厭煩…… 其實,VS本身就有內存泄露的檢測機制。只需做以下操作即可開啓。(同時必須在debug模式 下運行程序並且以 正常流程退出 ) // 在入口函數cpp中添加以下定義和頭文件  #define

原创 StrSafe.h 使用安全字符串操作函數

    const TCHAR P[] = _T("測試一下");     int nLen = sizeof(P)/sizeof(TCHAR); 

原创 enable_if

template<bool _Test, class _Ty = void> struct enable_if { // type is undefined for assumed !_Test }; template<cla

原创 enable_share_from_this

以前都沒有用過enable_shared_from_this模板類,雖然經常遇到但是也沒怎麼去關注,今天抽時間好好學習了下enable_shared_from_this模板類,發現在使用shared_ptr模板類和enable_share

原创 Boost - 序列化 (Serialization)

程序開發中,序列化是經常需要用到的。像一些相對高級語言,比如JAVA, C#都已經很好的支持了序列化,那麼C++呢?當然一個比較好的選擇就是用Boost,這個號稱C++準標準庫的東西。 什麼時候需要序列化呢?舉個例子,我們定義了一個cla

原创 log4cpp

#include "log4cpp/Category.hh" #include "log4cpp/OstreamAppender.hh" #include "log4cpp/BasicLayout.hh" #include "log4cp

原创 c++ bind functional

#include <algorithm> #include <memory> #include <functional> #include <vec

原创 archive

#include <fstream> #include <boost/archive/text_oarchive.hpp> #include <bo

原创 asio bind

void Write(const boost::system::error_code& error, std::size_t bytes_trans

原创 分解命令行以及環境變量函數

SHSTDAPI_(LPWSTR *)  CommandLineToArgvW(_In_ LPCWSTR lpCmdLine, _Out_ int* pNumArgs); 例:     PTSTR strCmd = GetCommand