I have implemented a constexpr
compile-time hash-function, which works fine (i.e. is evaluated at compile-time) if called as
constexpr auto hash = CompileTimeHash( "aha" );
but I need to use it in actual code as an argument to a function as in
foo( CompileTimeHash( "aha" ) ); // foo is NOT constexpr
For a specific reason, I cannot use the long version
constexpr auto hash = CompileTimeHash( "aha" );
foo( hash );
The compiler (VC++) will not compile-time hash in the short (first) case. Is there any way to achieve this?
EDIT: An example covering the 3 cases is now found here: https://godbolt.org/z/JGAyuE Only gcc gets it done in all 3 cases