You definetely know that macros are somewhat evil. With the relatively new keyword constexpr
we can do a few good stuff we couldn't with const
. E.g:
constexpr int GetVal()
{
return 40;
}
int arr[GetVal()];
And yeah...there are also many other usages for constexpr
, like in constructors..etc.
Now the question is, is there any benefit of using it over #define
macros?
edit
I know what can and what cannot be done with constexpr
over macros which is what most of that question and its answers are all about. Here I'm explicitly asking what are the benefits of using constexpr
over #define
when BOTH can be used.