diff options
Diffstat (limited to 'include/ncurses/utils/modifiers.hpp')
-rw-r--r-- | include/ncurses/utils/modifiers.hpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/ncurses/utils/modifiers.hpp b/include/ncurses/utils/modifiers.hpp new file mode 100644 index 0000000..79e4139 --- /dev/null +++ b/include/ncurses/utils/modifiers.hpp @@ -0,0 +1,31 @@ +#ifndef INCLUDE_UTILS_MODIFIERS_HPP_ +#define INCLUDE_UTILS_MODIFIERS_HPP_ + +#include <type_traits> + +#include <ncurses/utils/flags.hpp> + +namespace NCURSES_CPP_NAMESPACE { + +template <typename Derived, typename ApplicantType> class composable { +public: + using flags_type = multiflags<ApplicantType>; + using flags_mask_type = multiflags<ApplicantType>; + + NCURSES_CPP_CONSTEXPR_14 composable & + operator&(const ApplicantType applicant) { + static_cast<Derived *>(this)->value_(); + } + + NCURSES_CPP_CONSTEXPR_14 composable &operator&(const flags_type &flags) { + value_ &= static_cast<flags_mask_type>(flags); + return *this; + } + +private: + value_type value_; +}; + +} // namespace NCURSES_CPP_NAMESPACE + +#endif // INCLUDE_UTILS_MODIFIERS_HPP_ |