[](https://github.com/espressif/esp-boost/actions/workflows/pre-commit.yml) [](https://components.espressif.com/components/espressif/esp-boost)
# ESP Boost C++ Library
* [English Version](./README.md)
## 概述
esp-boost 是 Espressif 基于 [Boost](https://github.com/boostorg/boost) 移植的 C++ 库,用于 ESP 系列 SoCs(ESP32、ESP32-S3、ESP32-P4 等)开发 C++ 应用。
> [!NOTE]
> - esp-boost 移植的 Boost 库官方版本为 `1.87.0`。
> - esp-boost 中的绝大部分库都是直接从官方仓库拷贝而来。由于部分库具有平台依赖性,为了能够在 ESP-IDF 上进行编译,我们进行了必要的修改(如在 `config` 中新增 [esp32.hpp](src/boost/config/platform/esp32.hpp) 和 [esp32.cpp](src/boost/config/src/esp32.cpp))。所有修改的地方都会使用 `esp32` 注释标记。
> [!WARNING]
> - esp-boost 目前还未完全移植 Boost 中的所有库,仅移植了部分常用功能,具体支持情况请参考 [支持的库](#支持的库)。
> - 由于 Boost 很多库需要使用 C++ 的 `Exception` 和 `RTTI` 特性,而 ESP-IDF 默认禁用这两个特性,因此用户需要在 `menuconfig` 中开启 `CONFIG_COMPILER_CXX_EXCEPTIONS` 和 `CONFIG_COMPILER_CXX_RTTI` 配置选项。
## 目录
- [ESP Boost C++ Library](#esp-boost-c-library)
- [概述](#概述)
- [目录](#目录)
- [如何使用](#如何使用)
- [SDK 及依赖组件](#sdk-及依赖组件)
- [添加到工程](#添加到工程)
- [支持的库](#支持的库)
## 如何使用
### SDK 及依赖组件
在使用本库之前,请确保已安装符合以下版本要求的 SDK:
| **SDK** | **版本要求** |
| ----------------------------------------------- | ------------ |
| [esp-idf](https://github.com/espressif/esp-idf) | >= 5.3 |
> [!NOTE]
> * SDK 的安装方法请参阅 [ESP-IDF 编程指南 - 安装](https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/get-started/index.html#get-started-how-to-get-esp-idf)
### 添加到工程
esp-boost 已上传到 [Espressif 组件库](https://components.espressif.com/),您可以通过以下方式将其添加到工程中:
1. **使用命令行**
在工程目录下运行以下命令:
```bash
idf.py add-dependency "espressif/esp-boost"
```
2. **修改配置文件**
在工程目录下创建或修改 *idf_component.yml* 文件:
```yaml
dependencies:
espressif/esp-boost: "*"
```
详细说明请参阅 [Espressif 文档 - IDF 组件管理器](https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-guides/tools/idf-component-manager.html)。
## 支持的库
📋 以下是 esp-boost 支持的库列表:
> [!NOTE]
> 下面的表格中,图标和符号的含义如下:
> - ✅:表示该库已完全移植,并且内部使用官方的示例和测试进行了完整的验证。
> - ⚠️:表示该库仅移植了源码,但内部并未进行完整的验证测试。
> - ❌:表示没有相关的示例或测试。
| **名称** | **状态** | **文档** | **示例** | **测试** |
| --------------- | -------- | ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| signals2 | ✅️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/signals2/index.html) | [内部](./test_apps/signals2/example/) / [官方](https://github.com/boostorg/signals2/tree/boost-1.87.0/example) | [内部](./test_apps/signals2/test/) / [官方](https://github.com/boostorg/signals2/tree/boost-1.87.0/test) |
| thread | ✅️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/thread/index.html) | [内部](./test_apps/thread/example/) / [官方](https://github.com/boostorg/thread/tree/boost-1.87.0/example) | [内部 1](./test_apps/thread/test_common/) & [内部 2](./test_apps/thread/test_more/) / [官方](https://github.com/boostorg/thread/tree/boost-1.87.0/test) |
| algorithm | ✅️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/algorithm/index.html) | [内部](./test_apps/algorithm/example/) / [官方](https://github.com/boostorg/algorithm/tree/boost-1.87.0/example) | [内部](./test_apps/algorithm/test/) / [官方](https://github.com/boostorg/algorithm/tree/boost-1.87.0/test) |
| align | ✅️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/align/index.html) | ❌ | [内部](./test_apps/align/test/) / [官方](https://github.com/boostorg/align/tree/boost-1.87.0/test) |
| array | ✅️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/array/index.html) | ❌ | [内部](./test_apps/array/test/) / [官方](https://github.com/boostorg/array/tree/boost-1.87.0/test) |
| format | ✅️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/format/doc/format.html) | [内部](./test_apps/format/example/) / [官方](https://github.com/boostorg/format/tree/boost-1.87.0/example) | [内部](./test_apps/format/test/) / [官方](https://github.com/boostorg/format/tree/boost-1.87.0/test) |
| graph | ✅️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/graph/index.html) | [内部](./test_apps/graph/example/) / [官方](https://github.com/boostorg/graph/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/graph/tree/boost-1.87.0/test) |
| assert | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/assert/index.html) | ❌ | [官方](https://github.com/boostorg/assert/tree/boost-1.87.0/test) |
| atomic | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/atomic/index.html) | ❌ | [官方](https://github.com/boostorg/atomic/tree/boost-1.87.0/test) |
| bimap | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/bimap/index.html) | [官方](https://github.com/boostorg/bimap/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/bimap/tree/boost-1.87.0/test) |
| bind | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/bind/index.html) | ❌ | [官方](https://github.com/boostorg/bind/tree/boost-1.87.0/test) |
| chrono | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/chrono/index.html) | [官方](https://github.com/boostorg/chrono/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/chrono/tree/boost-1.87.0/test) |
| config | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/config/index.html) | ❌ | [官方](https://github.com/boostorg/config/tree/boost-1.87.0/test) |
| concept_check | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/concept_check/index.html) | ❌ | [官方](https://github.com/boostorg/concept_check/tree/boost-1.87.0/test) |
| container | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/container/index.html) | [官方](https://github.com/boostorg/container/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/container/tree/boost-1.87.0/test) |
| container_hash | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/container_hash/index.html) | ❌ | [官方](https://github.com/boostorg/container_hash/tree/boost-1.87.0/test) |
| conversion | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/conversion/index.html) | ❌ | [官方](https://github.com/boostorg/conversion/tree/boost-1.87.0/test) |
| core | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/core/index.html) | ❌ | [官方](https://github.com/boostorg/core/tree/boost-1.87.0/test) |
| date_time | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/date_time/index.html) | [官方](https://github.com/boostorg/date_time/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/date_time/tree/boost-1.87.0/test) |
| describe | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/describe/index.html) | [官方](https://github.com/boostorg/describe/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/describe/tree/boost-1.87.0/test) |
| detail | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/detail/index.html) | ❌ | [官方](https://github.com/boostorg/detail/tree/boost-1.87.0/test) |
| dynamic_bitset | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/dynamic_bitset/index.html) | [官方](https://github.com/boostorg/dynamic_bitset/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/dynamic_bitset/tree/boost-1.87.0/test) |
| endian | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/endian/index.html) | [官方](https://github.com/boostorg/endian/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/endian/tree/boost-1.87.0/test) |
| exception | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/exception/index.html) | [官方](https://github.com/boostorg/exception/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/exception/tree/boost-1.87.0/test) |
| foreach | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/foreach/index.html) | ❌ | [官方](https://github.com/boostorg/foreach/tree/boost-1.87.0/test) |
| function | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/function/index.html) | [官方](https://github.com/boostorg/function/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/function/tree/boost-1.87.0/test) |
| function_types | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/function_types/index.html) | [官方](https://github.com/boostorg/function_types/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/function_types/tree/boost-1.87.0/test) |
| fusion | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/fusion/index.html) | [官方](https://github.com/boostorg/fusion/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/fusion/tree/boost-1.87.0/test) |
| asio | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/asio/index.html) | [官方](https://github.com/boostorg/asio/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/asio/tree/boost-1.87.0/test) |
| io | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/io/index.html) | ❌ | [官方](https://github.com/boostorg/io/tree/boost-1.87.0/test) |
| integer | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/integer/index.html) | ❌ | [官方](https://github.com/boostorg/integer/tree/boost-1.87.0/test) |
| intrusive | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/intrusive/index.html) | [官方](https://github.com/boostorg/intrusive/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/intrusive/tree/boost-1.87.0/test) |
| iterator | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/iterator/index.html) | [官方](https://github.com/boostorg/iterator/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/iterator/tree/boost-1.87.0/test) |
| json | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/json/index.html) | [官方](https://github.com/boostorg/json/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/json/tree/boost-1.87.0/test) |
| lexical_cast | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/lexical_cast/index.html) | [官方](https://github.com/boostorg/lexical_cast/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/lexical_cast/tree/boost-1.87.0/test) |
| math | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/math/index.html) | [官方](https://github.com/boostorg/math/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/math/tree/boost-1.87.0/test) |
| move | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/move/index.html) | [官方](https://github.com/boostorg/move/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/move/tree/boost-1.87.0/test) |
| mp11 | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/mp11/index.html) | ❌ | [官方](https://github.com/boostorg/mp11/tree/boost-1.87.0/test) |
| mpl | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/mpl/index.html) | [官方](https://github.com/boostorg/mpl/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/mpl/tree/boost-1.87.0/test) |
| multi_index | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/multi_index/index.html) | [官方](https://github.com/boostorg/multi_index/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/multi_index/tree/boost-1.87.0/test) |
| optional | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/optional/index.html) | ❌ | [官方](https://github.com/boostorg/optional/tree/boost-1.87.0/test) |
| parameter | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/parameter/index.html) | ❌ | [官方](https://github.com/boostorg/parameter/tree/boost-1.87.0/test) |
| phoenix | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/phoenix/index.html) | [官方](https://github.com/boostorg/phoenix/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/phoenix/tree/boost-1.87.0/test) |
| pool | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/pool/index.html) | [官方](https://github.com/boostorg/pool/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/pool/tree/boost-1.87.0/test) |
| predef | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/predef/index.html) | ❌ | [官方](https://github.com/boostorg/predef/tree/boost-1.87.0/test) |
| preprocessor | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/preprocessor/index.html) | ❌ | [官方](https://github.com/boostorg/preprocessor/tree/boost-1.87.0/test) |
| property_map | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/property_map/index.html) | [官方](https://github.com/boostorg/property_map/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/property_map/tree/boost-1.87.0/test) |
| property_tree | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/property_tree/index.html) | [官方](https://github.com/boostorg/property_tree/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/property_tree/tree/boost-1.87.0/test) |
| proto | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/proto/index.html) | [官方](https://github.com/boostorg/proto/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/proto/tree/boost-1.87.0/test) |
| random | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/random/index.html) | [官方](https://github.com/boostorg/random/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/random/tree/boost-1.87.0/test) |
| range | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/range/index.html) | ❌ | [官方](https://github.com/boostorg/range/tree/boost-1.87.0/test) |
| ratio | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/ratio/index.html) | [官方](https://github.com/boostorg/ratio/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/ratio/tree/boost-1.87.0/test) |
| regex | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/regex/index.html) | [官方](https://github.com/boostorg/regex/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/regex/tree/boost-1.87.0/test) |
| serialization | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/serialization/index.html) | [官方](https://github.com/boostorg/serialization/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/serialization/tree/boost-1.87.0/test) |
| smart_ptr | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/smart_ptr/index.html) | [官方](https://github.com/boostorg/smart_ptr/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/smart_ptr/tree/boost-1.87.0/test) |
| spirit | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/spirit/index.html) | [官方](https://github.com/boostorg/spirit/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/spirit/tree/boost-1.87.0/test) |
| static_assert | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/static_assert/index.html) | [官方](https://github.com/boostorg/static_assert/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/static_assert/tree/boost-1.87.0/test) |
| system | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/system/index.html) | ❌ | [官方](https://github.com/boostorg/system/tree/boost-1.87.0/test) |
| test | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/test/index.html) | [官方](https://github.com/boostorg/test/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/test/tree/boost-1.87.0/test) |
| throw_exception | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/throw_exception/index.html) | ❌ | [官方](https://github.com/boostorg/throw_exception/tree/boost-1.87.0/test) |
| tokenizer | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/tokenizer/index.html) | [官方](https://github.com/boostorg/tokenizer/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/tokenizer/tree/boost-1.87.0/test) |
| tti | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/tti/index.html) | ❌ | [官方](https://github.com/boostorg/tti/tree/boost-1.87.0/test) |
| tuple | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/tuple/index.html) | ❌ | [官方](https://github.com/boostorg/tuple/tree/boost-1.87.0/test) |
| type_traits | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/type_traits/index.html) | ❌ | [官方](https://github.com/boostorg/type_traits/tree/boost-1.87.0/test) |
| typeof | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/typeof/index.html) | ❌ | [官方](https://github.com/boostorg/typeof/tree/boost-1.87.0/test) |
| unordered | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/unordered/index.html) | [官方](https://github.com/boostorg/unordered/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/unordered/tree/boost-1.87.0/test) |
| utility | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/utility/index.html) | ❌ | [官方](https://github.com/boostorg/utility/tree/boost-1.87.0/test) |
| variant | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/variant/index.html) | ❌ | [官方](https://github.com/boostorg/variant/tree/boost-1.87.0/test) |
| variant2 | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/variant2/index.html) | ❌ | [官方](https://github.com/boostorg/variant2/tree/boost-1.87.0/test) |
| winapi | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/winapi/index.html) | ❌ | [官方](https://github.com/boostorg/winapi/tree/boost-1.87.0/test) |
| xpressive | ⚠️ | [链接](https://www.boost.org/doc/libs/1_87_0/libs/xpressive/index.html) | [官方](https://github.com/boostorg/xpressive/tree/boost-1.87.0/example) | [官方](https://github.com/boostorg/xpressive/tree/boost-1.87.0/test) |
8c18ef17580e00c1c440a516b1c7511475dbecd9
idf.py add-dependency "espressif/esp-boost^0.4.1"