summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBarnabás Pőcze <pobrn@protonmail.com>2024-06-12 22:46:16 +0000
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-06-13 02:13:36 +0300
commit20b8538a197c45597eecf5c7a51058263e816eb9 (patch)
tree331b65206ccf1291d6453f11248dd3f857353aae /include
parentd9c6835e23ec9ff719acc76abb8cde89450680c2 (diff)
libcamera: yaml_parser: Make default value templated in `get()`
This way the construction of the default value of type `T` can be delayed until it is really needed, which is useful, for example when `T == std::string` and the default value comes from a string literal, as the default value string would always be constructed otherwise, even if not needed. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/internal/yaml_parser.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h
index b6979d73..3ac27e06 100644
--- a/include/libcamera/internal/yaml_parser.h
+++ b/include/libcamera/internal/yaml_parser.h
@@ -179,10 +179,10 @@ public:
#endif
std::optional<T> get() const;
- template<typename T>
- T get(const T &defaultValue) const
+ template<typename T, typename U>
+ T get(U &&defaultValue) const
{
- return get<T>().value_or(defaultValue);
+ return get<T>().value_or(std::forward<U>(defaultValue));
}
#ifndef __DOXYGEN__