_M_invoke(_Index_tuple_Indices...)

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

[hadoop@iZ25s7cmfyrZ C_script]$ cat test_thread_a.cpp 
#include <iostream>
#include <atomic>
#include <thread>
#include <vector>std::atomic<int> global_counter(0);void increase_global (int n){for (int i=0; i< n; ++i)++global_counter;
}void increase_reference(std::atomic<int>& variable, int n){for (int i=0;i<n; ++i)++variable;
}struct C:std::atomic<int>{C():std::atomic<int>(0){}void increase_member(int n){for(int i=0;i<n;++i)fetch_add(1);}
};int main(int argc, char** argv){std::vector<std::thread> threads;std::cout << "Increase global counter with 10 threads...." << std::endl;for(int i=0;i<10;++i)threads.push_back(std::thread(increase_global, 1000));std::cout << "Increase counter (foo) with 10 threads using reference...\n";std::atomic<int> foo(0);for(int i=0;i<10;++i)threads.push_back(std::thread(increase_reference, std::ref(foo), 1000));std::cout << "Increase counter (bar) with 10 threads using member...\n";C bar{};for(int i=0;i<10;++i){threads.push_back(std::thread(&C::increase_member,std::ref(bar),1000));}std::cout << "synchronizing all threads...\n";for(auto& th:threads) th.join();std::cout << "global: " << global_counter << std::endl;std::cout << "foo: " << foo << std::endl;std::cout << "bar: " << bar << std::endl;
}

使用  g++ 编译上面的代码,结果因为存在歧义 将C bar{}(注有无{}都报这个错误) 将bar理解成一个 返回C 类型的函数, 文章中说https://en.wikipedia.org/wiki/Most_vexing_parse, 在c++11中已经修复这个错误,就是在 变量后面添加花括号, 但是没有用依然报错,

In file included from /usr/include/c++/4.8.2/thread:39:0,from test_thread_a.cpp:3:
/usr/include/c++/4.8.2/functional: In instantiation of ‘struct std::_Bind_simple<std::_Mem_fn<void (C::*)(int)>(std::reference_wrapper<C>, int)>’:
/usr/include/c++/4.8.2/thread:137:47:   required from ‘std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (C::*)(int); _Args = {std::reference_wrapper<C>, int}]’
test_thread_a.cpp:42:77:   required from here
/usr/include/c++/4.8.2/functional:1697:61: error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void (C::*)(int)>(std::reference_wrapper<C>, int)>’typedef typename result_of<_Callable(_Args...)>::type result_type;^
/usr/include/c++/4.8.2/functional:1727:9: error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void (C::*)(int)>(std::reference_wrapper<C>, int)>’_M_invoke(_Index_tuple<_Indices...>)

后来改用 clang++ 编译没有出现这个错误,特此记录

转载于:https://my.oschina.net/lCQ3FC3/blog/1359284

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/258003.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

十年后2023年再读这篇文章,看看我将会怎么样?

http://blog.csdn.net/wojiushiwo987/article/details/8453881看到一篇文章不错【清华差生10年奋斗经历】 &#xff0c;写给将要工作的自己&#xff0c;十年后2023年再读这篇文章&#xff0c;看看我将会怎么样&#xff1f; 在2012年收关时刻&#xff0c;看到如此激励的文章&…

1203正规式转换为有穷自动机

1 #include<stdio.h>2 #include <ctype.h>3 #define ok 14 #define error 05 #define MAXREGLUARLONG 406 #define MAXSTATELONG 40 7 #define MAXCAHRSLONG 40 8 typedef int state;9 int iCurrentState0; //初态以1开始10 int iPreState0;11 in…

fasttext的基本使用 java 、python为例子

fasttext的基本使用 java 、python为例子 今天早上在地铁上看到知乎上看到有人使用fasttext进行文本分类&#xff0c;到公司试了下情况在GitHub上找了下&#xff0c;最开始是c版本的实现&#xff0c;不过有Java、Python版本的实现了&#xff0c;正好拿下来试试手&#xff0c; p…

oracle spring 分页查询,SpringJDBC 调用oracle 通用存储过程分页

