All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
function_view< Fn > Class Template Reference

#include <function_view.h>

Detailed Description

template<typename Fn>
class function_view< Fn >

function_view<R(T...)> is a lightweight non-owning generic callable object view, similar to a std::function<R(T...)>, but with much less overhead.

A function_view invocation should have the same cost as a function pointer (which it basically is underneath). Similar in spirit to a string_view or span, the function-like object that the function_view refers to MUST have a lifetime that outlasts any use of the function_view.

In contrast, a full std::function<> is an owning container for a callable object. It's more robust, especially with restpect to object lifetimes, but the call overhead is quite high. So use a function_view when you can.

This implementation comes from LLVM: https://github.com/llvm-mirror/llvm/blob/master/include/llvm/ADT/STLExtras.h

Definition at line 97 of file function_view.h.

The documentation for this class was generated from the following file: