Re: Make copyObject work in C++

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Subject: Re: Make copyObject work in C++
Date: 2026-02-19 08:31:45
Message-ID: 8f8776be-6d8f-4e1c-8d21-e55052edd91b@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 13.02.26 11:28, Jelte Fennema-Nio wrote:
> Patch 3 makes copyObject work when using GCC or Clang with -std=c++11 by
> introducing pg_exprtype.
>
> Patch 4 starts using pg_exprtype in more places.

I found this paper

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2927.htm

which led to the addition of typeof into the C standard.

It contains a section 'Why not "decltype"?' that explains how decltype
is different, but it also explains that if typeof were added to C++,
then it would be

std::remove_reference_t<decltype(T)>

What I suggest we should do here is:

1. Add a configure test that checks if the C++ compiler supports typeof.

2. If not, #define typeof to the above expression.

Then code can continue to use typeof unchanged.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2026-02-19 08:40:08 Remove obsolete SAMESIGN macro
Previous Message Fabrice Chapuis 2026-02-19 08:27:05 Re: incremental backup issue