multiSelect Helper¶
Basic Overload¶
-
template<size_t MaxDeps = 8, typename IndexSource, typename Source1, typename ...Sources>
auto RxESP32::Helpers::Combinatorial::multiSelect(IndexSource &index, Source1 &source1, Sources&... sources)¶ Select from multiple sources based on an index source.
Creates a Computed that returns the value from the source at the given index.
- Since
v0.1.0
enum class Options { First = 0, Second = 1, Third = 2 }; Signal<Options> index(Options::First); Signal<const char*> option1("First"); Signal<const char*> option2("Second"); Signal<const char*> option3("Third"); auto selected = multiSelect(index, option1, option2, option3); Serial.println(selected.get()); // "First" index.set(Options::Third); Serial.println(selected.get()); // "Third"Note
Negative indices clamped to 0.
Warning
Requires at least 2 sources.
All sources must have the same type.
Index must be integral or enum type.
With Options¶
-
template<size_t MaxDeps = 8, typename IndexSource, typename Source1, typename ...Sources>
auto RxESP32::Helpers::Combinatorial::multiSelect(IndexSource &index, const typename Computed<decltype(std::declval<Source1>().get()), MaxDeps, 2>::Options &options, Source1 &source1, Sources&... sources)¶ Select from multiple sources based on an index signal with options.
Creates a Computed that returns the value from the source at the given index, with custom options.
- Since
v0.1.0
enum class Options { First = 0, Second = 1, Third = 2 }; Signal<Options> index(Options::First); Signal<const char*> option1("First"); Signal<const char*> option2("Second"); Signal<const char*> option3("Third"); auto selected = multiSelect(index, {.lazy = true}, option1, option2, option3); Serial.println(selected.get()); // "First" index.set(Options::Third); Serial.println(selected.get()); // "Third"Note
Negative indices clamped to 0.
Warning
Requires at least 2 sources.
All sources must have the same type.
Index must be integral or enum type.
See Also¶
Combinatorial Helpers - Overview