libzypp 17.37.10

EnumClass.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
11#ifndef ZYPP_BASE_ENUMCLASS_H
12#define ZYPP_BASE_ENUMCLASS_H
13
14#include <iosfwd>
15
16#include <zypp-core/base/PtrTypes.h>
17
19 namespace zypp
20{
22 namespace base
23 {
46 template<typename TEnumDef>
47 class EnumClass : public TEnumDef
48 {
49 public:
50 using Enum = typename TEnumDef::Enum;
51 using Integral = std::underlying_type_t<Enum>;
52
53 EnumClass( Enum val_r ) : _val( val_r ) {}
54
64 Enum asEnum() const { return _val; }
65
75 Integral asIntegral() const { return static_cast<Integral>(_val); }
76
77 friend bool operator==( const EnumClass & lhs, const EnumClass & rhs ) { return lhs._val == rhs._val; }
78 friend bool operator!=( const EnumClass & lhs, const EnumClass & rhs ) { return lhs._val != rhs._val; }
79 friend bool operator< ( const EnumClass & lhs, const EnumClass & rhs ) { return lhs._val < rhs._val; }
80 friend bool operator<=( const EnumClass & lhs, const EnumClass & rhs ) { return lhs._val <= rhs._val; }
81 friend bool operator> ( const EnumClass & lhs, const EnumClass & rhs ) { return lhs._val > rhs._val; }
82 friend bool operator>=( const EnumClass & lhs, const EnumClass & rhs ) { return lhs._val >= rhs._val; }
83
84 private:
85 Enum _val;
86 };
87 } // namespace base
89} // namespace zypp
91#endif // ZYPP_BASE_ENUMCLASS_H
zypp::base
Definition Random.cc:7
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::operator==
bool operator==(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition SetRelationMixin.h:84
zypp::operator>=
bool operator>=(const IdString &lhs, const char *rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition IdString.h:231
zypp::operator!=
bool operator!=(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition SetRelationMixin.h:109
zypp::operator<=
bool operator<=(const IdString &lhs, const char *rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition IdString.h:199
PtrTypes.h