1 
2 module dquery.helper;
3 
4 import std.functional;
5 import std.typetuple;
6 
7 alias GetMember(Type, string Name) = Alias!(
8 	__traits(getMember, Type, Name)
9 );
10 
11 alias GetProtection(Type, string Name) = Alias!(
12 	__traits(getProtection, __traits(getMember, Type, Name))
13 );
14 
15 alias GetAttributes(alias Target) = Alias!(
16 	__traits(getAttributes, Target)
17 );
18 
19 alias GetAttributes(Type, string Name) = Alias!(
20 	__traits(getAttributes, __traits(getMember, Type, Name))
21 );
22 
23 /++
24  + Returns a template predicate from a unary function.
25  ++/
26 template UnaryToPred(alias Pred)
27 {
28 	alias UnaryToPred(alias Element) = Alias!(unaryFun!Pred(Element));
29 }
30 
31 template Compare(XList...)
32 {
33 	template With(YList...)
34 	if(XList.length > 0 && XList.length == YList.length)
35 	{
36 		enum With = (
37 			__traits(compiles, {
38 				static assert(is(XList[0] == YList[0]));
39 			}) ||
40 			__traits(compiles, {
41 				static assert(XList[0] == YList[0]);
42 			})
43 		) &&
44 		Compare!(XList[1 .. $]).With!(YList[1 .. $]);
45 	}
46 
47 	template With(YList...)
48 	if(XList.length == 0 && YList.length == 0)
49 	{
50 		enum With = true;
51 	}
52 
53 	template With(YList...)
54 	if(XList.length != YList.length)
55 	{
56 		enum With = false;
57 	}
58 }