网站首页 站内搜索

搜索结果

查询Tags标签: std,共有 1098条记录
  • 《Effective Modern C++》学习笔记之条款三十四:优先选用lambda表达式,而非std::bind

    1. 先来点历史资料 std::bind是C++98中std::bind1st和std::bind2nd的后继特性,但是作为一种非标准特性而言,std::bind在2005年就已经是标准库的组成部分了。正是在那时,标准委员会接受了名称TR1的文档,里面就包含了std::bind的规格(在TR1中,bind位于不同的名字空间,…

    2022/3/19 17:57:53 人评论 次浏览
  • C++ 11 利用std::queue创建安全队列 等待队列

    头文件:#include <mutex> #include <queue> #include <functional> #include <future> #include <thread> #include <utility> #include <vector>#include <condition_variable>class SafeQueue { private:std::queue&l…

    2022/3/19 17:27:52 人评论 次浏览
  • 【Example】C++ 标准库多线程同步及数据共享 (std::future 与 std::promise)

    阅读此文章前,务必读懂:【Example】C++ 标准库 std::thread 与 std::mutex 否则你会像听天书一样懵。(...)====================================在任何语言的多线程编程当中,必然涉及线程的同步及数据的共享,方式也有很多种。 C++ 标准库当中提供了同步及共享的方案:…

    2022/3/19 9:27:41 人评论 次浏览
  • C++ Primer阅读心得(第十七章)

    C++ Primer阅读心得(第十七章) c++11标准库中新增了临时数据组合的tuple类型(python万岁!)。类似pair,我们可以通过make_tuple创造一个tuple,通过get获得其中的一个元素,通过tuple_size获得tuple中的元素个数,通过tuple_element获得tuple中指定元素的类型。tuple…

    2022/3/19 1:28:08 人评论 次浏览
  • SFINAE几种实现方式

    一、通过函数返回值实现template<class T> typename std::enable_if<std::is_trivially_default_constructible<T>::value>::type construct(T*) {std::cout << "default constructing trivially default constructible T\n"; }templa…

    2022/3/11 23:20:37 人评论 次浏览
  • c++随机字符串生成

    #include <iostream> #include <random> #include <ctime> #include <chrono>namespace ShellRandom {static std::uniform_int_distribution<int> diProbability_;static std::default_random_engine dre_;template<class T>T DiRan…

    2022/3/11 12:14:56 人评论 次浏览
  • std::ostream & operator<<

    #include <iostream> #include <iostream> #include <string>class test{ public:test(const std::string _domain,const std::string _interface,const std::string _instance); private:std::string domain_;std::string interface_;std::string inst…

    2022/3/10 23:15:25 人评论 次浏览
  • C++11 线程池

    cpp #include<thread> #include<mutex> #include<vector> #include<condition_variable> #include<boost/circular_buffer.hpp> #include<functional> #include<atomic> #include<cassert>class ThreadPool { public:exp…

    2022/3/9 22:14:44 人评论 次浏览
  • 04

    #include<iostream> using namespace std;void fun(int* a, int* b) {int x = *a;*a = *b;*b = x;cout << *a << *b << " "; } int main() {int x = 1, y = 2;fun(&x, &y);cout << x << y << endl;return 0;…

    2022/3/8 23:18:06 人评论 次浏览
  • 03

    <!DOCTYPE html> <html><head><meta charset="utf-8"><title>表格</title></head><body><!-- table 表格tr 行td 列th 表头列 自动加粗且居中--><!--table的属性border 控制有无边框width 表格的宽度…

    2022/3/8 23:17:58 人评论 次浏览
  • 【Example】C++ 回调函数及 std::function 与 std::bind

    回调函数是做为参数传递的一种函数,在早期C样式编程当中,回调函数必须依赖函数指针来实现。 而后的C++语言当中,又引入了 std::function 与 std::bind 来配合进行回调函数实现。 标准库中有大量函数应用到了回调函数,其中 std::sort 就是一个经典例子。一,回调函数回…

    2022/3/5 9:15:09 人评论 次浏览
  • C++ 通用锁管理

    lock_guard 类 lock_guard 是互斥体包装器,为在作用域块期间占有互斥提供便利 RAII 风格机制。 创建 lock_guard 对象时,它试图接收给定互斥的所有权。控制离开创建 lock_guard 对象的作用域时,销毁 lock_guard 并释放互斥。 lock_guard 类不可复制。 成员类型mutex_ty…

    2022/3/3 1:17:31 人评论 次浏览
  • C++ atomic

    atomic 每个 std::atomic 模板的实例化和全特化定义一个原子类型。若一个线程写入原子对象,同时另一线程从它读取,则行为良好定义。 另外,对原子对象的访问可以建立线程间同步,并按 std::memory_order 所对非原子内存访问定序。 std::atomic 既不可复制亦不可移动。 成…

    2022/3/3 1:16:07 人评论 次浏览
  • 记录编译链接高博ORBSLAM2_with_pointcloud_map时两个比较费力的问题

    两个orbslam2_modified中make报错但网上很难找到直接答案的问题: 一. build Optimizer.cc的过程中提示g2o函数参数不正确在build过程中Optimizer.cc出现类似下述开头的no matching function for call to错误: no matching function for call to ‘g2o::BlockSolver<g…

    2022/3/2 23:46:28 人评论 次浏览
  • 【PAT乙级】1011 A+B 和 C (15 分) C++实现

    题目描述代码示例: #include<iostream> using namespace std; int main(){int n;long long int a[3];cin >> n;bool b[n];for(int i = 0;i<n;i++){for(int j=0;j<3;j++){std::cin>>a[j];}if(a[0]+a[1]>a[2]) b[i]=1;else b[i] = 0;}for(int i…

    2022/3/2 1:22:01 人评论 次浏览
扫一扫关注最新编程教程