C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Labelled parameters

From: Alejandro Colomar <une+cxx_std-proposals_at_[hidden]>
Date: Tue, 6 Jan 2026 21:56:57 +0100
Hi Jens,

On Tue, Jan 06, 2026 at 09:11:25PM +0100, Jens Maurer via Std-Proposals wrote:
> My point is that there's no point in optimizing the design in
> that respect. Those that "#define x" to something deserve to
> be broken.

I did define x() for some time! :-)

 #define x(p) \
 ({ \
  __auto_type p_ = p; \
                                                        \
  exit_if_null_(p_); \
  p_; \
 })

 inline void
 exit_if_null_(void *p)
 {
  if (p == NULL) {
   fprintf(stderr, "%s\n", strerror(errno));
   exit(1);
  }
 }

 #define xstrdup(s) x(strdup(s))

Recently, I renamed it to exit_if_null(), as x() seems to be widely used
for other purposes.


Have a lovely night!
Alex

>
> Jens
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

-- 
<https://www.alejandro-colomar.es>

Received on 2026-01-06 20:57:07