More type safety on SelectFlags

This commit is contained in:
Maxime Coste 2012-11-20 18:55:17 +01:00
parent 533079c389
commit 95cc08a19e

View File

@ -335,18 +335,23 @@ private:
template<typename T> template<typename T>
Repeated<T> repeated(T func) { return Repeated<T>(func); } Repeated<T> repeated(T func) { return Repeated<T>(func); }
namespace SelectFlags enum class SelectFlags
{ {
enum Type None = 0,
{ Reverse = 1,
None = 0, Inclusive = 2,
Reverse = 1, Extend = 4
Inclusive = 2, };
Extend = 4 constexpr SelectFlags operator|(SelectFlags lhs, SelectFlags rhs)
}; {
return (SelectFlags)((int) lhs | (int) rhs);
}
constexpr bool operator&(SelectFlags lhs, SelectFlags rhs)
{
return ((int) lhs & (int) rhs) != 0;
} }
template<int flags> template<SelectFlags flags>
void select_to_next_char(Context& context) void select_to_next_char(Context& context)
{ {
int param = context.numeric_param(); int param = context.numeric_param();