Skip to main content

Practice · 1 of 1

std::conditional_t Type Selection

CHALLENGE
Difficulty: advanced+25 XP

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>().

Back to lesson: Practice: Traits in Constraints