Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8f8979e
Revert "Merge pull request #4790 from JackStouffer/uni-private"
Nov 10, 2016
11a9c58
XREF -> REF
aG0aep6G Nov 13, 2016
2f27e58
Add regression test for issue 16663
Nov 10, 2016
73b699d
Revert "Merge pull request #4789 from JackStouffer/package2"
Nov 15, 2016
64cd526
Merge pull request #4899 from aG0aep6G/kill-xref
burner Nov 15, 2016
8b1a270
Merge pull request #4902 from Dicebot/revert-regressions3
MartinNowak Nov 16, 2016
ce85fd6
fix Issue 16661 - failing dstring/wstring format string
MartinNowak Nov 16, 2016
0556bf1
fix Issue 16667 - wrong @safe unittest compilation error
MartinNowak Nov 16, 2016
9707f00
Merge pull request #4904 from MartinNowak/fix16661
yebblies Nov 17, 2016
74acd69
remove pointless LREFs
aG0aep6G Nov 18, 2016
a7597df
Fix issue 16705 - TaskPool.reduce fails to compile "cannot get frame …
PetarKirov Nov 20, 2016
6a7ad38
Merge pull request #4915 from ZombineDev/patch-8
andralex Nov 20, 2016
ea55c96
move unittest outside of template
MartinNowak Nov 20, 2016
de688d9
Merge pull request #4901 from Dicebot/revert-regressions2
MartinNowak Nov 20, 2016
2a6b436
Merge pull request #4905 from MartinNowak/fix16667
Nov 20, 2016
dfebb1f
[Ddoc] backticks around isSorted and isStrictlyMonotonic
aG0aep6G Nov 21, 2016
5891dce
Merge pull request #4913 from aG0aep6G/std.algorithm.sorting-lrefs
andralex Nov 21, 2016
b44fb6b
Fix typo introduced in PR #4915
PetarKirov Nov 22, 2016
0949605
Merge pull request #4918 from ZombineDev/fix-typo-in-pr-4915
andralex Nov 22, 2016
c8a123f
fix issue 16948 - broken links in std.stdio due to inccorrect use of …
aG0aep6G Dec 4, 2016
68cf6e8
Merge pull request #4931 from aG0aep6G/16948
9il Dec 5, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion std/algorithm/setops.d
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ Returns:
A range containing the unique union of the given ranges.

See_Also:
$(XREF algorithm, sorting, merge)
$(REF merge, std,algorithm,sorting)
*/
auto setUnion(alias less = "a < b", Rs...)
(Rs rs)
Expand Down
11 changes: 4 additions & 7 deletions std/algorithm/sorting.d
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,20 @@ Checks whether a forward range is sorted according to the comparison
operation $(D less). Performs $(BIGOH r.length) evaluations of $(D
less).

Unlike $(LREF isSorted), $(LREF isStrictlyMonotonic) does not allow for equal values,
Unlike `isSorted`, `isStrictlyMonotonic` does not allow for equal values,
i.e. values for which both `less(a, b)` and `less(b, a)` are false.

With either function, the predicate must be a strict ordering just like with
$(LREF isSorted). For example, using `"a <= b"` instead of `"a < b"` is
`isSorted`. For example, using `"a <= b"` instead of `"a < b"` is
incorrect and will cause failed assertions.

Params:
less = Predicate the range should be sorted by.
r = Forward range to check for sortedness.

Returns:
`true` if the range is sorted, false otherwise. $(LREF isSorted) allows
duplicates, $(LREF isStrictlyMonotonic) not.
`true` if the range is sorted, false otherwise. `isSorted` allows
duplicates, `isStrictlyMonotonic` not.
*/
bool isSorted(alias less = "a < b", Range)(Range r) if (isForwardRange!(Range))
{
Expand Down Expand Up @@ -1055,9 +1055,6 @@ Params:

Returns:
A range containing the union of the given ranges.

See_Also:
$(XREF algorithm, setops, SetUnion)
*/
struct Merge(alias less = "a < b", Rs...) if (allSatisfy!(isInputRange, Rs))
{
Expand Down
61 changes: 34 additions & 27 deletions std/conv.d
Original file line number Diff line number Diff line change
Expand Up @@ -5552,42 +5552,49 @@ template castFrom(From)

return cast(To) value;
}
}

