_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,一经查实,立即删除!

相关文章

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…

[VMware WorkStation]虚拟机网络

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

火狐中的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∈…

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…

NSString 练习

//将“⽂文艺⻘青年”改成“213⻘青年”。 NSString *str "文艺青年"; NSString *str1 [str stringByReplacingOccurrencesOfString:"文艺" withString:"213"]; NSLog("%",str1); //将 整数123 转换为字符串“123”。 NSString *s …

linux编译运行build.sh,linux下libwebsockets编译及实例

最近想自己搭建一个webscoket协议的服务器&#xff0c;打算用libwebsockts这个库。下载代码编译。编写一个shell脚本#!/bin/sh# wget http://git.warmcat.com/cgi-bin/cgit/libwebsockets/snapshot/libwebsockets-1.4-chrome43-firefox-36.tar.gz# tar xvzf libwebsockets-1.4-…

Tomcat如何配置环境变量

1&#xff0c; JDK&#xff1a;版本为jdk-7-windows-i586.exe 下载地址: http://www.oracle.com/technetwork/java/javase/downloads/index.html 2&#xff0c;tomcat&#xff1a;版本为apache-tomcat-7.0.33-windows-x86.zip 下载地址&#xff1a;http://tomcat.apache.org/ 2…

反编译查看源码dex2jar

为什么80%的码农都做不了架构师&#xff1f;>>> 上次说到了用apktool反编译&#xff0c;这次我们来用dex2jar 把apk解压得到文件夹 文件夹打开看到这些文件 其中这个classes.dex就是这次需要用到的字节码文件 把这个字节码文件托到dex2jar目录里 命令行编辑 得到下…

代码混淆之后定位线上bug

代码混淆的目的 代码混淆的目的是防止竞争对手通过反编译来阅读项目代码。 Android中通过ProGuard来做代码混淆&#xff08;当然也还有其他的产品可以做代码混淆&#xff09;。 bug日志反混淆 资料&#xff1a;错误log、mapping.txt 异常log&#xff1a; mapping.txt&#xff…

本地通知

本地通知&#xff0c;local notification&#xff0c;用于基于时间行为的通知&#xff0c;比如有关日历或者todo列表的小应用。另外&#xff0c;应用如果在后台执行&#xff0c;iOS允许它在受限的时间内运行&#xff0c;它也会发现本地通知有用。比如&#xff0c;一个应用&…

把windows装到linux下,如何将WSL(Windows Subsystem for Linux 2)安装到Windows 10?

原标题&#xff1a;如何将WSL(Windows Subsystem for Linux 2)安装到Windows 10&#xff1f;Windows 10凭借大受欢迎的WSL(Windows Subsystem for Linux)进入Linux领域。由于最近推出了WSL的最新版WSL2&#xff0c;用户现在可以利用实际的Linux内核从Windows执行Linux任务。现在…

vba执行linux命令,从VBA中的shell命令捕获输出值?

慕盖茨4494581根据Andrew Lessard的回答&#xff0c;这是一个运行命令并将输出作为字符串返回的函数 -Public Function ShellRun(sCmd As String) As StringRun a shell command, returning the output as a stringDim oShell As ObjectSet oShell CreateObject("WScript…

C#= 栈模仿堆的操作

//原理&#xff0c;利用两个栈&#xff0c;互相作用&#xff0c;来模仿堆的效果&#xff0c;先进先出。。 1 using System;2 using System.Collections.Generic;3 using System.Linq;4 using System.Threading.Tasks;5 6 namespace TwoStacksQueue7 {8 public class Progra…

linux中内部命令有哪些,linux内部命令有哪些

linux中常见的内部命令有&#xff1a;1.exit命令&#xff0c;退出当前的shell&#xff1b;2.history命令&#xff0c;显示历史执行过的命令&#xff1b;3.cd命令&#xff0c;切换当前工作目录&#xff1b;4.source命令&#xff0c;重新执行刚修改的初始化文件&#xff1b;5.ech…

POJ 2778

题意&#xff1a;很Uva项链题目类似。 区别&#xff1a; 1、字符串很多&#xff0c;用map hash超时&#xff0c;用Trie查找。 2、DFS判断连通&#xff0c;和并查集判连通&#xff0c;被我写错的地方时&#xff0c;查森林的时候&#xff0c;还是要Find_Set。 1 #include <ios…

linux挂载VMFS硬盘,ESX4.1挂载NFS共享存储(VMkernel)

要使用vmotion,iscsi,nfs功能&#xff0c;必须启用VMkernel端口&#xff0c;ESX 4.1默认不启用&#xff0c;ESXi 5.x默认启用。在 vCenter Server“SZVCENTER01”上调用对象“datastoreSystem-44”的“HostDatastoreSystem.CreateNasDatastore” 失败。挂载NFS存储的ESX控制台命…

2017年8个最流行的Web编程趋势

互联网一直在不断的发展&#xff0c;这意味着开发人员必须及时了解当前的所有变化。人们在新闻、社交、购物到银行等各大方面都与互联网有着千丝万缕的联系。因此&#xff0c;为了满足全球数百万网络用户的需求&#xff0c;Web开发需求正在上升。Web编程趋势是在W开发的过程中不…

gRPC-rs:从 C 到 Rust

介绍 在上篇文章中&#xff0c;我们讲到 TiKV 为了支持 [gRPC]&#xff0c;我们造了个轮子 [gRPC-rs]&#xff0c;这篇文章简要地介绍一下这个库。首先我们来聊聊什么是 gRPC。gRPC 是 Google 推出的基于 [HTTP2] 的开源 RPC 框架&#xff0c;希望通过它使得各种微服务之间拥有…