Measurement of azimuthal correlations of D mesons with charged particles in pp collisions at √s = 7 TeV and p–Pb collisions at √sNN = 5.02 TeV