Boost logo

Boost :

Subject: Re: [boost] [utility/swap] MSVC 10 test failure, unsigned long to std::bitset conversion invalid?
From: Niels Dekker - address until 2010-10-10 (niels_address_until_2010-10-10_at_[hidden])
Date: 2010-03-08 11:36:08

Robert Stewart wrote:
> I agree that your test isn't about initialization, but I'd have
> thought the better thing would be to conditionally compile MSVC 10
> initialization logic to avoid breaking any other working platform.

Thanks Robert. But I'm not /entirely/ sure if the compile errors in the the
test code are a true *bug* in the MSVC 10 release candidate. You see, the
test code said:

  typedef std::bitset<8> bitset_type;
  const bitset_type initial_value1 = 1ul;
  const bitset_type initial_value2 = 2ul;

And C++0x no longer offers a bitset(unsigned long) constructor, according to
the Working Draft at

>> So I just committed that little modification of std_bitset.cpp to the
>> trunk:
>> My idea is just to look at the regression page for a week or
>> so, to see if it doesn't cause any other test failures.
>> Otherwise, we have to do something else....

> Watching for regressions is certainly good, but I still think you
> would be wise to apply an initialization workaround for the failing
> platforms and leave the rest alone.

I think I understand your point of view. But personally I'd rather have all
platforms compiling the same code, instead of having platform-specific
#ifdef's. Of course there are situations when platform-specific #ifdef's
are necessary, but I'd rather avoid them.

Anyway, do you think the lines of code I committed yesterday are at least
*supposed* to work on all platforms?

  typedef std::bitset<8> bitset_type;
  const bitset_type initial_value1 = 1;
  const bitset_type initial_value2 = 2;

Otherwise, if there is really no platform-independent way to initialize a
std::bitset by means of an integer type of argument, I think I'd rather go
for string literals:

  typedef std::bitset<8> bitset_type;
  const bitset_type initial_value1("01");
  const bitset_type initial_value2("10");

Kind regards,


Niels Dekker
Scientific programmer at LKEB, Leiden University Medical Center

Boost list run by bdawes at, gregod at, cpdaniel at, john at