Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22075

Error: format: No such file or directory when I use c++ 20

$
0
0

I want to use <format> lib in my program to format the output

#include <format>// matrix displaytemplate<typename T>void algebra::display(const algebra::MATRIX<T> &matrix) {    for (const auto& row : matrix) {        std::cout << "|";        for (const auto& elem : row) {            std::cout << std::format("{:^7}", elem) << "|";        }        std::cout << "\n";    }}

However, the compiler throws an error:

fatal error: format: No such file or directory11 | #include <format>      |          ^~~~~~~~compilation terminated.

I have set the c++ version in the CMakeLists.txt:

# Specify the minimum required version of CMake for this project. cmake_minimum_required(VERSION 3.14)project(AUT_AP_2024_SPRING_HW1)set(CMAKE_CXX_STANDARD 23)set(CMAKE_CXX_STANDARD_REQUIRED ON)

And I have checked the version of gcc, it is satisfied the requirement for <format>.


Viewing all articles
Browse latest Browse all 22075

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>