我博客前面有写道SpringJDBC调用通用的Oracle存储过程,今天来讲一下通用的Java存储过程带分页的功能,其中里面还有动态查询的SQL拼接,好的,先上代码1.Java代码Autowiredprivate JdbcTemplate jdbcTemplate;/**分页查询* return*/ResponseBodyRequestMapping(value "/find…

宝宝头三年至关重要,不看悔掉肠子

http://www.nowamagic.net/librarys/eight/posts/1885以下是一个早教工作者分享他关于现代父母早期教育中出现的问题和多数父母的误区。正如作者问自己的&#xff1a;“在孩子人生最重要的头三年&#xff0c;我做对了吗&#xff1f;在我的引导下&#xff0c;她能保持强烈的探索…

2015年底总结

2015-12-06 16:17&#xff0c;今天是周日&#xff0c;不需要加班的&#xff0c;到公司看看书&#xff0c;写写代码的&#xff0c;突然想到又是年底了&#xff01;需要写点东西来记录总结一下2015年了 年初的时候&#xff0c;入职现在这家成都游戏公司&#xff0c;到现在差不多也…

python脚本

01.用户三次登录锁定猜年龄游戏02.购物车省县市三级联动03.函数、文件操作实现数据增删改查---low版本04.ATM购物商城05.模拟计算器持续更新中...脚本很low&#xff0c;但我一直在学。。。转载于:https://blog.51cto.com/lyndon/1947437

oracle 命令日志输出,ORACLE常用命令日志

第一章&#xff1a;日志管理1.forcing log switchessql> alter system switch logfile;2.forcing checkpointssql> alter system checkpoint;3.adding online redo log groupssql> alter database add logfile [group 4]sql> (/disk3/log4a.rdo,/disk4/log4b.rdo) …

[VMware WorkStation]虚拟机网络

1、简介&#xff1a; vmware为我们提供了三种网络工作模式&#xff0c;它们分别是&#xff1a;Bridged&#xff08;桥接模式&#xff09;、NAT&#xff08;网络地址转换模式&#xff09;、Host-Only&#xff08;仅主机模式&#xff09;。在我安装了vmware workstation player 1…

阿里查出售假店主并索赔140万,这次是大数据帮的忙

阿里巴巴将平台上一家曾出售假货的网店起诉至深圳市龙岗区法院&#xff0c;以“违背平台不得售假约定、侵犯平台商誉”为由索赔140万元人民币。此案为国内首例电商平台起诉售假店主案。 阿里巴巴目前已经准备了一份超长起诉清单&#xff0c;计划以违背合同约定、侵犯商誉为由&a…

oracle 升级前备份,rac(exadata)升级前的备份及LVM快照的恢复

1、热备所有数据库热备脚本&#xff1a;10.1.1.200&#xff0c;/backup/scripts/whole_db_backup.sh2、在每个计算节点执行dbserver_backup.sh脚本Run script "dbserver_backup.sh" in each compute node. The script takes backup of "/boot" (to ROOT f…

我心中的MySQL DBA

原文网址链接&#xff1a;http://wangwei007.blog.51cto.com/68019/1718311 MySQL是一个跨平台的开源关系型数据库管理系统&#xff0c;目前MySQL被广泛地应用在Internet上的中小型网站中。由于其体积小、速度快、总体拥有成本低&#xff0c;尤其是开放源码这一特点&#xff0c…

Visual Studio 2015 前瞻 属性初始化赋值!

通常我们建立属性的时候如果带初始化值的时候我们经常会这样处理。 class MyClass{private string _name "hello world!";public string Name {get{return _name;}set{_name value;}}} 或者也可以这样写 &#xff1a; class MyClass{public string Name { set; get…

火狐中的CSS Grid Inspector新增强大的功能

2019独角兽企业重金招聘Python工程师标准>>> 上周&#xff0c;我谈到了日常的网站浏览我用Firefox&#xff0c;但是在切图网做前端开发的时候我会用Chrome。 随着每个版本&#xff0c;FF Nightly在开发工具箱中有一些越来越棒的工具&#xff0c;这些更新使Firefox成…

Linux内核态之间进程通信,内核态和用户态通信(二)--实现

本文主要使用netlink套接字实现中断环境与用户态进程通信。系统环境&#xff1a;基于linux 2.6.32.27 和 linux 3.16.36Linux内核态和用户态进程通信方法的提出和实现用户上下文环境运行在用户上下文环境中的代码是可以阻塞的&#xff0c;这样&#xff0c;便可以使用消息队列和…

上下文无关文法

在计算机科学中&#xff0c;若一个形式文法 G (N, Σ, P, S) 的产生式规则都取如下的形式&#xff1a;V -> w&#xff0c;则称之为上下文无关文法&#xff08;英语&#xff1a;context-free grammar&#xff0c;缩写为CFG&#xff09;&#xff0c;其中 V∈N &#xff0c;w∈…

centos 安装mysql时错误unknown variable #39;defaults-file=/opt/redmine-2.6.0-2/mysql/my.cnf#39;...

找到my.cnf所在目录。运行 chmod 664 my.cnf&#xff0c;再启动mysql成功

p5js可以在linux上运行吗,在linux上使用python运行phantomjs

我跟随this link&#xff0c;现在当我输入phan然后输入tab(\t)时&#xff0c;它会自动完成幻影JS。在但是&#xff0c;如果我运行phantomJS -v或phantomJS --version&#xff0c;我得到&#xff1a;bash: /usr/local/bin/phantomjs: /lib/ld-linux.so.2: bad ELF interpreter: …

使用Instant Client配置PL/SQL Developer

之前使用PL/SQL Developer都是直接在本机安装完整版的Oracle Database&#xff0c;一是省事&#xff0c;二是可以在本机做一些demo测试&#xff1b;最近换了台电脑&#xff0c;感觉Instant Client更简单一些&#xff0c;分分钟配好。 先下载Instant Client&#xff0c;注意&…

linux脚本转换exe,Ps1 To Exe(powershell脚本转换EXE工具) V3.0.6 官方版

Ps1 To Exe是款将PowerShell脚本转换为EXE可执行文件的软件。同时软件非常小巧&#xff0c;功能实用&#xff0c;软件还支持各国的语言&#xff0c;有需要的小伙伴们不要错过了。(点击图片查看高清大图)【软件特色】1、Ps1 To Exe 支持多种语言2、Ps1 To Exe使用简单&#xff0…