In principle there is no reason why a constexpr function could not
contain all this. One can call also library functions as long as those
functions are constexpr as well.
>
> I thought the compiler would just call a function in a dll/so or similar.
If I understand correctly, your proposal would be that when (shared)
library A contains a non-constexpr function foo() (e.g. for adding
128-bit floats) and library B depends on library A, then library B could
use constexpr functions containing calls to foo(), and the compiler
would actually call this function at compile time and substitute the
result, instead of just linking to the library and calling foo() at run
time.
Interesting idea, but I have not not heard of any such things. For
starters, compiling library B in general does not require the presence
of library A, only headers are needed (and in case of Windows, the stub
.lib file). Dealing with libraries is the concern of the linker which
would be too late. It is true that nowadays linkers are also capable of
generating compiled code (whole program optimization etc), but this is
not mandated. For calling foo(), the linker must first be able to load
the library A into a process (together with all its dependencies which
is not a trivial task), which may become very tricky in case of
cross-compilation etc.
The current constexpr support is much more modest. It does not involve
the linker. It is only the compiler which sees the full source code
(recursively, so no need to mess with any library loading), recompiles
it (probably for the current platform as then it would be easy to call
it) and calls it, probably directly from the memory buffer where it
wrote the binary code, no library or dependencies loading needed.
Note that cross-compilation is very widespread. For example, MSVC
compiler cl.exe is for example a 32-bit program, so compiling 64-bit
applications with MSVC means cross-compilation.
Cheers
Paavo