strstream veraltet?



  • Moin Leuts,

    ich habe in einem Program folgenden Code gefunden:

    #include <strstream>
    
    ...
    string line;
    ...
    //
    istrstream iss (cmdline.c_str());
    istream_iterator<string> beg (iss), end;
    

    Beim Compilieren mit dem g++ 3.2 unter Suse kommt die Warnung:

    In file included from /usr/include/g++/backward/strstream:51,
    from main.cpp:4:
    /usr/include/g++/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.

    Preisfrage: Wie erhalte ich einen Code, der ohne Warnung übersetzt? Dazu darf strstream nicht mehr included werden ... aber woher bekomme ich dann meinen istrstream oder eine äquivalente Lösung?

    Grüße LAOES



  • LAOES schrieb:

    Preisfrage: Wie erhalte ich einen Code, der ohne Warnung übersetzt? Dazu darf strstream nicht mehr included werden ...

    Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.



  • <sstream> einbinden und die Klassen heißen dann istringstream, ostringstream, stringstream.



  • Ja es funktioniert, danke!


Anmelden zum Antworten