[qt4, c++14] string .replace() .erase() no matching function 오류 도와주세요

신상우@Google의 이미지

qt 에서 코딩해서 빌드로 에러를 잡고있는데,

string 클래스의 함수를 써서 replace 나 erase 함수를 사용하는 데 있어서, 틀린 문법이라고 생각하지 않는데

basic string 클래스 안에 포함된 오버로딩된 replace, erase 함수들을 인식을 못하고 빌드에러가 뜹니다.

basic_string&
replace(size_type pos, size_type n, const basic_string& str) ;
이런 코드가 있는데도 인식이 안된다니요 ㅠㅠㅠ

구글에도 전혀 나오질 않습니다. 이런 문제는 본 적이 없습니다.
도와주십쇼 ㅠ

코드는 대충 ..

#include

int analyze(const string& result) {

if (result.size() > 10) {
string sub = result.substr(0, 10);
if(sub.compare("안녕 " == 0){
result.replace(0, 10, ""); // 에러 코드 줄
}
}

result.erase(std::remove(result.begin(), result.end(), ' '), result.end()); // 에러 코드 줄

............................... 생략

return 0;
}

build issues :
error: no matching function for call to ‘std::basic_string::replace(std::basic_string::size_type, std::basic_string::size_type, std::string) const’

error: no matching function for call to ‘std::basic_string::erase(__gnu_cxx::__normal_iterator >, std::basic_string::const_iterator) const’

ifree의 이미지

qt 4 버전이면 컴파일러는 무얼 쓰시나요?

신상우@Google의 이미지


gcc g++ 5버전 사용하고 있습니다!

소신있게

세벌의 이미지

qt5 아니고 qt4 쓰는 특별한 까닭이 있나요?
qt4는 공식 지원이 끊어질 텐데요...

https://wiki.debian.org/Qt4Removal

신상우@Google의 이미지

실습하고 있는 회사에서 사용하고 있는 qt 버전이 4 버전이기 때문에 사용하고 있습니다..ㅠㅠ

혹시 이 오류가 qt5 와 qt4의 차이로 생기는 오류일 수가 있을까요 .. ?

소신있게

ktd2004의 이미지

result 객체가 const인게 문제가 되는 것 같습니다.

신상우@Google의 이미지

정말이네요 .. ! 간단한 문제였는데, 너무 오래 붙잡고 있었습니다.

감사합니다. 해결완료 되었습니다!!

소신있게

세벌의 이미지

해결 축하드리고요.

kldp 에서 소소코드를 올릴 때 code 태그를 사용하면 소스가 제대로 보입니다.

신상우@Google의 이미지

감사합니다

참고해서 올리도록 하겠습니다!

소신있게

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.