Find a value in a set of shared_ptr
(In C++14) Make your comparator a transparent one and define additional logic for comparing stored shared_ptr
s with int
s:
struct Compare
{
using is_transparent = void;
// ~~~~~~~~~~~~~^
bool operator() (const IntPtr& a, const IntPtr& b) const
{
return *a < *b;
}
bool operator() (const IntPtr& a, int b) const
{
return *a < b;
}
bool operator() (int a, const IntPtr& b) const
{
return a < *b;
}
};
DEMO