Files
external_libcamera/include/libcamera
Laurent Pinchart 48c106429a libcamera: base: utils: Provide defopt to simplify std::optional::value_or() usage
The std::optional<T>::value_or(U &&default_value) function returns the
contained value if available, or default_value if the std::optional has
no value. If the desired default value is a default-constructed T, the
obvious option is to call std::optional<T>::value_or(T{}). This approach
has two drawbacks:

- The \a default_value T{} is constructed even if the std::optional
  instance has a value, which impacts efficiency.
- The T{} default constructor needs to be spelled out explicitly in the
  value_or() call, leading to long lines if the type is complex.

Introduce a defopt variable that solves these issues by providing a
value that can be passed to std::optional<T>::value_or() and get
implicitly converted to a default-constructed T.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-07-28 14:54:41 +03:00
..
2021-12-11 17:53:40 +01:00
2021-11-24 12:17:35 +00:00
2021-12-13 11:29:01 +02:00
2022-06-05 14:48:08 +02:00
2021-11-24 12:17:35 +00:00