C++ Logo

std-proposals

Advanced search

Re: static_printf and static_assertf: Standardizing Compilation-Time Output

From: Jake Arkinstall <jake.arkinstall_at_[hidden]>
Date: Tue, 19 Jan 2021 21:37:04 +0000
Well darn. That one was well out of my radar.

I've checked out this revision and the later revision (
http://open-std.org/JTC1/SC22/WG21/docs/papers/2019/p0596r1.pdf), and on a
brief scan it does seem to be taking a rather different angle - but I'll
read it more closely and come back.

On Tue, Jan 19, 2021 at 8:13 PM Ville Voutilainen <
ville.voutilainen_at_[hidden]> wrote:

> On Tue, 19 Jan 2021 at 22:06, Jake Arkinstall via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > Hi everyone.
> >
> > I've been thinking about this for a while now, and from some
> conversations I've had about it, I believe there could be some interest -
> but that, of course, won't happen without a proposal. So here goes. What I
> hope to be my first proposal.
> >
> > The idea is straightforward. Through static_assert, we can already opt
> to provide fixed (string literal) messages to the build log upon assertion
> failure. We cannot, however, opt to provide contextual information, such as
> the values of constant expressions that lead to the failure, without
> compiler-specific tricks. This can make debugging failed static assertions
> more complicated than I believe it could otherwise be.
> >
> > My proposed solution is to introduce a static_printf, a compile-time
> version of printf. Output is directed to the compiler's stdout, just as the
> message for a static_assert is upon failure, but utilising printf
> formatting. It has no effect on the output binary (except in the case of a
> formatting error).
>
> Such as
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0596r0.html ?
>

Received on 2021-01-19 15:37:18