Enums.hpp
Go to the documentation of this file.
1 // @formatter:off
2 //
3 // Balau core C++ library
4 //
5 // Copyright (C) 2008 Bora Software (contact@borasoftware.com)
6 //
7 // Licensed under the Boost Software License - Version 1.0 - August 17th, 2003.
8 // See the LICENSE file for the full license text.
9 //
10 
16 
17 #ifndef COM_BORA_SOFTWARE__BALAU_UTIL__ENUMS
18 #define COM_BORA_SOFTWARE__BALAU_UTIL__ENUMS
19 
20 #include <type_traits>
21 
22 namespace Balau::Util {
23 
27 struct Enums final {
31  template <typename E> static constexpr auto toUnderlying(E e) noexcept -> typename std::underlying_type<E>::type
32  {
33  return static_cast<typename std::underlying_type<E>::type>(e);
34  }
35 
37 
38  Enums() = delete;
39  Enums(const Enums &) = delete;
40  Enums & operator = (const Enums &) = delete;
41 };
42 
43 } // namespace Balau::Util
44 
45 #endif // COM_BORA_SOFTWARE__BALAU_UTIL__ENUMS
Utility functions.
static constexpr auto toUnderlying(E e) noexcept -> typename std::underlying_type< E >::type
Convert the strongly typed enum to its underlying integer.
Definition: Enums.hpp:31
Utilities for enums.
Definition: Enums.hpp:27