cin >> std::min -->No operator ">>" matches these operands - SGI

This is a discussion on cin >> std::min -->No operator ">>" matches these operands - SGI ; For portability reasons, how can I compile the below code on SGI? #include #include int main () { int min; cout cout cin >> std::hex >> min; } CC file.cpp No operator ">>" matches these operands. the operand types are: ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: cin >> std::min -->No operator ">>" matches these operands

  1. cin >> std::min -->No operator ">>" matches these operands

    For portability reasons, how can I compile the below code on SGI?

    #include
    #include

    int main ()
    {
    int min;
    cout << "hour " << std::hex << c << endl;

    cout << "Enter min "";

    cin >> std::hex >> min;
    }

    CC file.cpp
    No operator ">>" matches these operands.
    the operand types are: istream_withassign >> .

    cin >> std::min;
    ^

    Thank you,
    Christopher Lusardi


  2. Re: cin >> std::min -->No operator ">>" matches these operands


    clusard...@aol.com wrote:
    >
    > CC file.cpp
    > No operator ">>" matches these operands.
    > the operand types are: istream_withassign >> .
    >
    > cin >> std::min;
    > ^
    >


    Sorry, I forgot to add that for readability I want to use:
    std::min!

    Thank you,
    Christopher Lusardi


  3. Re: cin >> std::min -->No operator ">>" matches these operands


    clusard...@aol.com wrote:
    >
    > CC file.cpp
    > No operator ">>" matches these operands.
    > the operand types are: istream_withassign >> .
    >
    > cin >> std::min;
    > ^
    >


    Sorry, I forgot to add that for readability I want to use:
    std::min!

    Thank you,
    Christopher Lusardi


  4. Re: cin >> std::min -->No operator ">>" matches these operands

    In article <1109615101.342186.301160@g14g2000cwa.googlegroups. com>,
    wrote:
    >For portability reasons, how can I compile the below code on SGI?
    >
    >#include
    >#include
    >
    >int main ()
    >{
    > int min;
    > cout << "hour " << std::hex << c << endl;
    >
    > cout << "Enter min "";
    >
    > cin >> std::hex >> min;
    >}

    Mixing and is confusing things.
    (the std namespace vs no std namespace)

    The variable 'c' above does not exist.
    The variable name 'min' in some contexts might conflict with
    a standard function.

    //Revised function, reads in in hex, outputs in decimal:
    #include
    #include

    int main ()
    {
    int minx;

    std::cout << "Enter min ";

    std::cin.setf(std::ios_base::hex,std::ios_base::ba sefield);
    std::cin >> minx;
    //cin >> std::hex >> minx;
    std::cout << minx << std::endl;
    }

    You don't mention what IRIX compiler release you use either.
    I tried the above on latest.

    Regards,
    David B. Anderson davea at sgi dot com http://reality.sgiweb.org/davea


  5. Re: cin >> std::min -->No operator ">>" matches these operands

    Your version of the posted program is a little different than mine. I
    feel you've been misled!

    On SGI and Linux, I want to do something like

    cin >> std::hex >> minx;

    and

    cout << "Min is " << std::hex << minx << endl;

    The reason I want to use identical code on both platforms is I have a
    lot of I/O and I don't want 2 versions of the same code.

    IE: I don't want to use the style of coding:

    #ifdef __sgi
    cin ..
    #else
    cin ..
    #endif

    On Linux, I went to "cout << std::hex << minx;" because that works,
    and on SGI "cout << hex << minx;" works. I want to find out how
    to use the Linux format on both computers.

    Your version of the code seem to be dependent on "setf" for output
    format!

    Also, to answer your questions:

    %CC -v
    MIPSpro Compilers: Version 7.4.2m

    When I compile the your version of the program, I get the following
    errors:

    The namespace "std" has no member "cin".

    The namespace "std" has no member "cout".

    The namespace "std" has no member "endl".

    Christopher Lusardi
    --------------------------------------------------------------
    #include
    #include

    int main ()
    {
    int minx;
    cout << "hour " << std::hex << 10 << endl; // or 0xc

    std::cout << "Enter minute "";

    cin >> std::hex >> minx;
    }


  6. Re: cin >> std::min -->No operator ">>" matches these operands


    Your version of the posted program is a little different than mine. I
    feel you've been misled!

    On SGI and Linux, I want to do something like

    cin >> std::hex >> minx;

    and

    cout << "Min is " << std::hex << minx << endl;

    The reason I want to use identical code on both platforms is I have a
    lot of I/O and I don't want two versions of the same code.

    IE: I don't want to use the following ugly style of coding:

    #ifdef __sgi
    cin ..
    #else
    cin ..
    #endif

    On Linux, I went to "cout << std::hex << minx;" because that works,
    and on SGI "cout << hex << minx;" works. I want to find out how
    to use the Linux format on both computers.

    Your version of the code seem to be dependent on "setf" for output
    format!

    Also, to answer your questions:

    %CC -v
    MIPSpro Compilers: Version 7.4.2m

    When I compile the "your" version of the program, I get the following
    errors:

    The namespace "std" has no member "cin".

    The namespace "std" has no member "cout".

    The namespace "std" has no member "endl".

    My version of the code (below)
    Christopher Lusardi
    --------------------------------------------------------------
    #include
    #include

    int main ()
    {
    int minx;
    cout << "hour " << std::hex << 10 << endl; // or 0xc

    std::cout << "Enter minute ";

    cin >> std::hex >> minx;
    }

    %CC file.cpp

    No operator ">>" matches these operands.
    the operand types are: istream_withassign >> .

    cin >> std::min;
    ^


  7. Re: cin >> std::min -->No operator ">>" matches these operands

    In article <1109694810.808038.30920@l41g2000cwc.googlegroups.c om>,
    wrote:
    >Your version of the posted program is a little different than mine. I
    >feel you've been misled!

    [..]

    Not mislead. But I did rewrite the example, as I did not
    think the original correct (but what do I know).

    >The reason I want to use identical code on both platforms is I have a
    >lot of I/O and I don't want 2 versions of the same code.


    Good motivation :-)

    [..]
    >On Linux, I went to "cout << std::hex << minx;" because that works,
    >and on SGI "cout << hex << minx;" works. I want to find out how
    >to use the Linux format on both computers.
    >
    >Your version of the code seem to be dependent on "setf" for output
    >format!


    Yes, well, see below, I was missing something in Josuttis "C++ Standard
    Library".

    >Also, to answer your questions:


    >%CC -v
    >MIPSpro Compilers: Version 7.4.2m


    Good. Thanks.


    >When I compile the your version of the program, I get the following
    >errors:
    >
    >The namespace "std" has no member "cin".
    >
    >The namespace "std" has no member "cout".
    >
    >The namespace "std" has no member "endl".


    Using 7.4.4 (unreleased) on my version, no errors.

    >--------------------------------------------------------------


    I don't think it makes much sense to mix the .h and non-.h
    header files! If you are going to write standard C++ use
    the new form.

    >#include
    >#include


    >int main ()
    >{
    > int minx;
    > cout << "hour " << std::hex << 10 << endl; // or 0xc
    >
    > std::cout << "Enter minute "";


    The above line is malformed, "" at end. Not compilable at all.
    Mixing cout and std::cout is strange.

    > cin >> std::hex >> minx;
    >}


    I could not find the short form in Josuttis yesterday
    so used setf form. Today I find it on page 622, same page
    as setf use. Sigh.

    Here is a version that seems to work with 7.4.4 and demonstrates
    that cin and std::hex works sensibly.


    goalie 30% ./a.out
    hour a
    Enter minute 22
    34
    goalie 31% cat stdmin2.cxx

    #include
    #include

    int main ()
    {
    int minx;
    std::cout << "hour " << std::hex << 10 << std::endl; // or 0xc

    std::cout << "Enter minute ";

    std::cin >> std::hex >> minx;
    // Now show we read in in hex
    std::cout < }


    Mixing header forms (.h and non-.h) makes me very nervous as
    SGI std-header-writers use the form as a clue whether to introduce
    the std:: namespace.

    All your environments *should* have non-.h for ios and iostream.

    Hope this helps.
    David B. Anderson davea at sgi dot com http://reality.sgiweb.org/davea

+ Reply to Thread