Operator overload

A a;

if(a) <--- this will trigger operator bool() and also operator void const*() const{


boost style
(typedef T * (this_type::*unspecified_bool_type)() const;operator unspecified_bool_type() const // never throws{return px == 0? 0: &this_type::get;})

if (a == "ss") <-- a combinations of few operator overload.

Foo(std::string const& s);
Foo(std::string s);

bool operator==(Foo const& lhs, Foo const& rhs);

For []

int& operator[] (unsigned i) { return data[i]; }

class A
enum enA { A1, A2, A3 };
A() { }
~A() { }

operator A::enA() { return A2; }


void Fn(A::enA e)
std::cout << "Fn(A::enA)\n";


A a;
Fn(a); // Will call Fn(A::enA) due to overload of operator A::enA()


Popular posts from this blog

Clearcase check in/uncheck out all the checked out files script

Duplicating a local copy of project from TFS and making web software client factory to work