The only valid syntax to declare a const reference to an std::string
is 'std::string const & first' or 'const std::string & first'. Putting
the const qualifier elsewhere is an error.

Get a C++ book, teach yourself and stop spamming this list.
Your questions are not only too basic but also off-topic. That is
a warning. I am not willing to be unhelpful but at the moment
the only thing helpful (to this list) is telling you to STFU. If you don't,
someone would have to make it happen by force.


------------------                               
Best regards,
lh_mouse
2016-07-17

-------------------------------------------------------------
发件人:Jim Michaels <[email protected]>
发送日期:2016-07-17 01:46
收件人:mingw64 users
抄送:
主题:[Mingw-w64-public] g++ throwing compiler out with the bathwater

build 0708 (internally 0609)

#include <stdio.h>
#include <string>
#include <vector>
namespace str {
     //string type for S like std::string, std::wstring, etc.
     int compare(std::string& first const, std::string& second const, 
bool iCase=false, size_t firstPos=0) const {
...

}

I had thought the problem might be the & reference, so I dropped those 
and same error message.  g++ seems to now be throwing errors on any 
syntax. it must be royally confused. and it still doesn't like ) on 
functions.


Sat 07/16/2016 
10:37:03.31|C:\Users\Kristina\Desktop\prj\eolconvert\1.0\win|>g++ -v 
-save-temps -DTEST -s -static -lstdc++ -std=c++11 -o 32\eolconvert.exe
eolconvert.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/gcc-7-win32/bin/../libexec/gcc/i686-w64-mingw32/7.0.0/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: /home/cauchy/vcs/svn/gcc/trunk/configure 
--prefix=/home/cauchy/native/gcc-7-win32 
--with-sysroot=/home/cauchy/native/gcc-7-win32 --build=x
86_64-unknown-linux-gnu --host=i686-w64-mingw32 
--target=i686-w64-mingw32 --disable-multilib --disable-nls 
--disable-win32-registry --disable-gcov-tool --e
nable-checking=release --enable-languages=c,c++,fortran 
--enable-fully-dynamic-string --with-arch=core2 --with-tune=generic
Thread model: win32
gcc version 7.0.0 20160609 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-D' 'TEST' '-s' '-static' 
'-std=c++11' '-o' '32\eolconvert.exe' '-mtune=generic' '-march=core2'
  c:/gcc-7-win32/bin/../libexec/gcc/i686-w64-mingw32/7.0.0/cc1plus.exe 
-E -quiet -v -iprefix 
c:\gcc-7-win32\bin\../lib/gcc/i686-w64-mingw32/7.0.0/ -isysroot
  c:\gcc-7-win32\bin\../../gcc-7-win32 -U_REENTRANT -D TEST 
eolconvert.cpp -mtune=generic -march=core2 -std=c++11 -fpch-preprocess 
-o eolconvert.ii
ignoring duplicate directory 
"c:/gcc-7-win32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.0.0/../../../../include/c++/7.0.0"
ignoring duplicate directory 
"c:/gcc-7-win32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.0.0/../../../../include/c++/7.0.0/i686-w64-mingw32"
ignoring duplicate directory 
"c:/gcc-7-win32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.0.0/../../../../include/c++/7.0.0/backward"
ignoring duplicate directory 
"c:/gcc-7-win32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.0.0/include"
ignoring nonexistent directory 
"c:\gcc-7-win32\bin\../../gcc-7-win32/home/cauchy/native/gcc-7-win32/lib/gcc/i686-w64-mingw32/7.0.0/../../../../include"
ignoring duplicate directory 
"c:/gcc-7-win32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.0.0/include-fixed"
ignoring duplicate directory 
"c:/gcc-7-win32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.0.0/../../../../i686-w64-mingw32/include"
ignoring nonexistent directory 
"c:\gcc-7-win32\bin\../../gcc-7-win32/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
  
c:\gcc-7-win32\bin\../lib/gcc/i686-w64-mingw32/7.0.0/../../../../include/c++/7.0.0
  
c:\gcc-7-win32\bin\../lib/gcc/i686-w64-mingw32/7.0.0/../../../../include/c++/7.0.0/i686-w64-mingw32
  
c:\gcc-7-win32\bin\../lib/gcc/i686-w64-mingw32/7.0.0/../../../../include/c++/7.0.0/backward
  c:\gcc-7-win32\bin\../lib/gcc/i686-w64-mingw32/7.0.0/include
  c:\gcc-7-win32\bin\../lib/gcc/i686-w64-mingw32/7.0.0/include-fixed
  
c:\gcc-7-win32\bin\../lib/gcc/i686-w64-mingw32/7.0.0/../../../../i686-w64-mingw32/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-D' 'TEST' '-s' '-static' 
'-std=c++11' '-o' '32\eolconvert.exe' '-mtune=generic' '-march=core2'
  c:/gcc-7-win32/bin/../libexec/gcc/i686-w64-mingw32/7.0.0/cc1plus.exe 
-fpreprocessed eolconvert.ii -quiet -dumpbase eolconvert.cpp 
-mtune=generic -march=co
re2 -auxbase eolconvert -std=c++11 -version -o eolconvert.s
GNU C++11 (GCC) version 7.0.0 20160609 (experimental) (i686-w64-mingw32)
         compiled by GNU C version 7.0.0 20160609 (experimental), GMP 
version 6.1.0, MPFR version 3.1.4-p2, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++11 (GCC) version 7.0.0 20160609 (experimental) (i686-w64-mingw32)
         compiled by GNU C version 7.0.0 20160609 (experimental), GMP 
version 6.1.0, MPFR version 3.1.4-p2, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 85f4626b884448f9672ebbd3379aa3ed
eolconvert.cpp:6:32: error: expected ',' or '...' before 'const'
   int compare(std::string first const, std::string second const, bool 
iCase=false, size_t firstPos=0) const {
                                 ^~~~~
eolconvert.cpp:6:102: error: non-member function 'int 
str::compare(std::__cxx11::string)' cannot have cv-qualifier
   int compare(std::string first const, std::string second const, bool 
iCase=false, size_t firstPos=0) const {
^~~~~
eolconvert.cpp: In function 'int str::compare(std::__cxx11::string)':
eolconvert.cpp:7:39: error: 'firstPos' was not declared in this scope
           size_t 
middle=((first.size()-firstPos)/2)+((first.size()-firstPos)%2)+firstPos,i;
                                        ^~~~~~~~
eolconvert.cpp:9:23: error: 'second' was not declared in this scope
           if (firstPos+second.size()>first.size()) return -2;//problem 
with using an int
                        ^~~~~~
eolconvert.cpp:10:27: error: 'second' was not declared in this scope
           if (first.size()<second.size()) return -1;
                            ^~~~~~
eolconvert.cpp:11:27: error: 'second' was not declared in this scope
           if (first.size()>second.size()) return +1;
                            ^~~~~~
eolconvert.cpp:14:15: error: 'i' was not declared in this scope
           for (i=0; i <= (first.size()-firstPos)/*/2*/; i++) {
                ^
eolconvert.cpp:17:18: error: 'iCase' was not declared in this scope
               if (iCase) if 
(std::toupper(first.at(i+firstPos))<std::toupper(second.at(i))||std::toupper(first.at(first.size()-i+firstPos))<std::toupper(se
cond.at(second.size()-i))) return -1;
                   ^~~~~
eolconvert.cpp:17:77: error: 'second' was not declared in this scope
               if (iCase) if 
(std::toupper(first.at(i+firstPos))<std::toupper(second.at(i))||std::toupper(first.at(first.size()-i+firstPos))<std::toupper(se
cond.at(second.size()-i))) return -1;
^~~~~~
eolconvert.cpp:19:18: error: 'iCase' was not declared in this scope
               if (iCase) if 
(std::toupper(first.at(i+firstPos))>std::toupper(second.at(i))||std::toupper(first.at(first.size()-i+firstPos))>std::toupper(se
cond.at(second.size()-i))) return +1;
                   ^~~~~
eolconvert.cpp:19:77: error: 'second' was not declared in this scope
               if (iCase) if 
(std::toupper(first.at(i+firstPos))>std::toupper(second.at(i))||std::toupper(first.at(first.size()-i+firstPos))>std::toupper(se
cond.at(second.size()-i))) return +1;
^~~~~~
eolconvert.cpp:23:19: error: 'iCase' was not declared in this scope
               if (!iCase) if (            first.at(i+firstPos) <     
second.at(i)|| first.at(first.size()-i+firstPos)< second.at(second
.size()-i))  return -1;
                    ^~~~~
eolconvert.cpp:23:54: error: 'second' was not declared in this scope
               if (!iCase) if (            first.at(i+firstPos) <     
second.at(i)|| first.at(first.size()-i+firstPos)< second.at(second
.size()-i))  return -1;
                                                       ^~~~~~
eolconvert.cpp:25:19: error: 'iCase' was not declared in this scope
               if (!iCase) if (            first.at(i+firstPos) >     
second.at(i)|| first.at(first.size()-i+firstPos)> second.at(second
.size()-i))  return +1;
                    ^~~~~
eolconvert.cpp:25:54: error: 'second' was not declared in this scope
               if (!iCase) if (            first.at(i+firstPos) >     
second.at(i)|| first.at(first.size()-i+firstPos)> second.at(second
.size()-i))  return +1;
                                                       ^~~~~~
eolconvert.cpp:46:18: error: 'iCase' was not declared in this scope
               if (iCase) if 
(std::toupper(first.at(middle))<std::toupper(second.at(middle))) return -1;
                   ^~~~~
eolconvert.cpp:46:73: error: 'second' was not declared in this scope
               if (iCase) if 
(std::toupper(first.at(middle))<std::toupper(second.at(middle))) return -1;
^~~~~~
eolconvert.cpp:48:18: error: 'iCase' was not declared in this scope
               if (iCase) if 
(std::toupper(first.at(middle))>std::toupper(second.at(middle))) return +1;
                   ^~~~~
eolconvert.cpp:48:73: error: 'second' was not declared in this scope
               if (iCase) if 
(std::toupper(first.at(middle))>std::toupper(second.at(middle))) return +1;
^~~~~~
eolconvert.cpp:52:19: error: 'iCase' was not declared in this scope
               if (!iCase) if (first.at(middle)<second.at(middle)) 
return -1;
                    ^~~~~
eolconvert.cpp:52:47: error: 'second' was not declared in this scope
               if (!iCase) if (first.at(middle)<second.at(middle)) 
return -1;
                                                ^~~~~~
eolconvert.cpp:54:19: error: 'iCase' was not declared in this scope
               if (!iCase) if (first.at(middle)>second.at(middle)) 
return +1;
                    ^~~~~
eolconvert.cpp:54:47: error: 'second' was not declared in this scope
               if (!iCase) if (first.at(middle)>second.at(middle)) 
return +1;
                                                ^~~~~~
eolconvert.cpp: At global scope:
eolconvert.cpp:72:51: error: expected ',' or '...' before 'const'
   std::vector< size_t > find(std::string& haystack const, std::string& 
needle const, bool iCase=false, size_t pos=0) const {
                                                    ^~~~~
eolconvert.cpp:72:117: error: non-member function 'std::vector<unsigned 
int> str::find(std::__cxx11::string&)' cannot have cv-qualifier
   std::vector< size_t > find(std::string& haystack const, std::string& 
needle const, bool iCase=false, size_t pos=0) const {
^~~~~
eolconvert.cpp: In function 'std::vector<unsigned int> 
str::find(std::__cxx11::string&)':
eolconvert.cpp:76:41: error: 'needle' was not declared in this scope
            if ((0==haystack.size() && 0==needle.size()) || 
0==needle.size()) {
                                          ^~~~~~
eolconvert.cpp:82:23: error: 'needle' was not declared in this scope
    if (haystack.size()>needle.size()) {
                        ^~~~~~
eolconvert.cpp:85:24: error: 'needle' was not declared in this scope
    if (haystack.size()==needle.size() && 
0==compare(needle,haystack,iCase,pos)) {
                         ^~~~~~
eolconvert.cpp:85:68: error: 'iCase' was not declared in this scope
    if (haystack.size()==needle.size() && 
0==compare(needle,haystack,iCase,pos)) {
^~~~~
eolconvert.cpp:85:74: error: 'pos' was not declared in this scope
    if (haystack.size()==needle.size() && 
0==compare(needle,haystack,iCase,pos)) {
^~~
eolconvert.cpp:90:28: error: 'needle' was not declared in this scope
    if (0==compare(haystack, needle, iCase, i)) {
                             ^~~~~~
eolconvert.cpp:90:36: error: 'iCase' was not declared in this scope
    if (0==compare(haystack, needle, iCase, i)) {
                                     ^~~~~
eolconvert.cpp:94:7: error: 'pos' was not declared in this scope
    if (pos>=needle.size() || pos>=haystack.size()-needle.size() || 
pos>haystack.size()/4*4) {
        ^~~
eolconvert.cpp:94:12: error: 'needle' was not declared in this scope
    if (pos>=needle.size() || pos>=haystack.size()-needle.size() || 
pos>haystack.size()/4*4) {
             ^~~~~~
eolconvert.cpp:98:24: error: 'pos' was not declared in this scope
           for (size_t i=pos; i < haystack.size()-needle.size(); i++) {
                         ^~~
eolconvert.cpp:98:49: error: 'needle' was not declared in this scope
           for (size_t i=pos; i < haystack.size()-needle.size(); i++) {
                                                  ^~~~~~
eolconvert.cpp:99:37: error: 'iCase' was not declared in this scope
     if (0==compare(haystack, needle, iCase, i)) {
                                      ^~~~~
eolconvert.cpp: At global scope:
eolconvert.cpp:106:46: error: expected ',' or '...' before 'const'
   std::string str_replace(std::string& target const, std::string& 
findwhat const, std::string& replacewith const, size_t pos=0, bool 
iCase=false, bool all=
true) const {
                                               ^~~~~
eolconvert.cpp:106:161: error: non-member function 'std::__cxx11::string 
str::str_replace(std::__cxx11::string&)' cannot have cv-qualifier
   std::string str_replace(std::string& target const, std::string& 
findwhat const, std::string& replacewith const, size_t pos=0, bool 
iCase=false, bool all=
true) const {

       ^~~~~
eolconvert.cpp: In function 'std::__cxx11::string 
str::str_replace(std::__cxx11::string&)':
eolconvert.cpp:108:19: error: 'pos' was not declared in this scope
           size_t i=pos,prevpos=0;
                    ^~~
eolconvert.cpp:136:15: error: 'all' was not declared in this scope
           if (!all && (/*i*/vt = find(target,findwhat, iCase, 
prevpos)).size() != 0/*std::string::npos*/) {
                ^~~
eolconvert.cpp:136:41: error: 'findwhat' was not declared in this scope
           if (!all && (/*i*/vt = find(target,findwhat, iCase, 
prevpos)).size() != 0/*std::string::npos*/) {
                                          ^~~~~~~~
eolconvert.cpp:136:51: error: 'iCase' was not declared in this scope
           if (!all && (/*i*/vt = find(target,findwhat, iCase, 
prevpos)).size() != 0/*std::string::npos*/) {
                                                    ^~~~~
eolconvert.cpp:136:58: error: 'prevpos' was not declared in this scope
           if (!all && (/*i*/vt = find(target,findwhat, iCase, 
prevpos)).size() != 0/*std::string::npos*/) {
                                                           ^~~~~~~
eolconvert.cpp:139:26: error: 'replacewith' was not declared in this scope
     newS += prefindwhat + replacewith;//newS+=pre_findwhat + 
replacewith (prefindwhat+replaceWith)
                           ^~~~~~~~~~~
eolconvert.cpp:143:36: error: 'findwhat' was not declared in this scope
           while ((/*i*/vt = find(target,findwhat, iCase, 
prevpos)).size() != 0/*std::string::npos*/) {
                                     ^~~~~~~~
eolconvert.cpp:143:46: error: 'iCase' was not declared in this scope
           while ((/*i*/vt = find(target,findwhat, iCase, 
prevpos)).size() != 0/*std::string::npos*/) {
                                               ^~~~~
eolconvert.cpp:143:53: error: 'prevpos' was not declared in this scope
           while ((/*i*/vt = find(target,findwhat, iCase, 
prevpos)).size() != 0/*std::string::npos*/) {
                                                      ^~~~~~~
eolconvert.cpp:146:26: error: 'replacewith' was not declared in this scope
     newS += prefindwhat + replacewith;//newS+=pre_findwhat + 
replacewith (prefindwhat+replaceWith)
                           ^~~~~~~~~~~
eolconvert.cpp:149:32: error: 'prevpos' was not declared in this scope
           newS += target.substr(prevpos);//post
                                 ^~~~~~~
eolconvert.cpp: In function 'std::__cxx11::string 
str::stringReplace(std::__cxx11::string&, std::__cxx11::string&, 
std::__cxx11::string&, size_t, bool, boo
l)':
eolconvert.cpp:153:67: error: too many arguments to function 
'std::__cxx11::string str::str_replace(std::__cxx11::string&)'
    return str_replace(target, findwhat, replacewith, iCase, pos,all);
^
eolconvert.cpp:106:14: note: declared here
   std::string str_replace(std::string& target const, std::string& 
findwhat const, std::string& replacewith const, size_t pos=0, bool 
iCase=false, bool all=
true) const {
               ^~~~~~~~~~~
eolconvert.cpp: In function 'int main(int, char**)':
eolconvert.cpp:164:50: error: too many arguments to function 
'std::vector<unsigned int> str::find(std::__cxx11::string&)'
   std::vector<size_t> vpos=str::find(s,mid,false,0);
                                                   ^
eolconvert.cpp:72:24: note: declared here
   std::vector< size_t > find(std::string& haystack const, std::string& 
needle const, bool iCase=false, size_t pos=0) const {
                         ^~~~
eolconvert.cpp:200:3: error: 'fclose64' was not declared in this scope
    fclose64(fin);
    ^~~~~~~~
eolconvert.cpp:207:49: error: too many arguments to function 
'std::__cxx11::string str::str_replace(std::__cxx11::string&)'
    content=str::str_replace(content, "\r\n", "\r");
                                                  ^
eolconvert.cpp:106:14: note: declared here
   std::string str_replace(std::string& target const, std::string& 
findwhat const, std::string& replacewith const, size_t pos=0, bool 
iCase=false, bool all=
true) const {
               ^~~~~~~~~~~
eolconvert.cpp:208:47: error: too many arguments to function 
'std::__cxx11::string str::str_replace(std::__cxx11::string&)'
    content=str::str_replace(content, "\n", "\r");
                                                ^
eolconvert.cpp:106:14: note: declared here
   std::string str_replace(std::string& target const, std::string& 
findwhat const, std::string& replacewith const, size_t pos=0, bool 
iCase=false, bool all=
true) const {
               ^~~~~~~~~~~
eolconvert.cpp:209:49: error: too many arguments to function 
'std::__cxx11::string str::str_replace(std::__cxx11::string&)'
    content=str::str_replace(content, "\r", "\r\n");
                                                  ^
eolconvert.cpp:106:14: note: declared here
   std::string str_replace(std::string& target const, std::string& 
findwhat const, std::string& replacewith const, size_t pos=0, bool 
iCase=false, bool all=
true) const {
               ^~~~~~~~~~~


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public



------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to