Search code examples
c++clangc++20clionfmt

std::format errors "no matching function" and "call to consteval function"


Platform: Win 10 64 bit IDE: CLION 2022.2.4 Toolchain: VS 2022 Community Toolset v17.0 (CMAKE 3.23.2) Build Tool ninja.exe C++ compiler: cl.exe

#include <iostream>
#include <string>
#include <format>
    
int main() {
    std::wstring test1 = L"Hällo, ";
    std::wstring test2;
    
    std::cout << std::format("Hello {}\n", "world!");
    std::cout << std::format("Hello {}\n", "world!");
}

Errors shown in editor: Error in first format Error in first string Error in second string

I suspect this is a CLang error, but I'm not quite sure. I can compile the code just fine and I get an output to the console. But why do I get an error here?

I tried to find anything on Google on it, but I didn't find anything on this specific error. I know from a friend of mine that this is not an isolated issue, or at least he has the same issue.

From what I read the "consteval" was somewhat newly introduced and might still be incompletely implemented in some library functions?


Solution

  • The compiler that your editor uses for highlighting and intellisense doesn't support those features yet.

    std::format is a c++20 feature. According to this page it is not yet supported in Clang. This has been discussed here.