Is there a standalone implementation of std::function?(是否有 std::function 的独立实现?)
问题描述
我正在开发嵌入式系统,因此代码大小是一个问题.使用标准库将我的二进制大小增加了大约 60k,从 40k 增加到 100k.我想使用 std::function,但我不能证明它是 60k 的.是否有我可以使用的独立实现,或类似的东西?我正在使用它在 c++ 11 中使用绑定变量在成员函数中隐式转换 lambda.
I'm working on an embedded system, so code size is an issue. Using the standard library ups my binary size by about 60k, from 40k to 100k. I'd like to use std::function, but I can't justify it for 60k. Is there a standalone implementation that I can use, or something similar? I'm using it to implicitly cast lambdas in member functions with bound variables in c++ 11.
推荐答案
60k 来自编译器添加的异常处理,因为 std::function 需要异常.std::function 只抛出一个异常,bad_function_call".所以我删除了引发异常的代码,现在如果调用一个空函数,它会出现错误,我为自己节省了 60k.
The 60k came from exception handling being added by the compiler, because exceptions were required for std::function. std::function only throws one exception, "bad_function_call". So I removed the code that threw the exception, now it seg faults if an empty function is called, and I saved myself 60k.
这篇关于是否有 std::function 的独立实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否有 std::function 的独立实现?


基础教程推荐
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 常量变量在标题中不起作用 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30