【初心者歓迎】C/C++室 Ver.106【環境依存OK】at TECH
【初心者歓迎】C/C++室 Ver.106【環境依存OK】 - 暇つぶし2ch852:デフォルトの名無しさん
21/08/24 09:47:42.50 HAU1OEWW.net
>>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)
^~~~~~


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch