libcamera: libcamera::utils::overloaded< Ts > Struct Template Reference

libcamera v0.7.1 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
libcamera::utils::overloaded< Ts > Struct Template Reference

Helper type for type-matching std::visit() implementations. More...

Inheritance diagram for libcamera::utils::overloaded< Ts >:
[legend]
Collaboration diagram for libcamera::utils::overloaded< Ts >:
[legend]

## Detailed Description

template<class... Ts>
struct libcamera::utils::overloaded< Ts >

Helper type for type-matching std::visit() implementations.

Template Parameters

  Ts... | Template arguments pack of visitors

Expand the template argument pack Ts... to provide overloaded operator() to support type-matching implementations of the visitor design pattern using std::visit().

An example is provided by the C++ standard library documentation in the form of:

template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
using var_t = std::variant<int, long, double, std::string>;
std::vector<var_t> vec = {10, 15l, 1.5, "hello"};
for (auto& v: vec) {
std::visit(overloaded {
[](auto arg) { std::cout << arg << ' '; },
[](double arg) { std::cout << std::fixed << arg << ' '; },
[](const std::string& arg) { std::cout << std::quoted(arg) << ' '; },
}, v);
libcamera::utils::overloaded
Helper type for type-matching std::visit() implementations.
Definition utils.h:41

Use this helper to implement type-matching visitors using std::visit().

The documentation for this struct was generated from the following file:

- include/libcamera/base/utils.h