CppCon 2017: Sven Over “folly::Function: A Non-copyable Alternative to std::function”

24204 months ago

Published on October 11, 2017
Uploaded By: CppCon


Presentation Slides, PDFs, Source Code and other presenter materials are available at: https://github.com/CppCon/CppCon2017

We have often found it limiting that std::function cannot store callable objects if they are not copyable, so we developed and open-sourced folly::Function, a function wrapper that can store move-only callable objects. This presentation outlines the design decisions behind folly::Function and illustrates their consequences and our experiences after 18 months of wide production use at Facebook.

We find folly::Function is more appropriate than std::function for typical use cases, such as storing callback functions and submitting tasks for asynchronous execution. Other features of folly::Function include that it is noexcept-movable, and it avoids some known issues regarding const-correctness in std::function, which allows to invoke non-const operations on a const reference. Instead, folly::Function lets you declare whether a callable may or may not mutate its state (e.g. folly::Function<void() const>).

Sven Over: Software Engineer, Facebook

Sven completed a PhD in astro-particle physics before he turned full time software engineer. He worked on C++ data services at Last.fm, and is now at Facebook London.

Videos Filmed & Edited by Bash Films: http://www.BashFilms.com