[Boost-bugs] [Boost C++ Libraries] #11625: BOOST_TEST( ..., per_element() ) erroneously requires collections are comparable

Subject: [Boost-bugs] [Boost C++ Libraries] #11625: BOOST_TEST( ..., per_element() ) erroneously requires collections are comparable
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-09-07 10:50:01


#11625: BOOST_TEST( ..., per_element() ) erroneously requires collections are
comparable
-------------------------------------+-------------------------------------
 Reporter: Tony Lewis | Type: Bugs
  <tonyelewis@…> | Milestone: To Be Determined
   Status: new | Version: Boost 1.57.0
Component: None | Keywords:
 Severity: Problem | BOOST_TEST,per_element,collections,comparable,element,range,equality
-------------------------------------+-------------------------------------
 Thanks for the new BOOST_TEST() and per_element() tools, which look very
 useful.

 Unfortunately, I'm having trouble with comparing collections that aren't
 themselves comparable but have comparable elements.

 As I understand
 [http://www.boost.org/libs/test/doc/html/boost_test/testing_tools/extended_comparison/collections.html#boost_test.testing_tools.extended_comparison.collections.requirements
 the requirements documentation] for the BOOST_TEST / per_element() tools,
 they should only require that the two collections' ''elements'' are
 comparable, not necessarily the two collections themselves. I think this
 approach makes a lot of sense.

 However, when I try to compile the following under either `g++ -std=c++11`
 or `clang -std=c++11 -stdlib=libc++`, the compilers complain that
 collections aren't comparable :

 {{{#!cpp
 #define BOOST_TEST_MODULE comp_by_elem_mod

 #include <boost/test/included/unit_test.hpp>

 #include <iterator>
 #include <vector>

 struct my_class final {
         std::vector<int> the_ints = { 1, 2, 3 };

         using const_iterator = std::vector<int>::const_iterator;

         const_iterator begin() const {
                 return std::begin( the_ints );
         }
         const_iterator end() const {
                 return std::end( the_ints );
         }
 };

 BOOST_AUTO_TEST_CASE( comp_by_elem ) {
         const my_class a{};
         const std::vector<int> b = { 1, 2, 3 };
         BOOST_TEST( a == b, ::boost::test_tools::per_element() );
 }

 }}}

 I'll attach compiler errors.

 Many thanks.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11625>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC