Defined in Member types Construction Destructor emplace Assignment Apply Elimination the active alternative routes into the callable exhaustively every alternative must have a viable arm Transform The self flattening map over the alternatives the branch results form a new normalized copack apply_r apply_type apply_type_r get_ptr has_value as_copack The canonical coproduct payload exactly one alternative is present A discriminated union indexed by type not by position The alternatives are required to be flat unique and sorted in the library s total order over types and an instantiation that diverges out of order duplicated or nested is ill formed spell copack_for which normalizes any list into the canonical form rather than name that order by hand Every evaluation of a copack is an exhaustive dispatch a callback set missing any alternative is rejected at compile time A structural type when its alternatives are Builds the canonical copack for any list of types The user facing construction alias flattens nested copacks deduplicates and sorts into the library s canonical order resolving to the one valid copack in an API signature the two are the same type Spell copack_for rather than copack so that no spelling in your project is tied to one compiler s alternative order using data_t detail variadic_union<Ts > 1 The union holding the alternatives data_t data 1 The union holding the active alternative std size_t index 1 The index of the active alternative static std size_t size sizeof Ts 1 The number of alternatives static std size_t size 0 1 The number of alternatives template <typename T> static constexpr bool has_type false 1 Whether T is one of the alternatives template <typename T> static constexpr bool has_type data_t template has_type<T> 1 Checks if T is one of the alternatives template <std size_t I> using select_nth detail select_nth_t<I Ts > 1 The I th alternative in the canonical order constexpr copack noexcept delete 1 constexpr copack copack const & noexcept default 2 constexpr copack copack && noexcept default 3 Default constructor not available on this carrier Copy constructor Move constructor template <typename T> constexpr copack T &&v 1 constexpr explicit copack T &&v 2 constexpr explicit copack std in_place_type_t<T> auto && args 3 template <typename Tx> constexpr copack copack<Tx > const &arg 4 constexpr copack copack<Tx > &&arg 5 constexpr copack std in_place_type_t<copack<Tx >> some_copack auto &&arg 6 constexpr copack copack const &other default 7 constexpr copack copack const &other 8 constexpr copack copack &&other default 9 constexpr copack copack &&other 10 Constructs the alternative matching the value s decayed type Takes a value of exactly one alternative a merely convertible non alternative is rejected so interconvertible alternatives never make a resolution puzzle Explicit exactly where the conversion to that alternative is v T && Value of one alternative Constructs the alternative T in place from the arguments args auto && Arguments to construct the alternative from args auto && Arguments to construct the alternative from Widening constructor from a copack over a subset of the alternatives The active alternative relocates into this copack implicit as the subset to superset direction can never lose information arg copack < Tx > const & The narrower copack Widening constructor from a copack over a subset of the alternatives Widening constructor from a copack whose type is spelled as a tag arg some_copack auto && The narrower copack Copy constructor trivial where every alternative s is other copack const & The copack to copy from Move constructor trivial where every alternative s is other copack && The copack to move from constexpr copack default 1 constexpr copack 2 Destructor constexpr copack noexcept default 1 Destructor template <typename T> constexpr auto emplace auto && args > T & 1 Destroys the alternative held and constructs a T from the arguments with the strong exception guarantee return Reference to the new alternative args auto && Arguments to construct the new alternative from return Reference to the new alternative args auto && Arguments to construct the new alternative from constexpr auto operator copack const & noexcept default > copack & 1 constexpr auto operator copack && noexcept default > copack & 2 Copy assignment Move assignment constexpr auto operator copack const &other default > copack & 1 constexpr auto operator copack const &other > copack & 2 constexpr auto operator copack &&other default > copack & 3 constexpr auto operator copack &&other > copack & 4 template <typename Tx> constexpr auto operator copack<Tx > const &arg > copack & 5 constexpr auto operator copack<Tx > &&arg > copack & 6 template <typename U typename T> constexpr auto operator U &&v > copack & 7 Copy assignment with the strong exception guarantee return Reference to *this other copack const & The copack to copy from Move assignment with the strong exception guarantee return Reference to *this other copack && The copack to move from Widening copy assignment from a copack over a subset of the alternatives return Reference to *this arg copack < Tx > const & The narrower copack Widening move assignment from a copack over a subset of the alternatives return Reference to *this arg copack < Tx > && The narrower copack Assignment from a value of one alternative with the strong exception guarantee return Reference to *this v U && Value of one alternative template <typename Fn typename Args> constexpr auto apply Fn &&fn Args && args & 1 constexpr auto apply Fn &&fn Args && args const & 2 constexpr auto apply Fn &&fn Args && args && 3 constexpr auto apply Fn &&fn Args && args const && 4 Eliminates the copack the active alternative routes into the callable The dispatch is exhaustive every alternative must have a viable arm selected by ordinary overload resolution and the result type is deduced so all alternatives must yield the same one apply_r serves where they differ A tuple like alternative is unpacked one level into its elements and trailing arguments follow the content return The callable s result fn Fn && Callable applied on the active alternative fn overload fuses arms into one args Args && Additional arguments appended after the alternative s content template <typename Fn typename Args> constexpr auto transform Fn &&fn Args && args & 1 constexpr auto transform Fn &&fn Args && args const & 2 constexpr auto transform Fn &&fn Args && args && 3 constexpr auto transform Fn &&fn Args && args const && 4 Maps the alternatives the branch results forming a new normalized copack The self flattening map the callable is dispatched exhaustively and the branch results heterogeneous types allowed a copack result dissolving into the set flatten deduplicate and sort into the copack_for of them all return A copack of the normalized branch result set holding the active branch s result fn Fn && Callable applied on the active alternative fn overload fuses arms into one args Args && Additional arguments appended after the alternative s content template <typename Ret typename Fn typename Args> constexpr auto apply_r Fn &&fn Args && args & > Ret 1 constexpr auto apply_r Fn &&fn Args && args const & > Ret 2 constexpr auto apply_r Fn &&fn Args && args && > Ret 3 constexpr auto apply_r Fn &&fn Args && args const && > Ret 4 Eliminates the copack converting each branch s result to Ret The escape from result type convergence every alternative converts implicitly into its parent copack so apply_r targeting a copack_for of the branch results accepts branches that disagree return The callable s result converted to Ret fn Fn && Callable applied on the active alternative fn overload fuses arms into one args Args && Additional arguments appended after the alternative s content return The callable s result converted to Ret fn Fn && Callable applied on the active alternative fn overload fuses arms into one args Args && Additional arguments appended after the alternative s content template <typename Fn typename Args> constexpr auto apply_type Fn &&fn Args && args & 1 constexpr auto apply_type Fn &&fn Args && args const & 2 constexpr auto apply_type Fn &&fn Args && args && 3 constexpr auto apply_type Fn &&fn Args && args const && 4 Eliminates the copack keyed by the alternative s type The active arm receives std in_place_type<T> for the alternative held followed by its content a tuple like alternative s elements form is the row s one signature so the handler knows which injection placed the value even where C s implicit conversions would conflate the payloads return The callable s result fn Fn && Callable applied on the tag and the alternative s content args Args && Additional arguments appended after the content template <typename Ret typename Fn typename Args> constexpr auto apply_type_r Fn &&fn Args && args & > Ret 1 constexpr auto apply_type_r Fn &&fn Args && args const & > Ret 2 constexpr auto apply_type_r Fn &&fn Args && args && > Ret 3 constexpr auto apply_type_r Fn &&fn Args && args const && > Ret 4 Eliminates the copack keyed by the alternative s type converting the result to Ret return The callable s result converted to Ret fn Fn && Callable applied on the tag and the alternative s content args Args && Additional arguments appended after the content return The callable s result converted to Ret fn Fn && Callable applied on the tag and the alternative s content args Args && Additional arguments appended after the content template <typename T> constexpr auto get_ptr std in_place_type_t<T> std in_place_type<T> > T * 1 constexpr auto get_ptr std in_place_type_t<T> std in_place_type<T> const > T const * 2 Pointer to the alternative T or nullptr where it is not the one held The escape hatch for direct access unlike apply no dispatch and no exhaustiveness the caller names one alternative and tests the result template <typename T> constexpr auto has_value std in_place_type_t<T> std in_place_type<T> const > bool 1 Checks if T is the active alternative constexpr auto as_copack auto &&src > decltype auto 1 template <typename T> constexpr auto as_copack std in_place_type_t<T> auto && args > decltype auto 2 Lifts a value into a singular copack decaying Unlike as_pack always by value a copack alternative can never be a reference return A copack over the decayed type of src holding it src auto && Value to lift Lifts arguments into a singular copack of T constructed in place return copack<T> holding the alternative args auto && Arguments to construct the alternative from return copack<T> holding the alternative args auto && Arguments to construct the alternative from