Stone–Weierstrass for maps $S^m\to S^n$? In the middle of page 35 of Algebraic Topology by Tammo tom Dieck, the author remarks:

If $f:S^m\to S^n$ is a continuous map, then there exists (by the theorem of
  Stone–Weierstrass, say) a $C^\infty$-map $g:S^m\to S^n$ such that $\|f(x)-g(x)\|<2$, $\forall\, x\in S^m$.

Here, of course, $S^n:=\{\,x\in\mathbb{R}^{n+1}:\|x\|=1\,\}$.
The most general version of Stone–Weierstrass theorem that I know is about the density of a subalgebra of $C(X,\mathbb{R})$ for $X$ a compact Hausdorff space. How does it apply here? Which version of the theorem is the author talking about?

By the usual version of Stone-Weierstrass for maps $S^m \to \mathbb R$, you can approximate $f$ by a smooth $h: S^m \to \mathbb R^{n+1}$ (i.e. approximate each coordinate of $f$).  But the map $p: \mathbb R^{n+1}\setminus\{0\} \to S^n$ given by $p(x) = x/\|x\|$ is smooth, so take $g = p \circ h$ if $\|f - h\| < 1$.