///
@safe unittest
///
@system unittest
{
// Regular cast, which has been verified to be legal by the programmer:
{
// Regular cast, which has been verified to be legal by the programmer:
{
long x;
auto y = cast(int) x;
}
long x;
auto y = cast(int) x;
}

// However this will still compile if 'x' is changed to be a pointer:
{
long* x;
auto y = cast(int) x;
}
// However this will still compile if 'x' is changed to be a pointer:
{
long* x;
auto y = cast(int) x;
}

// castFrom provides a more reliable alternative to casting:
{
long x;
auto y = castFrom!long.to!int(x);
}
// castFrom provides a more reliable alternative to casting:
{
long x;
auto y = castFrom!long.to!int(x);
}

// Changing the type of 'x' will now issue a compiler error,
// allowing bad casts to be caught before it's too late:
{
long* x;
static assert (
!__traits(compiles, castFrom!long.to!int(x))
);
// Changing the type of 'x' will now issue a compiler error,
// allowing bad casts to be caught before it's too late:
{
long* x;
static assert (
!__traits(compiles, castFrom!long.to!int(x))
);

// if cast is still needed, must be changed to:
auto y = castFrom!(long*).to!int(x);
}
// if cast is still needed, must be changed to:
auto y = castFrom!(long*).to!int(x);
}
}

// https://issues.dlang.org/show_bug.cgi?id=16667
unittest
{
ubyte[] a = ['a', 'b', 'c'];
assert(castFrom!(ubyte[]).to!(string)(a) == "abc");
}

/**
Check the correctness of a string for $(D hexString).
The result is true if and only if the input string is composed of whitespace
Expand Down
9 changes: 8 additions & 1 deletion std/format.d
Original file line number Diff line number Diff line change
Expand Up @@ -6479,6 +6479,13 @@ immutable(Char)[] format(Char, Args...)(in Char[] fmt, Args args) if (isSomeChar
assert(is(typeof(format("happy"d)) == dstring));
}

// https://issues.dlang.org/show_bug.cgi?id=16661
@safe unittest
{
assert(format("%.2f"d, 0.4) == "0.40");
assert("%02d"d.format(1) == "01"d);
}

/*****************************************************
* Format arguments into buffer $(I buf) which must be large
* enough to hold the result. Throws RangeError if it is not.
Expand Down Expand Up @@ -6570,7 +6577,7 @@ char[] sformat(Char, Args...)(char[] buf, in Char[] fmt, Args args)
* the difference between the starts of the arrays
*/
@trusted private pure nothrow @nogc
ptrdiff_t arrayPtrDiff(const void[] array1, const void[] array2)
ptrdiff_t arrayPtrDiff(T)(const T[] array1, const T[] array2)
{
return array1.ptr - array2.ptr;
}
46 changes: 24 additions & 22 deletions std/parallelism.d
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,21 @@ Warning: Unless marked as $(D @trusted) or $(D @safe), artifacts in
this module allow implicit data sharing between threads and cannot
guarantee that client code is free from low level data races.

Synopsis:
Source: $(PHOBOSSRC std/_parallelism.d)
Author: David Simcha
Copyright: Copyright (c) 2009-2011, David Simcha.
License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0)
*/
module std.parallelism;

---
import std.algorithm, std.parallelism, std.range;
///
unittest
{
import std.algorithm : map;
import std.range : iota;
import std.math : approxEqual;
import std.parallelism : taskPool;

void main() {
// Parallel reduce can be combined with
// std.algorithm.map to interesting effect.
// The following example (thanks to Russel Winder)
Expand All @@ -47,32 +56,25 @@ void main() {
// getTerm is evaluated in parallel as needed by
// TaskPool.reduce.
//
// Timings on an Athlon 64 X2 dual core machine:
// Timings on an Intel i5-3450 quad core machine
// for n = 1_000_000_000:
//
// TaskPool.reduce: 12.170 s
// std.algorithm.reduce: 24.065 s
// TaskPool.reduce: 1.067 s
// std.algorithm.reduce: 4.011 s

immutable n = 1_000_000_000;
immutable delta = 1.0 / n;
enum n = 1_000_000;
enum delta = 1.0 / n;

real getTerm(int i)
alias getTerm = (int i)
{
immutable x = ( i - 0.5 ) * delta;
return delta / ( 1.0 + x * x ) ;
}
};

immutable pi = 4.0 * taskPool.reduce!"a + b"(
std.algorithm.map!getTerm(iota(n))
);
}
---
immutable pi = 4.0 * taskPool.reduce!"a + b"(n.iota.map!getTerm);

Source: $(PHOBOSSRC std/_parallelism.d)
Author: David Simcha
Copyright: Copyright (c) 2009-2011, David Simcha.
License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0)
*/
module std.parallelism;
assert(pi.approxEqual(3.1415926));
}

import core.atomic;
import core.exception;
Expand Down
28 changes: 11 additions & 17 deletions std/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ else version (Posix)
else
static assert(0);

