mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-11 08:49:50 +00:00
Codechange: Use std::underlying_type for DECLARE_POSTFIX_INCREMENT.
This commit is contained in:
parent
ac1e1a272f
commit
66cd32a252
@ -13,17 +13,17 @@
|
|||||||
#define ENUM_TYPE_HPP
|
#define ENUM_TYPE_HPP
|
||||||
|
|
||||||
/** Some enums need to have allowed incrementing (i.e. StationClassID) */
|
/** Some enums need to have allowed incrementing (i.e. StationClassID) */
|
||||||
#define DECLARE_POSTFIX_INCREMENT(type) \
|
#define DECLARE_POSTFIX_INCREMENT(enum_type) \
|
||||||
inline type operator ++(type& e, int) \
|
inline enum_type operator ++(enum_type& e, int) \
|
||||||
{ \
|
{ \
|
||||||
type e_org = e; \
|
enum_type e_org = e; \
|
||||||
e = (type)((int)e + 1); \
|
e = (enum_type)((std::underlying_type<enum_type>::type)e + 1); \
|
||||||
return e_org; \
|
return e_org; \
|
||||||
} \
|
} \
|
||||||
inline type operator --(type& e, int) \
|
inline enum_type operator --(enum_type& e, int) \
|
||||||
{ \
|
{ \
|
||||||
type e_org = e; \
|
enum_type e_org = e; \
|
||||||
e = (type)((int)e - 1); \
|
e = (enum_type)((std::underlying_type<enum_type>::type)e - 1); \
|
||||||
return e_org; \
|
return e_org; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user