Context object vs. function calls

function foo() { console.log(this.a); } var obj = { a: 2, foo: foo }; obj.foo(); Regardless of whether foo() is initially declared on obj, or is added as a reference later (as this snippet shows), in neither case is the function really "owned" or "contained" by the obj object. However... the…

Obtaining a std::shared_ptr from this pointer

std::enable_shared_from_this enables you to get a valid std::shared_ptr instance to this, when all you have is this. Without it, you would have no way of getting a std::shared_ptr to this, unless you had already one as a member. class Y: public std:…