I'm having trouble with std::to_string() in the following lambda function:
#include <iostream>
#include <string>
inline constexpr int a_global_constant { 12345 };
int main( )
{
    auto calculateMsgLength = [ ] ( ) consteval -> std::size_t
    {
        std::string str1 { "Part 1 " };
        std::string str2 { "Part 2 " };
        std::string msg { str1 + str2 /*+ std::to_string( a_global_constant )*/ };
        // The complete message should look like this: Part 1 Part 2 12345
        return msg.length( );
    };
    constexpr std::size_t msgLength { calculateMsgLength( ) };
    std::cout << "Message length == " << msgLength << '\n';
}
The above code doesn't compile on my GCC v11.2 therefore I had to use GCC (trunk) at the Compiler Explorer to compile it.
However, just by uncommenting the call to std::to_string() it doesn't compile:
<source>: In function 'int main()':
<source>:19:61: error: 'main()::<lambda()>' called in a constant expression
   19 |         constexpr std::size_t msgLength { calculateMsgLength( ) };
      |                                           ~~~~~~~~~~~~~~~~~~^~~
<source>:10:35: note: 'main()::<lambda()>' is not usable as a 'constexpr' function because:
   10 |         auto calculateMsgLength = [ ] ( ) consteval -> std::size_t
      |                                   ^
<source>:10:35: error: call to non-'constexpr' function 'std::string std::__cxx11::to_string(int)'
.
.
.
Is std::to_string going to be made constexpr in STL sometime in the near future? Or should I look for an alternative way for doing this? What is an alternative to std::to_string?

std::to_stringis specified in terms ofsprintf. While it doesn't have to actually be implemented viasprintf, it more than likely shares internals with it at the very least across major implementations. Making thatconstexprwill be a major pain to standard library and/or compiler vendors. Don't expect it soon.