diff --git a/docs/changelog.txt b/docs/changelog.txt index 495a5ecc92..cfff16e5a4 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -65,6 +65,7 @@ Template for new versions: ## Documentation ## API +- add flexible casting to ``enum_field`` to enable explicit casting to more types ## Lua diff --git a/library/include/DataDefs.h b/library/include/DataDefs.h index 08d8d02097..88c4a93651 100644 --- a/library/include/DataDefs.h +++ b/library/include/DataDefs.h @@ -632,6 +632,10 @@ namespace df enum_field &operator=(EnumType ev) { value = IntType(ev); return *this; } + explicit operator IntType () const { return IntType(value); } + template + explicit operator T () const { return static_cast(IntType(value)); } + }; template