private:
version(Windows)
{
// core.stdc.stdio.fopen expects file names to be
Expand Down Expand Up @@ -247,7 +246,6 @@ version(HAS_GETDELIM) extern(C) nothrow @nogc
ptrdiff_t getline(char**, size_t*, FILE*);
}


//------------------------------------------------------------------------------
struct ByRecord(Fields...)
{
Expand Down Expand Up @@ -312,7 +310,6 @@ template byRecord(Fields...)
}
}

public:
/**
Encapsulates a $(D FILE*). Generally D does not attempt to provide
thin wrappers over equivalent functions in the C standard library, but
Expand Down Expand Up @@ -650,7 +647,6 @@ Throws: $(D ErrnoException) in case of error.
version(StdDdoc)
void windowsHandleOpen(HANDLE handle, in char[] stdioOpenmode);

/// ditto
version(Windows)
void windowsHandleOpen(HANDLE handle, in char[] stdioOpenmode)
{
Expand Down Expand Up @@ -1862,7 +1858,6 @@ Returns the underlying operating system $(D HANDLE) (Windows only).
version(StdDdoc)
@property HANDLE windowsHandle();

/// ditto
version(Windows)
@property HANDLE windowsHandle()
{
Expand All @@ -1879,7 +1874,7 @@ Range that reads one line at a time. Returned by $(LREF byLine).

Allows to directly use range operations on lines of a file.
*/
private struct ByLine(Char, Terminator)
struct ByLine(Char, Terminator)
{
private:
import std.typecons : RefCounted, RefCountedAutoInitialize;
Expand Down Expand Up @@ -2400,7 +2395,7 @@ $(REF readText, std,file)
/*
* Range that reads a chunk at a time.
*/
private struct ByChunk
struct ByChunk
{
private:
File file_;
Expand Down Expand Up @@ -2602,7 +2597,7 @@ $(D StdioException).
/*
$(D Range) that locks the file and allows fast writing to it.
*/
private struct LockingTextWriter
struct LockingTextWriter
{
private:
import std.range.primitives : ElementType, isInfinite, isInputRange;
Expand Down Expand Up @@ -2779,7 +2774,7 @@ See $(LREF byChunk) for an example.
// An output range which optionally locks the file and puts it into
// binary mode (similar to rawWrite). Because it needs to restore
// the file mode on destruction, it is RefCounted on Windows.
private struct BinaryWriterImpl(bool locking)
struct BinaryWriterImpl(bool locking)
{
import std.traits : hasIndirections;
private:
Expand Down Expand Up @@ -3194,7 +3189,7 @@ enum LockType
readWrite
}

private struct LockingTextReader
struct LockingTextReader
{
private File _f;
private char _front;
Expand Down Expand Up @@ -3914,7 +3909,6 @@ struct lines
this.terminator = terminator;
}

/// Implements `opApply` `foreach` support
int opApply(D)(scope D dg)
{
import std.traits : Parameters;
Expand Down Expand Up @@ -3958,8 +3952,8 @@ struct lines
return opApplyRaw(dg);
}
}

private int opApplyRaw(D)(scope D dg)
// no UTF checking
int opApplyRaw(D)(scope D dg)
{
import std.conv : to;
import std.exception : assumeUnique;
Expand Down Expand Up @@ -4317,7 +4311,7 @@ Initialize with a message and an error code.
}
}

package extern(C) void std_stdio_static_this()
extern(C) void std_stdio_static_this()
{
static import core.stdc.stdio;
//Bind stdin, stdout, stderr
Expand All @@ -4339,7 +4333,7 @@ __gshared
{
/** The standard input stream.
Bugs:
Due to $(WEB https://issues.dlang.org/show_bug.cgi?id=15768, bug 15768),
Due to $(LINK2 https://issues.dlang.org/show_bug.cgi?id=15768, bug 15768),
it is thread un-safe to reassign `stdin` to a different `File` instance
than the default.
*/
Expand All @@ -4363,15 +4357,15 @@ __gshared
/**
The standard output stream.
Bugs:
Due to $(WEB https://issues.dlang.org/show_bug.cgi?id=15768, bug 15768),
Due to $(LINK2 https://issues.dlang.org/show_bug.cgi?id=15768, bug 15768),
it is thread un-safe to reassign `stdout` to a different `File` instance
than the default.
*/
File stdout;
/**
The standard error stream.
Bugs:
Due to $(WEB https://issues.dlang.org/show_bug.cgi?id=15768, bug 15768),
Due to $(LINK2 https://issues.dlang.org/show_bug.cgi?id=15768, bug 15768),
it is thread un-safe to reassign `stderr` to a different `File` instance
than the default.
*/
Expand Down
Loading