Re: Make copyObject work in C++ - Mailing list pgsql-hackers

From Jelte Fennema-Nio
Subject Re: Make copyObject work in C++
Date
Msg-id CAGECzQSgRGRRHt4BVhMLpxrXMGDGzFLk3d=rnC7ye2kNibc-AQ@mail.gmail.com
Whole thread Raw
In response to Re: Make copyObject work in C++  (Peter Eisentraut <peter@eisentraut.org>)
List pgsql-hackers
On Mon, 8 Dec 2025 at 08:57, Peter Eisentraut <peter@eisentraut.org> wrote:
> In the long run, I would like to change copyObject() to use
> typeof_unqual instead, because that handles qualifiers more correctly.
> (Currently, copyObject() of a const-qualified pointer results in a
> const-qualified pointer, which is nonsensical because the reason you
> made the copy is that you can modify it.)  See attached patch for an
> example.  Does C++ have something that is semantically similar to that?

Yes, there's a std::remove_cv, std::remove_const, and std::remove_volatile[1].

[1]: https://en.cppreference.com/w/cpp/types/remove_cv.html



pgsql-hackers by date:

Previous
From: Jelte Fennema-Nio
Date:
Subject: Re: Type assertions without GCC builtins
Next
From: Anton Haglund
Date:
Subject: [PATCH] Update comment in nodeBitmapHeapscan.c