Opened 5 years ago
Closed 5 years ago
#13181 closed Feature Requests (fixed)
Boost test can't compare classes which have begin and end but not const_iterator
Reported by: | Owned by: | Raffi Enficiaud | |
---|---|---|---|
Milestone: | Boost 1.67.0 | Component: | test |
Version: | Boost 1.65.0 | Severity: | Regression |
Keywords: | Cc: |
Description
The following code:
struct s { const int *begin() const; const int *end() const; }; bool operator==(s,s); std::ostream &operator<<(std::ostream &out, s); BOOST_AUTO_TEST_CASE(foo) { s s1; s s2; BOOST_TEST(s1==s2); }
When compiled in C++14 mode by gcc or clang, fails because s
does not contain member types const_iterator
and value_type
. This works in C++03 mode, and it worked with boost 1.64.
The attached patch fixes the issue.
Attachments (1)
Change History (8)
by , 5 years ago
Attachment: | boost-test.diff added |
---|
comment:1 by , 5 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 5 years ago
Milestone: | To Be Determined → Boost 1.66.0 |
---|
comment:3 by , 5 years ago
- I mean compilation failure.
- I would prefer doing collection comparison for the better test failure messages, but it's fine if it uses the user-provided equality operator.
The workaround does work.
comment:4 by , 5 years ago
Merged to branch topic/13181-collection-compare-missing-typename
, but tests are failing, I will check
comment:6 by , 5 years ago
Milestone: | Boost 1.66.0 → Boost 1.67.0 |
---|
comment:7 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Type: | Bugs → Feature Requests |
In master
Note:
See TracTickets
for help on using tickets.
Thanks for the report and the patch, will apply for 1.66. A couple of questions:
value_type
andconst_iterator
(as well assize
). In your case, that would mean that your class will switch to the collection comparison, while you are providingoperator==
and I guess you expect that this operator will be used. What is your suggestion?As a workaround, does this
work as you expect?