Macro can be converted to constexpr

Viewed 28

I have seen a similar discussion here (When should you use constexpr capability in C++11?).

#define kMaxLength 50
#define kSlipsModeSelect 0
#define kSlipsModeAll 1
#define kStatusBarIconWidth 20

All of the above are flagging code analysis:

Macro can be converted to constexpr

It is proposing:

constexpr auto kMaxLength = 50;
constexpr auto kSlipsModeSelect = 0;
constexpr auto kSlipsModeAll = 1;
constexpr auto kStatusBarIconWidth = 20;

What are the benefits of making this change?

0 Answers
Related