Open Sebanisu opened 3 years ago
Might be a bit too early to do this.
555 hits in 46 files
regular expression pattern: integer
#define\s+([\d\w_]+)\s+(-?\s*\d+)\s*?(?=$|//|/\*)
matches
#define EVRANK -14 #define EVSPELL 16 #define EVSTACK 17 //blah #define EVSTOP 18 /* blah
replace pattern
static int constexpr $1 = $2;
end result
static int constexpr EVRANK = -14; static int constexpr EVSPELL = 16; static int constexpr EVSTACK = 17; //blah static int constexpr EVSTOP = 18; /* blah */
A basic enum creates something similar to above.
enum { EVRANK = -14, EVSPELL = 16, EVSTACK = 17, //blah EVSTOP = 18, /* blah */ }
Enum's can have names though in c all the members are global anyway. In c++ 11 we get scopes with enum class and set the base integral type. So in cases where we're defining a lot of constants maybe enums are better.
5 hits in 2 files
regular expression pattern: double
#define\s+([\d\w_]+)\s+(-?\s*\d+\.\d+)\s*?(?=$|//|/\*)
#define EMAX 709.78271289338409 #define EMIN -744.44007192138126 #define EMAX2 710.47586007394398 #define TMAX 19.066172834610153
static double constexpr $1 = $2;
static double constexpr EMAX = 709.78271289338409; static double constexpr EMIN = -744.44007192138126; static double constexpr EMAX2 = 710.47586007394398; static double constexpr TMAX = 19.066172834610153;
Might be a bit too early to do this.
Some of the values could be replaced with const values from the standard library. std::numeric_limits
555 hits in 46 files
regular expression pattern: integer
matches
replace pattern
end result
A basic enum creates something similar to above.
Enum's can have names though in c all the members are global anyway. In c++ 11 we get scopes with enum class and set the base integral type. So in cases where we're defining a lot of constants maybe enums are better.
5 hits in 2 files
regular expression pattern: double
matches
replace pattern