c++ - Are there any benefits of using constexpr over #define? -
this question has answer here:
- why preprocessor macros evil , alternatives? 7 answers
- is constexpr needed? 6 answers
you definetely know macros evil. relatively new keyword constexpr can few stuff couldn't const. e.g:
constexpr int getval() { return 40; } int arr[getval()]; and yeah...there many other usages constexpr, in constructors..etc.
now question is, there benefit of using on #define macros?
edit
i know can , cannot done constexpr on macros of question , answers about. here i'm explicitly asking benefits of using constexpr on #define when both can used.
Comments
Post a Comment