Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Template for new versions:
## Documentation

## API
- add flexible casting to ``enum_field`` to enable explicit casting to more types

## Lua

Expand Down
4 changes: 4 additions & 0 deletions library/include/DataDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,10 @@ namespace df
enum_field<EnumType,IntType> &operator=(EnumType ev) {
value = IntType(ev); return *this;
}
explicit operator IntType () const { return IntType(value); }
template <typename T>
explicit operator T () const { return static_cast<T>(IntType(value)); }

};

template<class ET, class IT>
Expand Down
Loading