Euphoria
cpp.h
Go to the documentation of this file.
1#pragma once
2
3namespace eu
4{
5
6// ------------------------------------------------------------------------------------------------
7// std utils
8
9// convert an enum class to it's underlying (int) type
10// src: https://twitter.com/idoccor/status/1314664849276899328
11template<typename E>
12constexpr typename std::underlying_type_t<E> base_cast(E e) noexcept
13{
14 return static_cast<typename std::underlying_type_t<E>>(e);
15}
16
17template<typename E>
18constexpr bool is_flag_set(E var, E flag)
19{
20 return (base_cast(var) & base_cast(flag)) > 0;
21}
22
23} // namespace eu
Definition assert.h:118
constexpr bool is_flag_set(E var, E flag)
Definition cpp.h:18
constexpr std::underlying_type_t< E > base_cast(E e) noexcept
Definition cpp.h:12