Use constrained generic implementations to minimise casts.