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