| | 877 | bool _startIncl = true, _endExcl = true; |
|---|
| | 878 | _Range switchMode(string P, string V, bool INC)() { |
|---|
| | 879 | auto res = *this; |
|---|
| | 880 | if (mixin((INC?"!":"")~"res."~P)) { |
|---|
| | 881 | mixin("res."~P~" = "~(INC?"true":"false")~"; "); |
|---|
| | 882 | mixin("res."~V~" "~(INC?"--":"++")~"; "); |
|---|
| | 883 | } |
|---|
| | 884 | return res; |
|---|
| | 885 | } |
|---|
| | 886 | mixin switchMode!("_startIncl", "from", true) startIncl; |
|---|
| | 887 | mixin switchMode!("_startIncl", "from", false) startExcl; |
|---|
| | 888 | mixin switchMode!("_endExcl", "to", false) endIncl; |
|---|
| | 889 | mixin switchMode!("_endExcl", "to", true) endExcl; |
|---|
| 913 | | enum Start { Incl, Excl } |
|---|
| 914 | | enum End { Incl, Excl } |
|---|
| 915 | | static _Range!(T) opSlice(T, U)(T from, U to, Start sm=Start.Incl, End em=End.Excl) { |
|---|
| 916 | | if (sm != Start.Incl) from++; |
|---|
| 917 | | if (em != End.Excl) to++; |
|---|
| 918 | | return _Range!(T)(from, to); |
|---|
| 919 | | } |
|---|
| | 926 | static _Range!(T) opSlice(T, U)(T from, U to) { return _Range!(T)(from, to); } |
|---|