Subject: [Boost-bugs] [Boost C++ Libraries] #9223: Alllow find(key) with key's type different from the contained value type.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-10-10 11:56:49
#9223: Alllow find(key) with key's type different from the contained value type.
------------------------------+------------------------
Reporter: mjklaim@⦠| Owner: igaztanaga
Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: container
Version: Boost 1.54.0 | Severity: Problem
Keywords: |
------------------------------+------------------------
In a test, I have this:
{{{
struct Id
{
int value;
};
bool operator==( const Id& a, const Id& b )
{
return a.value == b.value;
}
bool operator< ( const Id& a, const Id& b )
{
return a.value < b.value;
}
struct Event
{
Id id;
std::string data;
};
bool operator==( const Entity& a, const Entity& b )
{
return a.id == b.id;
}
bool operator< ( const Entity& a, const Entity& b )
{
return a.id < b.id;
}
bool operator==( const Id& a, const Entity& b )
{
return a == b.id;
}
bool operator==( const Entity& a, const Id& b )
{
return b == a;
}
}}}
Here value type Event can be compared to Id.
Now this test can't work:
{{{
boost::container::flat_set<Event> events;
events.find( Id{42} ); // ERROR: Id isn't an Event!
}}}
I would like this to compile because it would allow me to have a set of
objects containing a state which can be overridden. In this test Event's
value is it's id, but it contain associated data too which are not part of
the comparison and can change when we insert new Events with the same id
but different data.
This feature looks like a recent c++ proposal: n3573
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9223> 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:14 UTC