14

I want to use the new C++20 <format> header. But when I try to #include it, it apparently doesn't exist in my current stdlib.

I tried using clang++ and g++, but neither of them work.

Yes, I specified the C++ standard to be "c++2a" in the tasks.json file in VSCode.

What am I doing wrong?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Hell stormer
  • 413
  • 1
  • 4
  • 14

1 Answers1

18

You can view an overview of compiler support here: https://en.cppreference.com/w/cpp/compiler_support

According to the table, up to today (May 13 '20 at 8:07) no compiler supports P0645R10: Text formatting.

The overview specifically for MSVS can be found here: https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance?view=vs-2019 (though I didn't find <format> on their list).

463035818_is_not_an_ai
  • 109,796
  • 11
  • 89
  • 185
  • If no compiler exists which supports format, then how are you supposed to use it? Or why does it even exist? – Hell stormer May 13 '20 at 08:14
  • 1
    @Hellstormer support for C++20 is rapidly growing, you need to check your compilers news and stay tuned. Things will change in the coming months – 463035818_is_not_an_ai May 13 '20 at 08:16
  • It exists because it will be supported but not yet. – calynr May 13 '20 at 08:16
  • 3
    @Hellstormer " Or why does it even exist?" I dont understand.. what exists is the standard that specifies what the header should contain, thats not the same as having it ready to be used – 463035818_is_not_an_ai May 13 '20 at 08:17
  • Ok thank all of you. I guess I didn't know how c++ is being developed. – Hell stormer May 14 '20 at 08:59
  • 1
    @Hellstormer I also dont know all the details. Sometimes new additions to the standard library are coming via boost. Afaik an example implementation has to exist for a proposal to be accepted, but propososals go trhough a long process including potential modifications before actually included in the standard. I didnt check, but I wouldnt be surprised if `` is very similar to Boost::format, and probably you can find most things there already – 463035818_is_not_an_ai May 14 '20 at 09:06