I want to create a nice table in stdout. The table has a lot of headers that are mainly compiletime strings. For example:
std::cout << fmt::format("|{0:-^80}|\n", "File Information");
The above prints:
|-----------------------------File Information------------------------------|
I have lots of different type of fills and align widths. I decided to make some helper functions:
constexpr static
std::string_view
headerCenter(const std::string& text, const int width, const char fill) {
// build fmt string
const std::string_view format = "{:" + 'fill' + '^' + toascii(width) + '}';
return fmt::format(format, text);
}
I got this error while compiling:
Constexpr function never produces a constant expression
What is it that I am doing wrong, and how to do it correctly?