1 #ifndef MF_MASKED_ELEM_H_
2 #define MF_MASKED_ELEM_H_
14 template<
typename Elem,
typename =
void>
16 static_assert(! std::is_const<Elem>::value,
"masked_elem cannot have const Elem");
24 explicit operator bool ()
const {
return !
is_null(); }
35 else if(a.
mask != b.
mask)
return false;
49 template<
typename Elem>
50 class masked_elem<Elem, std::enable_if_t<elem_traits<Elem>::is_nullable>> {
51 static_assert(! std::is_const<Elem>::value,
"masked_elem cannot have const Elem");
58 explicit operator bool ()
const {
return !
is_null(); }
74 operator const Elem& ()
const {
return elem; }
75 operator Elem& () {
return elem; }
83 template<
typename Elem>
89 template<
typename Elem>
94 template<
typename Elem>
99 template<
typename Elem>
101 using type = masked_elem<Elem>;
104 template<
typename Elem>
106 using type = masked_elem<Elem>;
112 template<
typename Elem>
using masked_type =
typename detail::masked_type<Elem>::type;
116 template<
typename Elem>
using unmasked_type =
typename detail::unmasked_type<Elem>::type;
masked_elem & operator=(const Elem &el)
Definition: masked_elem.h:31
masked_elem & operator=(const masked_elem &)=default
masked_elem()
Definition: masked_elem.h:26
Elem elem
Non-nullable element.
Definition: masked_elem.h:16
static masked_elem null()
Definition: masked_elem.h:22
bool is_null() const
Definition: masked_elem.h:23
Nullable wrapper for elem type which adds mask.
Definition: masked_elem.h:15
friend bool operator!=(const masked_elem &a, const masked_elem &b)
Definition: masked_elem.h:38
friend bool operator==(const masked_elem &a, const masked_elem &b)
Definition: masked_elem.h:67
Elem traits base class with the required members.
Definition: elem.h:14
typename detail::unmasked_type< Elem >::type unmasked_type
Remove mask to type Elem, if is is a masked_type.
Definition: masked_elem.h:116
#define MF_EXPECTS(condition)
Definition: common.h:27
Default elem traits, using Elem as standard layout scalar type.
Definition: elem.h:30
friend bool operator==(const masked_elem &a, const masked_elem &b)
Definition: masked_elem.h:33
typename detail::masked_type< Elem >::type masked_type
Add mask to type Elem, if not already a masked_type.
Definition: masked_elem.h:112
friend bool operator!=(const masked_elem &a, const masked_elem &b)
Definition: masked_elem.h:70
bool mask
Mask, false if masked_elem is null.
Definition: masked_elem.h:20
masked_elem(const Elem &el)
Definition: masked_elem.h:27