Re: Safer hash table initialization macro - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: Safer hash table initialization macro
Date
Msg-id CA+hUKGLYn6jxMSptjzMqBZ7ZYKQ2cewiKjg31zUR+ZR3E+mu+Q@mail.gmail.com
Whole thread Raw
In response to Re: Safer hash table initialization macro  (Bertrand Drouvot <bertranddrouvot.pg@gmail.com>)
Responses Re: Safer hash table initialization macro
List pgsql-hackers
On Tue, Dec 9, 2025 at 8:27 PM Bertrand Drouvot
<bertranddrouvot.pg@gmail.com> wrote:
> On Mon, Dec 08, 2025 at 11:53:02AM +0100, Jelte Fennema-Nio wrote:
> > On Sat Dec 6, 2025 at 1:56 AM CET, Thomas Munro wrote:
> +#if defined(__cplusplus)
> +#define pg_expr_has_type_p(expr, type) (std::is_same<decltype(expr), type>::value)
> +#else
> +#define pg_expr_has_type_p(expr, type) \
> +       _Generic((expr), type: 1, default: 0)
> +#endif
>
> What about relying on the existing __builtin_types_compatible_p() instead of
> _Generic() here?

If we used standard C/C++ it'd work on MSVC too.



pgsql-hackers by date:

Previous
From: Jelte Fennema-Nio
Date:
Subject: Re: Proposal to allow setting cursor options on Portals
Next
From: Jakub Wartak
Date:
Subject: Re: 64-bit wait_event and introduction of 32-bit wait_event_arg