Wyatt Hepler | f9fb90f | 2020-09-30 18:59:33 -0700 | [diff] [blame^] | 1 | .. _module-pw_result: |
Alexei Frolov | 41b32d3 | 2019-11-13 17:22:03 -0800 | [diff] [blame] | 2 | |
| 3 | --------- |
| 4 | pw_result |
| 5 | --------- |
Ewout van Bekkum | 0d04fbc | 2020-07-23 15:58:04 -0700 | [diff] [blame] | 6 | ``pw::Result`` is a convenient wrapper around returning a Status along side some |
| 7 | data when the status is OK. This is meant for returning lightweight result |
| 8 | types or references to larger results. |
| 9 | |
| 10 | .. warning:: |
| 11 | |
| 12 | Be careful not to use larger types by value as this can quickly consume |
| 13 | unnecessary stack. |
Alexei Frolov | 41b32d3 | 2019-11-13 17:22:03 -0800 | [diff] [blame] | 14 | |
| 15 | .. warning:: |
| 16 | |
| 17 | This module is experimental. Its impact on code size and stack usage has not |
| 18 | yet been profiled. Use at your own risk. |
Ewout van Bekkum | 0d04fbc | 2020-07-23 15:58:04 -0700 | [diff] [blame] | 19 | |
| 20 | Compatibility |
| 21 | ============= |
| 22 | Works with C++11, but some features require C++17. |
Alexei Frolov | de3c2a1 | 2020-08-31 10:57:25 -0700 | [diff] [blame] | 23 | |
| 24 | Size report |
| 25 | =========== |
| 26 | The table below showcases the difference in size between functions returning a |
| 27 | Status with an output pointer, and functions returning a Result, in various |
| 28 | situations. |
| 29 | |
| 30 | Note that these are simplified examples which do not necessarily reflect the |
| 31 | usage of Result in real code. Make sure to always run your own size reports to |
| 32 | check if Result is suitable for you. |
| 33 | |
| 34 | .. include:: result_size |