Make typeof and typeof_unqual fallback definitions work on C++11

These macros were unintentionally using C++14 features. This replaces
them with valid C++11 code.

Tested locally by compiling with -std=c++11 (which reproduced the
original issue).

Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/92f9750f-c7f6-42d8-9a4a-85a3cbe808f3%40eisentraut.org
This commit is contained in:
Peter Eisentraut 2026-03-15 07:36:27 +01:00
parent 0123ce131f
commit cd083b54bd

View file

@ -447,7 +447,7 @@ extern "C++"
#ifdef pg_cxx_typeof
#define typeof(x) pg_cxx_typeof(x)
#elif !defined(HAVE_CXX_TYPEOF)
#define typeof(x) std::remove_reference_t<decltype(x)>
#define typeof(x) std::remove_reference<decltype(x)>::type
#endif
#ifndef HAVE_TYPEOF
#define HAVE_TYPEOF 1
@ -459,7 +459,7 @@ extern "C++"
#ifdef pg_cxx_typeof_unqual
#define typeof_unqual(x) pg_cxx_typeof_unqual(x)
#elif !defined(HAVE_CXX_TYPEOF_UNQUAL)
#define typeof_unqual(x) std::remove_cv_t<std::remove_reference_t<decltype(x)>>
#define typeof_unqual(x) std::remove_cv<std::remove_reference<decltype(x)>::type>::type
#endif
#ifndef HAVE_TYPEOF_UNQUAL
#define HAVE_TYPEOF_UNQUAL 1