From: Alejandro Colomar Date: Wed, 15 May 2024 11:19:43 +0000 (+0200) Subject: lib/cast.h: const_cast(): Reimplement with _Generic(3) X-Git-Tag: 4.15.2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69f74dbf8a2341aa73dc3f2213102eae1a3e49e0;p=thirdparty%2Fshadow.git lib/cast.h: const_cast(): Reimplement with _Generic(3) This makes it much simpler and portable. Signed-off-by: Alejandro Colomar --- diff --git a/lib/cast.h b/lib/cast.h index 9229528d0..5cbbcf6dd 100644 --- a/lib/cast.h +++ b/lib/cast.h @@ -8,14 +8,8 @@ #include -#include "must_be.h" - -#define const_cast(T, p) \ -({ \ - static_assert(is_same_type(typeof(&*(p)), const T), ""); \ - (T) (p); \ -}) +#define const_cast(T, p) _Generic(p, const T: (T) (p)) #endif // include guard