Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// allSatisfy-equivalent template from mach
- template All(alias predicate, T...){
- static if(T.length == 0){
- enum bool All = true;
- }else static if(T.length == 1){
- enum bool All = predicate!(T[0]);
- }else{
- enum bool All = (
- All!(predicate, T[0]) &&
- All!(predicate, T[1 .. $])
- );
- }
- }
- /// static foreach syntax suggestion
- template All(alias predicate, Tx...){
- foreach(T; Tx){
- static if(!predicate!T){
- enum bool All = false;
- // Some way to not evaluate after-loop `enum bool All = true;`
- // is required. `return` may be the best option for this?
- return;
- }
- }
- enum bool All = true;
- }
- /// another suggestion
- template All(alias predicate, Tx...){
- enum bool All = true;
- foreach(T; Tx){
- static if(!predicate!T){
- enum bool All = false;
- }
- }
- }
- // In mach currently
- template Map(alias transform, T...){
- static if(T.length == 0){
- alias Map = Aliases!();
- }else static if(T.length == 1){
- alias Map = Aliases!(transform!(T[0]));
- }else{
- alias Map = Aliases!(
- Map!(transform, T[0]),
- Map!(transform, T[1 .. $])
- );
- }
- }
- // static foreach suggestion
- template Map(alias transform, Tx...){
- alias Map = Aliases!() // Aliases ~= AliasSeq
- foreach(T; Tx){
- alias Map = Aliases!(Map, transform!T);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement