//Purpose: // Prototype d version of boost::mpl::set // //{ChangeLog: // 2007-01-09.0622 // WHAT: // Changed has_key.tester according to // suggestion in post with headers: /* From: Daniel Keep Newsgroups: digitalmars.D Subject: Re: can't use variadic template arg in dependent type Date: Tue, 09 Jan 2007 17:15:49 +0800 */ //}ChangeLog: class bool_ ( bool TrueFalse ) { } class set ( ) { } class set ( Head , Tail... ) : set!(Tail) //needed if specialization of has_key_tester to work. { private static alias Head _Head; private static alias Tail _Tail; } template has_key ( Key ) { bool_!(true) tester ( Set ) ( Set a_set ) { alias Set._Head Head; alias Set._Tail Tail; static if( !is( set!(Head,Tail) == Set) ) static assert(false, "I can see through your clever deception!"); return new bool_!(true); } bool_!(false) tester ( NotSet ) ( ... ) { return new bool_!(false); } } class not_member {} bool_!(true) tester ( Set ) ( Set a_set ) { alias Set._Head Head; alias Set._Tail Tail; static if( !is( set!(Head,Tail) == Set) ) static assert(false, "I can see through your clever deception!"); return new bool_!(true); } void test() { auto set_int_float=new set!(int,float); { bool_!(true) result=tester(set_int_float); } auto set_empty=new set!(); set_empty=set_int_float;//check that set_empty is superset of set_int_float { bool_!(true) result=has_key!(int).tester(set_int_float); } { bool_!(false) result=has_key!(not_member).tester(set_empty); } { bool_!(false) result=has_key!(not_member).tester(set_int_float); } }