#Std::format

7 messages · Page 1 of 1 (latest)

topaz bay
#

Quick question about std::format.
Why does this work:

std::cout << std::format("|{: >{}}|\n", "123", 5); // prints(|  123|)

but not this:

std::cout << std::format("|{:{}>{}}|\n", "123", " ", 5);

Is it in the wrong order?

clear hareBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

vernal inlet
#

The format string is checked at compile time, which isn't possible if you parametrize it with a runtime argument: use vformat in that case.

topaz bay
#

I see

#

thank you

clear hareBOT
#

@topaz bay Has your question been resolved? If so, run !solved :)

topaz bay
#

!solved