boostorg / test

The reference C++ unit testing framework (TDD, xUnit, C++03/11/14/17)
http://boost.org/libs/test
Boost Software License 1.0
183 stars 140 forks source link

When using MSVC, collections always require their element type to be comparable #405

Open Marc-Aldorasi-Imprivata opened 12 months ago

Marc-Aldorasi-Imprivata commented 12 months ago
struct elem;
//bool operator==(const elem &, const elem &);
struct container {
    const elem *begin() const;
    const elem *end() const;
};
bool operator==(const container &, const container &);
std::ostream &operator<<(std::ostream &, const container &);

void foo(container &c)
{
    BOOST_TEST(c == c);
}

This fails to compile in MSVC unless the operator== declaration on the second line is uncommented. That operator does not need to be defined because it is never actually used, but MSVC will complain about its absence if it is not declared.