MXS-1503: Add EqualPointees<T> template

The templated provides an unary predicate for (shared) pointers that
allows containers containing pointers to objects to be searched, not by
pointer comparisons but by comparisons of the values that they point
to. This allows std::find_if to be used with shared pointers in a similar
manner that std::find is used with non-pointer objects.
This commit is contained in:
Markus Mäkelä
2018-03-29 17:24:52 +03:00
parent 14e399dd68
commit 98fb2cf5ed
2 changed files with 27 additions and 16 deletions

View File

@ -89,22 +89,6 @@ public:
*/
bool eq(const SessionCommand& rhs) const;
class Equals: public std::unary_function<const SSessionCommand&, bool>
{
public:
Equals(const SSessionCommand& base):
m_base(base)
{}
bool operator ()(const SSessionCommand& rhs)
{
return m_base->eq(*rhs);
}
private:
const SSessionCommand& m_base;
};
private:
mxs::Buffer m_buffer; /**< The buffer containing the command */
uint8_t m_command; /**< The command being executed */