Opened 7 years ago

Closed 7 years ago

#11778 closed Bugs (wontfix)

Cannot test C++11 "enum class" types

Reported by: Adam Nielsen <a.nielsen@…> Owned by: Gennadiy Rozental
Milestone: To Be Determined Component: test
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

If you use the test tools with C++11 variables of type "enum class", compilation fails with many iostream errors, mostly variations on this one:

/usr/include/boost/test/tools/detail/print_helper.hpp:50:14: note:   cannot convert ‘t’ (type ‘const Example’) to type ‘const std::error_code&’
         ostr << t;

Attachments (1)

test.cpp (261 bytes ) - added by Adam Nielsen <a.nielsen@…> 7 years ago.
Minimal example demonstrating problem

Download all attachments as: .zip

Change History (4)

by Adam Nielsen <a.nielsen@…>, 7 years ago

Attachment: test.cpp added

Minimal example demonstrating problem

comment:1 by Raffi Enficiaud, 7 years ago

The problem says that the variable is not printable. Would you please confirm that using

BOOST_TEST_DONT_PRINT_LOG_VALUE

(documented here) solves the issue?

Thanks.

comment:2 by Adam Nielsen <a.nielsen@…>, 7 years ago

Yes that does work - sorry I didn't realise you had already catered for this situation! I had assumed it would be possible to simply convert the enums to ints when printing, but then enum class types can't be inherited so I imagine it's not possible to handle enum classes in a generic way like this.

I don't suppose there's any way a static_assert or similar could be used to at least get an error message that makes it look less like a problem with the library code?

Either way thanks for your help!

comment:3 by Gennadiy Rozental, 7 years ago

Resolution: wontfix
Status: newclosed

In development version you'll get nicer error message about this kind of errors

Note: See TracTickets for help on using tickets.