Constexpr vectors and constexpr strings in C++20

Hi all!

I came across this thread. The posts towards the end suggest that constexpr vectors and constexpr strings are approved in C++20.

So, I tried to use those here and BAM! - a compilation error, as expected. :frowning:

I’m sure I’m misunderstanding something. It would be great if someone could explain how to do it.

Another question: After running a program on CodeChef, a field called Time is displayed. Does it include the time to compile the code?

Thank you. :slight_smile:

Hello @ssjgz! Can you please shed some light once you’re free? :slightly_smiling_face:

1 Like

Hmmm … not really :slight_smile: I searched around briefly through the papers and their dependencies, and couldn’t find a single example of how they are supposed to actually be used.

So I can’t tell if your example is invalid or if (more likely) gcc (or its C++ Standard Library) doesn’t support this yet.

1 Like

Thank you very much for the effort.

I’ve been waiting for constexpr vectors and constexpr strings for a long time. Hope I come across a nice way to use those in my codes soon, now that C++20 is done!

Cheers! :slightly_smiling_face:

1 Like