# C++ General-Purpose Polymorphic Function Wrapper

## Introduction

C++ class template std::function is a general-purpose polymorphic function wrapper. It could wrap functions, functors, and lambda expressions allowing them to use the same argument type in the higher-order function.

In this blog post, I would like to show how to use std::function.

## Examples

To compile the program, please run the following command in the terminal.

## Conclusions

std::function is highly polymorphic, general-purpose, and versatile. So there will be significant runtime overhead. However, because it is so general-purpose, it is often used in the C++ callback interface so that the user could pass different kinds of callable implementations.

C++ General-Purpose Polymorphic Function Wrapper

https://leimao.github.io/blog/CPP-std-function/

Lei Mao

02-11-2020

02-27-2022