Boost logo

Boost :

Subject: [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-06 09:50:46


There's a regression failure of Microsoft Visual C++ 10 on a unit test
of the boost::swap utility:
>
> ..\libs\utility\swap\test\std_bitset.cpp(20) : error C2440:
> 'initializing' : cannot convert from 'unsigned long' to
> 'std::bitset<_Bits>'
> No constructor could take the source type, or constructor
> overload resolution was ambiguous
>
> ..\libs\utility\swap\test\std_bitset.cpp(21) : error C2440

See
http://www.boost.org/development/tests/trunk/developer/output/RWVC10-boost-bin-v2-libs-utility-swap-test-std_bitset-test-msvc-10-0-debug-threading-multi.html

Do I understand correctly that MSVC 10 does not support implicit
conversion from unsigned long to std::bitset<N>?

The program "std_bitset.cpp" is at
http://svn.boost.org/svn/boost/trunk/libs/utility/swap/test/std_bitset.cpp
  It does:

   #include <bitset>

   int test_main(int, char*[])
   {
     typedef std::bitset<8> bitset_type;
     const bitset_type initial_value1 = 1ul; // Line 20.
     const bitset_type initial_value2 = 2ul; // Line 21.

     // [...]

     return 0;
   }

Can anyone here reproduce the compile error? If so, would it be helpful
to replace line 20 and 21 by using parentheses? As follows:

     const bitset_type initial_value1(1ul);
     const bitset_type initial_value2(2ul);

Kind regards,

   Niels

-- 
Niels Dekker
http://www.xs4all.nl/~nd/dekkerware
Scientific programmer at LKEB, Leiden University Medical Center

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk