diff --git a/src/tools.h b/src/tools.h index e5d55409..3f809f4d 100644 --- a/src/tools.h +++ b/src/tools.h @@ -96,4 +96,18 @@ int64_t OTSYS_TIME(); SpellGroup_t stringToSpellGroup(const std::string& value); -#endif // FS_TOOLS_H \ No newline at end of file +namespace tfs { + +#if __has_cpp_attribute(__cpp_lib_to_underlying) + +inline constexpr auto to_underlying(auto e) noexcept { return std::to_underlying(e); } + +#else + +inline constexpr auto to_underlying(auto e) noexcept { return static_cast>(e); } + +#endif + +} // namespace tfs + +#endif // FS_TOOLS_H