How is it that we can express
$$ \mathrm{p.v.}\int_{-\infty} ^{\infty} \frac{\cos 3x}{x^2+4}=\Re \ \mathrm{p.v.}\int_{-\infty} ^{\infty} \frac{e^{3xi}}{x^2+4} $$
while we cannot for
$$ \mathrm{p.v.}\int_{-\infty} ^{\infty} \frac{\cos 3x}{x+i} $$
How do we determine whether the integrand is real valued or not?