bitset assignment

From: Andy Skypeck (askypeck_at_earthlink.net)
Date: 12/03/03


Date: 3 Dec 2003 08:45:34 -0800

I have a question concerning the use of the [] operator in bitset
asignment.

bitset<4> a("1100");
bitset<4> b("0011");

a[i] = a[j];

Is clearly supported by the standard, and works with all the C++
compilers I have worked with. But what about

a[i] = b[j]; // ?

Assume that there are no indices out of range.
This works with gcc-3.* and MSVC 6 and higher but fails on an older
Borland compiler. I contend that this is ok because both a[i] and
b[j] return type bitset<N>::reference. Others say no, but for
unspecified reasons. Does anybody
have an authoritative answer?



Relevant Pages

  • Re: Cant understand this! (Help required please)
    ... Yes and some online courses NETG does not seem to understand what ... > New to programming: ... I have heard of comeau don't they make compilers too? ... An argument I have used many times myself, I want to learn standard C++, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: GCC
    ... The header names changed explicitly to ... The Standard says that the standard ... that did not put iostream into the std namespace. ... and compilers change along with them. ...
    (Debian-User)
  • Re: subroutine stack and C machine model
    ... Herb has found out that a+bis ... Peter: But the STANDARD says... ... Most compilers have left to right evaluation as it happens. ... evidence appear to be more than one piece of evidence. ...
    (comp.lang.c)
  • Re: Should anyone be using modern Fortran any more?
    ... (Getting compilers to run or run with the right set of options has nothing to do with language standard.) ... any sort of computer language is a "convenience" - you could always go an work at the machine instruction level! ... on teaching and upgrading programmers by employers or the self-employed ...
    (comp.lang.fortran)
  • Re: man 3 switch
    ... As C is an ISO standard, I sincerely doubt there would be any ... syntax and behaviour of the keywords between C compilers on any Unix-like ... of arithmetic operators of equal precedence in the same statement (in ... The languages themselves normally aren't. ...
    (Fedora)