diff --git a/changelog/range_predicate_element.dd b/changelog/range_predicate_element.dd deleted file mode 100644 index 570c561c2..000000000 --- a/changelog/range_predicate_element.dd +++ /dev/null @@ -1,24 +0,0 @@ -`isForwardRange`, `isBidirectionalRange`, and `isRandomAccessRange` now take an optional element type - -In Phobos 2.106, an optional second template parameter was added to -`isInputRange` to enable conveniently checking a range's element type. Now, the -same parameter has been added to `isForwardRange`, `isBidirectionalRange`, and -`isRandomAccessRange`. - -As before, if a second type argument is passed to one of these templates, the -range's element type is checked to see if it is -$(DDSUBLINK spec/const3, implicit_qualifier_conversions, qualifier-convertible) -to the given type, and this additional check must pass in order for the -template to evaluate to `true`. - -Examples: ---- -// exact match -static assert( isForwardRange!(int[], int)); - -// match with qualifier conversion -static assert( isBidirectionalRange!(int[], const(int)); - -// not a match -static assert(!isRandomAccessRange!(int[], string)); ---- diff --git a/changelog/upgrade-unicode.dd b/changelog/upgrade-unicode.dd deleted file mode 100644 index 62b3c25fd..000000000 --- a/changelog/upgrade-unicode.dd +++ /dev/null @@ -1,20 +0,0 @@ -std.uni has been upgraded from Unicode 15.0.0 to 15.1.0 - -This Unicode update was released September 12, 2023. -See: https://www.unicode.org/versions/Unicode15.1.0/ - -``` -import std; - -void main() -{ - const alphaCount = iota(0, dchar.max).filter!(std.uni.isAlpha).walkLength; - writeln(alphaCount); - // formerly: 137765 - // now: 138387 - // 622 new dchars return true for `isAlpha` -} -``` - -The internal unicode tables (std/internal/unicode_tables.d) have also been changed to use hex strings instead of array literals, which makes them faster to import. -The exact speed up depends on your computer and D compiler, but it likely cuts between 30 and 100 milliseconds if you compile something which imports `std.string` or `std.uni`. diff --git a/std/experimental/allocator/building_blocks/kernighan_ritchie.d b/std/experimental/allocator/building_blocks/kernighan_ritchie.d index 6883d33ad..167cf1bc6 100644 --- a/std/experimental/allocator/building_blocks/kernighan_ritchie.d +++ b/std/experimental/allocator/building_blocks/kernighan_ritchie.d @@ -647,7 +647,7 @@ fronting the GC allocator. import std.experimental.allocator.gc_allocator : GCAllocator; import std.typecons : Ternary; // KRRegion fronting a general-purpose allocator - ubyte[1024 * 128] buf; + align(KRRegion!().alignment) ubyte[1024 * 128] buf; auto alloc = fallbackAllocator(KRRegion!()(buf), GCAllocator.instance); auto b = alloc.allocate(100); assert(b.length == 100); @@ -916,7 +916,7 @@ version (StdUnittest) @system unittest { import std.typecons : Ternary; - ubyte[1024] b; + align(KRRegion!().alignment) ubyte[1024] b; auto alloc = KRRegion!()(b); auto k = alloc.allocate(128); diff --git a/std/net/curl.d b/std/net/curl.d index 6aec366c6..3f823013e 100644 --- a/std/net/curl.d +++ b/std/net/curl.d @@ -2422,6 +2422,7 @@ struct HTTP import std.algorithm.searching : findSplit, startsWith; import std.string : indexOf, chomp; import std.uni : toLower; + import std.exception : assumeUnique; // Wrap incoming callback in order to separate http status line from // http headers. On redirected requests there may be several such @@ -2448,7 +2449,9 @@ struct HTTP } auto m = header.findSplit(": "); - auto fieldName = m[0].toLower(); + const(char)[] lowerFieldName = m[0].toLower(); + ///Fixes https://issues.dlang.org/show_bug.cgi?id=24458 + string fieldName = lowerFieldName is m[0] ? lowerFieldName.idup : assumeUnique(lowerFieldName); auto fieldContent = m[2].chomp; if (fieldName == "content-type") { diff --git a/std/typecons.d b/std/typecons.d index 5c7a3d5ba..f5b48468a 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -559,6 +559,14 @@ private template isBuildableFrom(U) enum isBuildableFrom(T) = isBuildable!(T, U); } +private enum hasCopyCtor(T) = __traits(hasCopyConstructor, T); + +// T is expected to be an instantiation of Tuple. +private template noMemberHasCopyCtor(T) +{ + import std.meta : anySatisfy; + enum noMemberHasCopyCtor = !anySatisfy!(hasCopyCtor, T.Types); +} /** _Tuple of values, for example $(D Tuple!(int, string)) is a record that @@ -745,7 +753,8 @@ if (distinctFieldNames!(Specs)) * compatible with the target `Tuple`'s type. */ this(U)(U another) - if (areBuildCompatibleTuples!(typeof(this), U)) + if (areBuildCompatibleTuples!(typeof(this), U) && + (noMemberHasCopyCtor!(typeof(this)) || !is(Unqual!U == Unqual!(typeof(this))))) { field[] = another.field[]; } @@ -1655,6 +1664,42 @@ if (distinctFieldNames!(Specs)) Tuple!(MyStruct) t; } +// https://issues.dlang.org/show_bug.cgi?id=24465 +@safe unittest +{ + { + static struct S + { + this(ref return scope inout(S) rhs) scope @trusted inout pure nothrow {} + } + + static void foo(Tuple!S) + { + } + + Tuple!S t; + foo(t); + + auto t2 = Tuple!S(t); + } + + { + static struct S {} + Tuple!S t; + auto t2 = Tuple!S(t); + + // This can't be done if Tuple has a copy constructor, because it's not + // allowed to have an rvalue constructor at that point, and the + // compiler doesn't to something intelligent like transform it into a + // move instead. However, it has been legal with Tuple for a while + // (maybe even since it was first added) when the type doesn't have a + // copy constructor, so this is testing to make sure that the fix to + // make copy constructors work doesn't mess up the rvalue constructor + // when none of the Tuple's members have copy constructors. + auto t3 = Tuple!S(Tuple!S.init); + } +} + /** Creates a copy of a $(LREF Tuple) with its fields in _reverse order.