Fixposition SDK 0.0.0-heads/main-0-g90a51ff
Collection of c++ libraries and apps for use with Fixposition products
Loading...
Searching...
No Matches
types.hpp
Go to the documentation of this file.
1/**
2 * \verbatim
3 * ___ ___
4 * \ \ / /
5 * \ \/ / Copyright (c) Fixposition AG (www.fixposition.com) and contributors
6 * / /\ \ License: see the LICENSE file
7 * /__/ \__\
8 * \endverbatim
9 *
10 * @file
11 * @brief Fixposition SDK: Common types
12 *
13 * @page FPSDK_COMMON_TYPES Common types
14 *
15 * **API**: fpsdk_common/types.hpp and fpsdk::common::types
16 *
17 */
18#ifndef __FPSDK_COMMON_TYPES_HPP__
19#define __FPSDK_COMMON_TYPES_HPP__
20
21/* LIBC/STL */
22#include <cstdint>
23#include <type_traits>
24
25/* EXTERNAL */
26
27/* PACKAGE */
28
29namespace fpsdk {
30namespace common {
31/**
32 * @brief Common types
33 */
34namespace types {
35/* ****************************************************************************************************************** */
36
37/**
38 * @brief Convert enum class constant to the underlying integral type value
39 *
40 * @tparam T The enum class type
41 * @param[in] enum_val The enum constant
42 *
43 * @returns the integral value of the enum constant as the value of the underlying type
44 */
45template <typename T, typename = typename std::enable_if<std::is_enum<T>::value, T>::type>
46constexpr typename std::underlying_type<T>::type EnumToVal(T enum_val)
47{
48 return static_cast<typename std::underlying_type<T>::type>(enum_val);
49}
50
51/* ****************************************************************************************************************** */
52} // namespace types
53} // namespace common
54} // namespace fpsdk
55#endif // __FPSDK_COMMON_TYPES_HPP__
constexpr std::underlying_type< T >::type EnumToVal(T enum_val)
Convert enum class constant to the underlying integral type value.
Definition types.hpp:46
Fixposition SDK.