Measurement of CP violation in B 0 → D ∓π± decays