It is well-known that the conditional expectation of a square-integrable random variable $Y$ given another (real) random variable $X$ can be obtained by minimizing the mean square loss between $Y$ and $f(X)$ for all Borel-measurable functions $f : \mathbb{R} \rightarrow \mathbb{R}$, that is:

$$\tag{1}\mathbb{E}[Y \,|\,X] \, = \, \operatorname{argmin}_{f\in\mathcal{B}}\mathbb{E}|Y - f(X)|^2$$

for $\mathcal{B}:=\{g : \mathbb{R} \rightarrow \mathbb{R} \mid g \ \text{ Borel measurable}\}$.

**Question:** Are you aware of conditions on $(X,Y)$ for which in fact

$$\tag{2}\mathbb{E}[Y \,|\, X] \, = \, \operatorname{argmin}_{f\in\mathcal{C}}\mathbb{E}|Y - f(X)|^2 \quad \text{ with } \quad \mathcal{C}:= \{g : \mathbb{R}\rightarrow\mathbb{R} \mid g \ \text{ continuous} \} \ ?$$