Changeset 1705
- Timestamp:
- 07/01/10 03:26:52 (14 years ago)
- Files:
-
- trunk/docsrc/changelog.dd (modified) (1 diff)
- trunk/phobos/std/traits.d (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docsrc/changelog.dd
r1702 r1705 6 6 $(VERSION 048, Jun 11, 2010, =================================================, 7 7 8 8 $(WHATSNEW 9 9 $(LI std.string: icmp() now works with all built-in string types.) 10 10 ) 11 11 $(BUGSFIXED 12 12 $(L1 $(Unlisted Bug): std.algorithm.filter not a forward range) 13 13 $(L1 $(Unlisted Bug): std.algorithm.Uniq requires a bidirectional range) 14 14 $(L1 $(Unlisted Bug): std.algorithm.Uniq missing a save() function) 15 15 $(L1 $(Unlisted Bug): std.algorithm.Group missing a save() function) 16 $(L1 $(Unlisted Bug): std.traits.isAssociativeArray reports true for structs w/ keys, values properties) 16 17 $(LI $(BUGZILLA 978): std.utf's toUTF* functions accept some invalid and reject some valid UTF) 17 18 $(LI $(BUGZILLA 996): Error in doc on implicit conversion between pointer and array) 18 19 $(LI $(BUGZILLA 2275): std.utf.toUTF16z() should return const(wchar)*) 20 $(LI $(BUGZILLA 2627): std.traits.hasAliasing reports true for static arrays) 19 21 $(LI $(BUGZILLA 2872): Length, opIndex for Map) 20 22 $(LI $(BUGZILLA 3202): std.math.pow cause dead loop) 21 23 $(LI $(BUGZILLA 3355): std.string.cmp works incorrectly for mixed-type and different-length strings) 22 24 $(LI $(BUGZILLA 3386): to!bool(string) is not implemented) 23 25 $(LI $(BUGZILLA 3436): std.functional.compose with only one function) 24 26 $(LI $(BUGZILLA 3439): std.range.Sequence.opIndex not consistent after calling popFront().) 25 27 $(LI $(BUGZILLA 3447): std.file uses unconventional file permissions) 26 28 $(LI $(BUGZILLA 3872): std.algorithm.filter could become bidirectional if its input range is bidir) 27 29 $(LI $(BUGZILLA 3874): std.range.stride assumes a bidirectional input range) 28 30 $(LI $(BUGZILLA 3937): os.path.dirname fails on absolute path) trunk/phobos/std/traits.d
r1680 r1705 841 841 private template HasRawPointerImpl(T...) 842 842 { 843 843 static if (T.length == 0) 844 844 { 845 845 enum result = false; 846 846 } 847 847 else 848 848 { 849 849 static if (is(T[0] foo : U*, U)) 850 850 enum hasRawAliasing = !is(U == immutable); 851 else static if (is(T[0] foo : U[], U) )851 else static if (is(T[0] foo : U[], U) && !isStaticArray!(T[0])) 852 852 enum hasRawAliasing = !is(U == immutable); 853 853 else 854 854 enum hasRawAliasing = false; 855 855 enum result = hasRawAliasing || HasRawPointerImpl!(T[1 .. $]).result; 856 856 } 857 857 } 858 858 859 859 private template HasRawLocalPointerImpl(T...) 860 860 { 861 861 static if (T.length == 0) … … 1098 1098 } 1099 1099 1100 1100 unittest 1101 1101 { 1102 1102 struct S1 { int a; Object b; } 1103 1103 static assert(hasAliasing!(S1)); 1104 1104 struct S2 { string a; } 1105 1105 static assert(!hasAliasing!(S2)); 1106 1106 struct S3 { int a; immutable Object b; } 1107 1107 static assert(!hasAliasing!(S3)); 1108 struct X { float[3] vals; } 1109 static assert(!hasAliasing!X); 1108 1110 } 1109 1111 1110 1112 /** 1111 1113 Returns $(D true) if and only if $(D T)'s representation includes at 1112 1114 least one of the following: $(OL $(LI a raw pointer $(D U*) and $(D U) 1113 1115 is not immutable or shared;) $(LI an array $(D U[]) and $(D U) is not 1114 1116 immutable or shared;) $(LI a reference to a class type $(D C) and 1115 1117 $(D C) is not immutable or shared.)) 1116 1118 */ 1117 1119 … … 2068 2070 static assert(!isSomeChar!(dstring)); 2069 2071 static assert(!isSomeChar!(char[4])); 2070 2072 } 2071 2073 2072 2074 /** 2073 2075 * Detect whether T is an associative array type 2074 2076 */ 2075 2077 2076 2078 template isAssociativeArray(T) 2077 2079 { 2078 enum bool isAssociativeArray = 2079 is(typeof(T.keys)) && is(typeof(T.values)); 2080 } 2081 2082 unittest 2083 { 2080 enum bool isAssociativeArray = __traits(isAssociativeArray, T); 2081 } 2082 2083 unittest 2084 { 2085 struct Foo { 2086 @property uint[] keys() { 2087 return null; 2088 } 2089 2090 @property uint[] values() { 2091 return null; 2092 } 2093 } 2094 2095 static assert(!isAssociativeArray!(Foo)); 2084 2096 static assert(!isAssociativeArray!(int)); 2085 2097 static assert(!isAssociativeArray!(int[])); 2086 2098 static assert(isAssociativeArray!(int[int])); 2087 2099 static assert(isAssociativeArray!(int[string])); 2088 2100 static assert(isAssociativeArray!(immutable(char[5])[int])); 2089 2101 } 2090 2102 2091 2103 /** 2092 2104 * Detect whether type T is a static array. 2093 2105 */
