Monthly Archives: April 2014

Functional Stalemate

The other day I had occasion to write something along the lines of struct SomeClass { std::function<void ()> m_thisWillBeCalledLater; void SetFunc(std::function<void ()> func) { m_thisWillBeCalledLater = std::move(func); } }; class Foo; struct HandleUnique { HandleUnique (std::unique_ptr<Foo> foo_p): m_foo_p (std::move (foo_p)) {} std::unique_ptr<Foo> m_foo_p; void operator()() const { m_foo_p->Frobnobicate(); } }; SomeClass obj; obj.SetFunc(HandleUnique(std::make_unique<Foo>())); This code […]

Pointing the Way Redux, Part 2: References

Continuing on with my series going into way more detail than anyone probably wants to go into about which reference type to use when, we now arrive at part 2: references (see motivation and part 1). Most of the time, by returning a reference to an object you’re making the statement that the object referred […]