cpp-common: add `bt2s::optional`, alias of `nonstd::optional` In order to avoid having all sorts of external namespaces, make `bt2s::optional` an alias of `nonstd::optional`, and make sure everything in the project uses `bt2s::optional`. Also add aliases for other STL types and functions of `<optional>`. This will make it possible to easily change the implementation without changing the code using it indirectly (only `cpp-common/bt2s/optional.hpp` will change). Move `cpp-common/optional.hpp` to `cpp-common/vendor/optional-lite/optional.hpp` to make it clear it's an external project. Making everything under `cpp-common/vendor` an exception in `tools/format-cpp.sh`. Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com> Change-Id: I2a1ea52c484c85fbf8d68631d40369efd969818a Reviewed-on: https://review.lttng.org/c/babeltrace/+/11391 Tested-by: jenkins <jenkins@lttng.org> Reviewed-by: Simon Marchi <simon.marchi@efficios.com> CI-Build: Simon Marchi <simon.marchi@efficios.com>
Add `std::optional` replacement (`nonstd::optional`) This patch adds an `std::optional` replacement, `nonstd::optional`, which comes from the Boost-licensed <https://github.com/martinmoene/optional-lite> project. Babeltrace 2 cannot use `std::optional` as it's part of C++17, whereas the project only requires C++11. `nonstd::optional` is meant to work like C++17's `std::optional`. In any Babeltrace 2 C++ file, include it like this: #include "cpp-common/optional.hpp" Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com> Change-Id: Icda5af4bd5affd1237786bdb9cb2e64861643440 Reviewed-on: https://review.lttng.org/c/babeltrace/+/4517