VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtEnumClassFlag.h
Go to the documentation of this file.
1 /***************************************************************************
2 ** Copyright (c) 2024 MAK Technologies, Inc.
3 ** All rights reserved
4 ***************************************************************************/
5 
23 
24 #pragma once
25 
26 // Intentionally undefined for non-enum types.
27 template <typename T, bool = std::is_enum<T>::value>
28 struct is_flag;
29 
30 template <typename T>
31 struct is_flag<T, true> : std::false_type { };
32 
33 template <typename T, typename std::enable_if<is_flag<T>::value>::type* = nullptr>
34 T operator |(T lhs, T rhs) {
35  using u_t = typename std::underlying_type<T>::type;
36  return static_cast<T>(static_cast<u_t>(lhs) | static_cast<u_t>(rhs));
37 }
38 
39 template <typename T, typename std::enable_if<is_flag<T>::value>::type* = nullptr>
40 T operator &(T lhs, T rhs) {
41  using u_t = typename std::underlying_type<T>::type;
42  return static_cast<T>(static_cast<u_t>(lhs) & static_cast<u_t>(rhs));
43 }
44 
Definition: DtEnumClassFlag.h:28
T operator&(T lhs, T rhs)
Definition: DtEnumClassFlag.h:40
T operator|(T lhs, T rhs)
Definition: DtEnumClassFlag.h:34

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)