, , . ; . , operator[] -. - operator== . , std:: map operator [] , .
(, , [1] Foo &):
class SomeProxy
{
private:
Foo* f;
public:
explicit SomeProxy(Foo& i_f): f(&i_f) {}
operator Foo&() const {return *f;}
};
SomeProxy Database::operator[](unsigned int n)
{
return SomeProxy(some_array + n);
}
bool operator==(const SomeProxy& lhs, const Foo& rhs)
{
}
bool operator==(const SomeProxy& lhs, const SomeProxy& rhs);
bool operator==(const Foo& lhs, const SomeProxy& rhs);
: , (- ), , Foo, , , : operator==, operator[] .
, SomeProxy private . , : ( []), ( ), Foo/ , .