Could not easily find a solution online...
I have something similar to the following.
class Color {
public:
Color(std::string n) : name(n) {}
typedef std::tr1::shared_ptr<Color> Ptr;
std::string name;
};
meanwhile elsewhere...
void Function()
{
std::vector<Color::Ptr> myVector;
Color::Ptr p1 = Color::Ptr(new Color("BLUE") );
Color::Ptr p2 = Color::Ptr(new Color("BLUE") );
// Note: p2 not added.
myVector.push_back( p1 );
// This is where my predicament comes in..
std::find( myVector.begin(), myVector.end(), p2 );
}
How would I write this so my std::find would actually deference the smart_pointers and compare the objects strings rather than their memory addresses? My first approach was to write a custom std::equal function however it does not accept templates as its own template types.