This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/5792: g++ fails with functions as arguments



>Number:         5792
>Category:       c++
>Synopsis:       g++ fails with functions as arguments
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 28 09:56:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     cagdasozgenc@hotmail.com
>Release:        3.0.4
>Organization:
>Environment:
redhat linux 7.2 dual pentium 800Mhz
>Description:
#include <map>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
typedef map<string,int> Index;
int main(int argc, char* argv[]) {
    Index index;
    ifstream ifs(argv[1]);
    string word;
    while(ifs >> word) {
        transform(word.begin(),word.end(),word.begin(),tolower);
        index[word]++;
    }
    cout.setf(ios::left);
    for(Index::const_iterator i = index.begin(); i != index.end(); ++i) {
        cout << setw(20) << i->first << " : " << i -> second << endl;
    }
    return 0;
}

transform function won't accept to lower without a typecast.
for_each function will not work either for the same reason.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]