  A measurement of the $CP$ asymmetries $S_{f}$ and $S_{\bar{f}}$ in $B^0\to
D^{\mp}\pi^{\pm}$ decays is reported. The decays are reconstructed in a dataset
collected with the LHCb experiment in proton-proton collisions at
centre-of-mass energies of 7 and 8 TeV and corresponding to an integrated
luminosity of $3.0 \rm{ fb}^{-1}$. The $CP$ asymmetries are measured to be
$S_{f} = 0.058 \pm 0.020 (\rm{stat}) \pm 0.011(\rm{syst})$ and $S_{\bar{f}} =
0.038\pm 0.020 (\text{stat})\pm 0.007 (\text{syst})$. These results are in
agreement with, and more precise than, previous determinations. They are used
to constrain $|\sin\left(2\beta+\gamma\right)|$ and $\gamma$ to intervals that
are consistent with the current world-average values.
