Is $\mathbb{R}\cong\text{Cont}(X,Y)$ for some non-trivial spaces $X,Y$?

I must admit that I hesitated answering this question, but here it is.

The answer is "no". Assume there exist topological spaces $X$ and $Y$ such that $C(X,Y)\simeq \mathbb{R}$ and $Y\not\simeq\mathbb{R}$. Identifying $C(X,Y)$ with $\mathbb{R}$ and $Y$ with the constant functions in $Y^X$ we consider $Y$ as a closed subsapce of $\mathbb{R}$. Considering the surjection $\mathbb{R} \to C(X,Y)\to C(\{x\},Y) \to Y$, we see that $Y$ is connected. Thus $Y\subset\mathbb{R}$ is a closed convex subset. As $Y\not\simeq \mathbb{R}$ there must exist an extreme point $y\in Y$. Note that $C(X,Y)$ is a convex subset of $C(X,\mathbb{R})$ and the constant function $y$ is an extreme point of it. It follows that $C(X,Y)-\{y\}$ is also convex, hence contractible. But $C(X,Y)-\{y\}$ is homeomorphic to $\mathbb{R}$ minus a point. This is a contradiction.


Following the answer of Uri Bader, we can show that $Y$ is a retract of the real line, so can be identified with a closed convex subset of $\mathbb R$. Without loss of generality we can assume that $0,1\in Y$ and hence $[0,1]\subset Y$. It follows that the function $C(X,Y)$ is a convex subset of $Y^X\subset \mathbb R^X$ and $C(X,[0,1])\subset C(X,Y)$. The assumption $Y\not\cong\mathbb R\cong C(X,Y)$ implies that $C(X,Y)$ contains a non-constant function $f$. Consider the constant functions $\mathbf 0:X\to\{0\}\subset Y$ and $\mathbf 1:X\to\{1\}\subset Y$ and observe that the set $T=\{\mathbf 0,\mathbf 1,f\}\subset C(X,Y)\subset Y^X\subset\mathbb R^X$ is affinely independent and its convex hull $conv(T)\subset C(X,Y)$ is homeomorphic to the 2-dimensional symplex, which cannot be contained in the real line $\mathbb R\cong C(X,Y)$. This contradiction completes the proof.

The negative answer can also be deduced from the following theorem. We recall that a topological space $X$ is functionally Hausdorff if for any distinct points $x,y\in X$ there exists a continuous function $f:X\to\mathbb R$ such that $f(x)\ne f(y)$.

Theorem. If for non-empty topological spaces $X,Y$ the function space $C(X,Y)$ is functionally Hausdorff and path-connected, then either $C(X,Y)$ is homeomorphic to $Y^n$ for some $n\in\mathbb N$ or $C(X,Y)$ contains a topological copy of the Hilbert cube.

Proof. The space $Y\cong C(\{x\},Y)$ is functionally Hausdorff and path-connected, being a retract of the functionally Hausdorff path-connected space $C(X,Y)$. If $Y$ is a singleton, then $C(X,Y)\cong Y^1$ is a singleton, too. So, we assume that $Y$ contains more than one point. In this case $Y$ contains a subspace $I$, homeomorphic to the closed interval $[0,1]$.

Consider the canonical map $\delta:X\to Y^{C(X,Y)}$, $\delta:x\mapsto (f(x))_{f\in C(X,Y)}$. If the image $\delta(X)$ is finite of cardinality $n$, then $C(X,Y)$ is homeomorphic to $Y^n$ (since each function $f\in C(X,Y)$ is constant on each set $\delta^{-1}(y)$, $y\in \delta(X)$).

So, we assume that the set $\delta(X)$ is infinite. Taking into account that the space $Y^{C(X,Y)}$ is functionally Hausdorff, we can construct a continuous map $g:Y^{C(x,Y)}\to I$ such that the image $Z=g(\delta(X))$ is infinite. The surjective continuous map $p:=g\circ\delta:X\to Z$ induces a continuous injective map $p^*:C(Z,I)\to C(X,I)$, $p^*:f\mapsto f\circ p$. It is easy to see that the function space $C(Z,I)\subset I^Z$ contains a topological copy $Q$ of the Hilbert cube $I^\omega$. Then $p^*(Q)$ is a topological copy of the Hilbert cube in $C(X,I)\subset C(X,Y)$.