| From: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
|---|---|
| To: | Jelte Fennema-Nio <postgres(at)jeltef(dot)nl> |
| Cc: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Safer hash table initialization macro |
| Date: | 2025-12-09 07:27:03 |
| Message-ID: | aTfPRxNYuYWVLI+3@ip-10-97-1-34.eu-west-3.compute.internal |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
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:
> > On Sat, Dec 6, 2025 at 3:32 AM Jelte Fennema-Nio <postgres(at)jeltef(dot)nl> wrote:
> > > On Fri, 5 Dec 2025 at 02:30, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> > > create a hashmap it's still possible to call the.
> >
> > ... C functions without the helper macros.
>
> Oops, forgot to finish that sentence.
Thanks for this patch series!
> > Yeah. I don't think we want that sort of thing all over the place.
> > We could eventually come up with a small set of tools in a central
> > place though, so people can work with this stuff without also known
> > C++ meta-programming voodoo. For example something like (untested, I
> > didn't think about char[size], just spitballing here...):
> >
> > (pg_expr_has_type_p(ptr, char *) || pg_expr_has_type_p(ptr, NameData *))
> >
> > ... given the definition I posted recently[1].
+#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?
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Kirill Reshke | 2025-12-09 07:30:51 | Re: citext_1.out, citext.out confusing comment |
| Previous Message | Peter Eisentraut | 2025-12-09 06:45:41 | Re: Remove unnecessary casts in printf format arguments |