Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into sha1
Browse files Browse the repository at this point in the history
  • Loading branch information
redstar committed Jun 4, 2012
2 parents 5b63c22 + f30dc4d commit 6eccf3f
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions std/format.d
Expand Up @@ -2193,7 +2193,12 @@ unittest

template hasToString(T, Char)
{
static if (is(typeof({ T val; FormatSpec!Char f; val.toString((const(char)[] s){}, f); })))
static if(isPointer!T && !isAggregateType!T)
{
// X* does not have toString, even if X is aggregate type has toString.
enum hasToString = 0;
}
else static if (is(typeof({ T val; FormatSpec!Char f; val.toString((const(char)[] s){}, f); })))
{
enum hasToString = 4;
}
Expand Down Expand Up @@ -2588,7 +2593,7 @@ unittest
Pointers are formatted as hex integers.
*/
void formatValue(Writer, T, Char)(Writer w, T val, ref FormatSpec!Char f)
if (/*!hasToString!(T, Char) && */isPointer!T)
if (!hasToString!(T, Char) && isPointer!T)
{
if (val is null)
put(w, "null");
Expand Down Expand Up @@ -2633,6 +2638,7 @@ unittest

unittest
{
// Test for issue 7869
struct S
{
string toString(){ return ""; }
Expand All @@ -2644,6 +2650,19 @@ unittest
formatTest( q, "FFEECCAA" );
}

unittest
{
// Test for issue 8186
class B
{
int*a;
this(){ a = new int; }
alias a this;
}
formatTest( B.init, "null" );
}


/**
Delegates are formatted by 'Attributes ReturnType delegate(Parameters)'
*/
Expand Down

0 comments on commit 6eccf3f

Please sign in to comment.