Skip to main content

Practice ยท 1 of 1

std::conditional_t Type Selection

Implement Storage<T> whose value_type is T for small types (<= 8 bytes) but std::shared_ptr<T> for large ones โ€” via std::conditional_t โ€” plus biggest(a, b) returning the larger by reference using std::conditional_t on a comparison trait is overkill; just use std::conditional_t<std::is_integral_v<T>, int, double> fallback semantics in numberKind<T>().

Difficulty: advanced

Back to lesson: Practice: Traits in Constraints