Changeset 1550
- Timestamp:
- 05/24/10 04:27:06 (15 years ago)
- Files:
-
- trunk/docsrc/changelog.dd (modified) (1 diff)
- trunk/phobos/std/typecons.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docsrc/changelog.dd
r1549 r1550 4 4 5 5 6 6 $(VERSION 047, May 9, 2010, =================================================, 7 7 8 8 $(WHATSNEW 9 9 $(LI std.functional: toDelegate now accepts callable(function pointers, delegates and objects implement opCall) ) 10 10 $(LI std.traits: Added templates to get compile-time information about functions.) 11 11 $(LI std.typecons: Added tie and AutoImplement.) 12 12 ) 13 13 $(BUGSFIXED 14 $(LI $(BUGZILLA 2738): Rebindable should work for interfaces.) 14 15 $(LI $(BUGZILLA 2835): std.socket.TcpSocket doesn't actually connect) 15 16 $(LI $(BUGZILLA 3088): std.xml.check() fails on xml comments) 16 17 $(LI $(BUGZILLA 3200): std.xml doesn't follow spec for Tag.text) 17 18 $(LI $(BUGZILLA 3873): std.range.repeat should have popBack defined) 18 19 $(LI $(BUGZILLA 3880): std.regex functions with const/immutable Regex object) 19 20 $(LI $(BUGZILLA 4109): writeln doesn't work with empty static array) 20 21 $(LI $(BUGZILLA 4202): Changset 1517 doesn't compile) 21 22 $(LI $(BUGZILLA 4228): std.array.replace contains 2 bugs) 22 23 ) 23 24 ) trunk/phobos/std/typecons.d
r1540 r1550 992 992 a = new Widget; // fine 993 993 ---- 994 994 995 995 You may want to use $(D Rebindable) when you want to have mutable 996 996 storage referring to $(D const) objects, for example an array of 997 997 references that must be sorted in place. $(D Rebindable) does not 998 998 break the soundness of D's type system and does not incur any of the 999 999 risks usually associated with $(D cast). 1000 1000 1001 1001 */ 1002 template Rebindable(T) if (is(T : Object) || isArray!(T))1002 template Rebindable(T) if (is(T == class) || is(T == interface) || isArray!(T)) 1003 1003 { 1004 1004 static if (!is(T X == const(U), U) && !is(T X == immutable(U), U)) 1005 1005 { 1006 1006 alias T Rebindable; 1007 1007 } 1008 1008 else static if (isArray!(T)) 1009 1009 { 1010 1010 alias const(ElementType!(T))[] Rebindable; 1011 1011 } 1012 1012 else … … 1051 1051 assert(obj1.get !is null); 1052 1052 1053 1053 Rebindable!(immutable(C)) obj2; 1054 1054 static assert(is(typeof(obj2.get) == immutable(C))); 1055 1055 static assert(is(typeof(obj2.stripped) == C)); 1056 1056 obj2 = new immutable(C); 1057 1057 assert(obj1.get !is null); 1058 1058 1059 1059 // test opDot 1060 1060 assert(obj2.foo == 42); 1061 1062 interface I { final int foo() const { return 42; } } 1063 Rebindable!(I) obj3; 1064 static assert(is(typeof(obj3) == I)); 1065 static assert(is(typeof(obj3.foo()) == int)); 1061 1066 } 1062 1067 1063 1068 /** 1064 1069 Order the provided members to minimize size while preserving alignment. 1065 1070 Returns a declaration to be mixed in. 1066 1071 1067 1072 Example: 1068 1073 --- 1069 1074 struct Banner { 1070 1075 mixin(alignForSize!(byte[6], double)(["name", "height"]));
