pick

Wrap one of several values in a SuperStruct.

This can be used to return a value from one of several different types. Similar to std.range.chooseAmong, but for a broader range of types.

pick
(
T...
)
(
size_t index
,)

Return Value

Type: auto

A SuperStruct!T constructed from the value at index.

Examples

pick is useful for something that is a floor wax _and_ a dessert topping:

struct FloorWax       { string itIs() { return "a floor wax!";       } }
struct DessertTopping { string itIs() { return "a dessert topping!"; } }

auto shimmer(bool hungry) {
  return pick(hungry, FloorWax(), DessertTopping());
}

assert(shimmer(false).itIs == "a floor wax!");
assert(shimmer(true ).itIs == "a dessert topping!");

Meta