mirror of
https://github.com/shadow-maint/shadow.git
synced 2026-01-26 14:03:17 +00:00
lib/cast.h: const_cast(): Reimplement with _Generic(3)
This makes it much simpler and portable. Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
parent
4e2453fa9f
commit
69f74dbf8a
@ -8,14 +8,8 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user