>>821
こんな感じです。
g++のバージョンは8.3で-std=gnu++1z でコンパイルしています。
-- ソースファイル
#include <string>
int main(int argc, char** argv) {
std::string str="abcd";
std::string::const_iterator it = str.cend();
str.insert(it, 'a');
return 0;
}
-- エラーメッセージ
testinsert.cpp: In function ‘int main(int, char**)’:
testinsert.cpp:6:21: error: no matching function for call to ‘std::basic_string<char>::insert(std::basic_string<char>::const_iterator&, char)’
str.insert(it, 'a');
^
In file included from /opt/rh/devtoolset-8/root/usr/include/c++/8/string:52,
from testinsert.cpp:1:
/opt/rh/devtoolset-8/root/usr/include/c++/8/bits/basic_string.h:4419:7: note: candidate: ‘void std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::iterator, std::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >; typename _Alloc::rebind<_CharT>::other::pointer = char*; std::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’
insert(iterator __p, size_type __n, _CharT __c)
^~~~~~
【初心者歓迎】C/C++室 Ver.106【環境依存OK】
■ このスレッドは過去ログ倉庫に格納されています
823デフォルトの名無しさん
2021/08/24(火) 09:47:42.50ID:HAU1OEWW■ このスレッドは過去ログ倉庫に格納されています
ニュース
- 【W杯1次リーグA組】南アフリカ1−0韓国 チェコ0ー3メキシコ/最終戦 [征夷大将軍★]
- 【W杯】韓国が南アに敗退 3位でGL終了、ラウンド32進出は他試合結果次第に。3連勝メキシコが首位&南アフリカが初の決勝Tへ [阿弥陀ヶ峰★]
- 【MLB】大谷翔平、第2子は男児と明かす [ネギうどん★]
- 【米紙報道】高市首相「コングレッショナルフェロー(官職)」経歴詐称疑惑… ★6 [BFU★]
- 【米紙報道】高市首相「コングレッショナルフェロー(官職)」経歴詐称疑惑… ★5 [BFU★]
- 【サッカー】日本代表、決勝Tの相手が確定! 2位通過ならブラジルと対戦、逆転1位ならモロッコと対戦… X戦々恐々「どっちも怖い」 [冬月記者★]
- 【地上波/DAZNほか】 FIFAワールドカップ2026 総合スレ★176【メキシコ/カナダ/アメリカ】
- 【地上波/DAZNほか】 FIFAワールドカップ2026 総合スレ★177【メキシコ/カナダ/アメリカ】
- 【MLB】ツインズ vs ドジャース ★7
- MLB総合★50
- こいせん 全レス転載禁止
- ハム専 ★7
- 【安倍悲報】トンボ鉛筆佐藤の思い出 [279951338]
- 【エロ注意】刃牙最新話に高市早苗登場wwww [177316839]
- 韓国0-1南アフリカ(後半20分) [667744927]
- 【悲報】自衛隊、機密システムを中国系ウイルスに1年間占領される [834922174]
- ワールドカップ、韓国vs南アフリカ
- 【悲報】まんさん「ヤマトの集荷…何時に来るの?」「人の時間奪うって事わからないかな」 [394133584]