
C++
文章平均质量分 54
此曲只应天上有
coding lover
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
C++11 实现线程同步:一个生产者一个缓冲区一个消费者
main.cpp#include <iostream>#include <thread>#include <mutex>#include <condition_variable>#include <chrono>#include <queue>std::mutex mtx_producer, mtx_consumer;std::condition_variable cv_producer, cv_consumer;s原创 2020-11-24 22:47:10 · 802 阅读 · 0 评论 -
boost bind和function结合使用
function是函数包装器,bind可以绑定普通函数和类成员函数。当function的返回值和形成都被声明为void时,可以接收被bind修饰的任意函数类型。如:#include "boost/function.hpp"#include "boost/bind.hpp"#include <iostream>class Task{public: bool Bind(boost::function<void()> func) { if原创 2020-07-28 17:56:41 · 133 阅读 · 0 评论 -
c++ 数字和字符串之间的转换方式
atoi 不会exceptionto_string 有exceptionboost::lexical_cast 会exceptionstringstream 不会exception原创 2020-04-21 20:20:17 · 196 阅读 · 0 评论 -
boost split和tokenizer
split和tokenizer都可以分割字符串split需要开辟空间vector std::string sChannel(0;1;2); std::vector<std::string> vsChannel; boost::split(vsChannel, sChannel, boost::is_any_of(";"), boo...原创 2020-04-21 16:41:46 · 242 阅读 · 0 评论 -
C++使用时的一些细节问题
在头文件中声明本命名空间以为的类时,应该在本命名空间外面进行声明重载类的赋值=运算符时,如果形参不是类本身,则=相当于函数重载,支持不同类型的赋值...原创 2020-03-19 11:20:30 · 123 阅读 · 0 评论 -
动态链接库存在继承关系时如何导出
如果使用方需要实例化子类,就必须导出子类,基类可以不导出,如:zoo.h#ifdef BUILD_DLL#define __OWNER#endif#ifdef __OWNER#define IMPORT_EXPORT __declspec(dllexport)#else#define IMPORT_EXPORT __declspec(dllimport)#endifen...原创 2020-03-17 09:24:22 · 428 阅读 · 0 评论 -
lambda表达式排序
struct Test{std::string sName;int64_t iCode;};std::vector myVec;Test myTest;myTest.sName = “BAC1”;myVec.push_back(myTest);myTest.sName = “BAC2”;myVec.push_back(myTest);myTest.sName = “BAC1”...原创 2020-03-13 17:26:22 · 189 阅读 · 0 评论 -
c++社区网站
http://www.drdobbs.com/cpp/http://www.cplusplus.com/ 这个的论坛不错。http://www.codeproject.com/ 有一些很优秀的articles。http://www.cprogramming.com/ 这个网站用来学习和进阶是很有用的参考。...原创 2020-03-05 10:17:28 · 646 阅读 · 0 评论 -
boost正则表达式匹配并且截取想要的字符串
#include "boost/regex.hpp"string SubString(std::string sInuputName){ boost::smatch mat; // 匹配结果 boost::regex reg("[\\D]+"); // 匹配非数字 boost::regex_search(sInuputName,mat,reg); return *mat.begin()...原创 2019-11-30 15:45:51 · 963 阅读 · 0 评论 -
C++工厂类和单例模式的结合使用
单例模式: 简单来说一个类只有一个实例且封装性好。这里用宏定义实现。animal_singleton.h#pragma once#include <iostream>#define IMPLEMENTION_SINGLETON_CLASS( Type ) \public: \ static Type* GetIn原创 2016-05-26 21:42:05 · 2852 阅读 · 1 评论