is constexpr(): Difference between revisions

From vegard.wiki
Jump to navigation Jump to search
Content added Content deleted
(new page)
 
(add category)
 
Line 17: Line 17:
[[Category:Programming]]
[[Category:Programming]]
[[Category:C]]
[[Category:C]]
[[Category:C preprocessor snippets]]

Latest revision as of 11:54, 1 March 2020

/*
 * This returns a constant expression while determining if an argument is
 * a constant expression, most importantly without evaluating the argument.
 * Glory to Martin Uecker <Martin.Uecker@med.uni-goettingen.de>
 */
#define __is_constexpr(x) \
        (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))

See also