Boost logo

Boost Users :

Subject: [Boost-users] [Test] BOOST_CHECK_EQUAL can't compare scoped enumerations
From: Merrill Cornish (merrill.cornish_at_[hidden])
Date: 2016-02-04 16:52:06


I'm running Windows 10, 64-bit, MinGW64 with GCC 5.3 64-bit, and
BOOST_1_60_0 64-bit.

Here is the stripped down version of what's failing:

     enum class UsedFor { NOTIFY_INPUT, CONST_INPUT, VAR_INPUT,
                          NOTIFY_RESULT, VAR_RESULT};
     UsedFor mUse = UsedFor::NOTIFY_INPUT;
     BOOST_CHECK(mUse == Operand::UsedFor::NOTIFY_INPUT);
// BOOST_CHECK_EQUAL(mUse, Operand::UsedFor::NOTIFY_INPUT);

If BOOST_CHECK_EQUAL() is commented out, BOOST_CHECK() complies and
executes without error.
However,

// BOOST_CHECK(mUse == Operand::UsedFor::NOTIFY_INPUT);
     BOOST_CHECK_EQUAL(mUse, Operand::UsedFor::NOTIFY_INPUT);

If BOOST_CHECK() is comment out, BOOST_CHECK_EQUAL() gets a template
barf with the general comment, " template argument
deduction/substitution failed:". Here are some of the complaints:

D:\Boost_1_60_0/boost/test/tools/detail/print_helper.hpp:50:14: note:
cannot convert 't' (type 'const
DiGSE::Operand_Class_Test_Suite::Operand_Default_Constructor_Test::test_method()::UsedFor')
to type 'std::_Setw'
          ostr << t;
               ^

D:/Program
Files/mingw-w64/x86_64-5.3.0-posix-seh-rt_v4-rev0/mingw64/x86_64-w64-mingw32/include/c++/iomanip:208:5:
note: candidate: template<class _CharT, class _Traits>
std::basic_ostream<_CharT, _Traits>&
std::operator<<(std::basic_ostream<_CharT, _Traits>&, std::_Setprecision)
      operator<<(basic_ostream<_CharT, _Traits>& __os, _Setprecision __f)

D:\Boost_1_60_0/boost/test/tools/detail/print_helper.hpp:50:14: note:
cannot convert 't' (type 'const
DiGSE::Operand_Class_Test_Suite::Operand_Default_Constructor_Test::test_method()::UsedFor')
to type 'std::_Setprecision'
          ostr << t;
                 ^

At this point, it seems to be complaining about every io manipulator in
existence.

D:\Boost_1_60_0/boost/test/tools/detail/print_helper.hpp:50:14: note:
mismatched types 'const std::piecewise_linear_distribution<_RealType>'
and 'const
DiGSE::Operand_Class_Test_Suite::Operand_Default_Constructor_Test::test_method()::UsedFor'
          ostr << t;

Then it gets to the point of, apparently, dragging out all of the error
messages it doesn't get to use very often:

  mismatched types*'const std::chi_squared_distribution<_RealType>' *and
'const
DiGSE::Operand_Class_Test_Suite::Operand_Default_Constructor_Test::test_method()::UsedFor'
          ostr << t;
               ^

For the time being, I can simply use the explicit == check, but it looks
like there's a problem here.

Merrill Cornish



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net