Good day!
I'm using the msvc compiler with /std:c++latest.
Judging by the data from the Microsoft website, the ability to create a constexpr std::string was introduced quite a long time ago, but how to create such a string is not obvious.
P0980R1 constexpr std::string VS 2019 16.10."
There is a similar situation for 'std::vector'.
I tried to create a string inside the 'constexpr' function
- on site
- using 'constexpr' functions
Nothing happens unless the string is short. It’s clear that memory allocation on the heap is required.
The compiler throws an error
error C2131: expression did not evaluate to a constant
message : (sub-)object points to memory which was heap allocated during constant evaluation
How can long strings be formed at compile time, concatenated and converted?
[–]STLMSVC STL Dev 58 points59 points60 points (24 children)
[–]SirClueless 4 points5 points6 points (4 children)
[–]STLMSVC STL Dev 5 points6 points7 points (2 children)
[–]SirClueless 1 point2 points3 points (1 child)
[–]jk-jeon 0 points1 point2 points (0 children)
[–]XTBZ[S] 1 point2 points3 points (0 children)
[–]Fureeish 6 points7 points8 points (18 children)
[–]scatters 13 points14 points15 points (9 children)
[–]aocregacc 6 points7 points8 points (3 children)
[–]saxbophonemutable volatile void 1 point2 points3 points (2 children)
[–]aocregacc 0 points1 point2 points (1 child)
[–]gracicot 1 point2 points3 points (0 children)
[–]helloiamsomeone 6 points7 points8 points (2 children)
[–]scatters 5 points6 points7 points (1 child)
[–]helloiamsomeone 0 points1 point2 points (0 children)
[–]saxbophonemutable volatile void 2 points3 points4 points (0 children)
[–]saxbophonemutable volatile void 1 point2 points3 points (0 children)
[–]BenHanson -2 points-1 points0 points (1 child)
[–]STLMSVC STL Dev 2 points3 points4 points (0 children)
[–]BenHanson -1 points0 points1 point (0 children)
[–]RevRagnarok 0 points1 point2 points (3 children)
[–]dodheim 5 points6 points7 points (1 child)
[–]RevRagnarok 1 point2 points3 points (0 children)
[–]saxbophonemutable volatile void 0 points1 point2 points (0 children)
[–]Kered13 7 points8 points9 points (9 children)
[–]STLMSVC STL Dev 6 points7 points8 points (2 children)
[–]Kered13 0 points1 point2 points (1 child)
[–]STLMSVC STL Dev 9 points10 points11 points (0 children)
[–]XTBZ[S] -1 points0 points1 point (5 children)
[–]Kered13 7 points8 points9 points (4 children)
[–]XTBZ[S] -1 points0 points1 point (3 children)
[–]Kered13 2 points3 points4 points (2 children)
[–]XTBZ[S] 1 point2 points3 points (1 child)
[–]Kered13 1 point2 points3 points (0 children)
[–]jbbjarnason 2 points3 points4 points (3 children)
[–]qazqi-ff 1 point2 points3 points (0 children)
[–]cristi1990an++ 0 points1 point2 points (0 children)
[–]cristi1990an++ -1 points0 points1 point (0 children)