_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.pswp.cn/news/258003.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/258003.shtml
英文地址,請注明出處:http://en.pswp.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…