| 1 |
// PERMUTE_ARGS: |
| 2 |
|
| 3 |
// Prefer immutable(char)[] to all others |
| 4 |
int foo( char[] a) { return 11; } |
| 5 |
int foo( const char[] a) { return 12; } |
| 6 |
int foo(immutable char[] a) { return 13; } |
| 7 |
int foo( wchar[] a) { return 21; } |
| 8 |
int foo( const wchar[] a) { return 22; } |
| 9 |
int foo(immutable wchar[] a) { return 23; } |
| 10 |
int foo( dchar[] a) { return 31; } |
| 11 |
int foo( const dchar[] a) { return 32; } |
| 12 |
int foo(immutable dchar[] a) { return 33; } |
| 13 |
|
| 14 |
// Prefer const conversion over polysemous conversion |
| 15 |
int bar( char[] a) { return 11; } |
| 16 |
int bar( const char[] a) { return 12; } |
| 17 |
// bar(immutable char[] a); |
| 18 |
int bar( wchar[] a) { return 21; } |
| 19 |
int bar( const wchar[] a) { return 22; } |
| 20 |
// bar(immutable wchar[] a); |
| 21 |
int bar( dchar[] a) { return 31; } |
| 22 |
int bar( const dchar[] a) { return 32; } |
| 23 |
// bar(immutable dchar[] a); |
| 24 |
|
| 25 |
// No conversion to mutable |
| 26 |
int baz( char[] a) { return 11; } |
| 27 |
// baz( const char[] a); |
| 28 |
// baz(immutable char[] a); |
| 29 |
int baz( wchar[] a) { return 21; } |
| 30 |
// baz( const wchar[] a); |
| 31 |
// baz(immutable wchar[] a); |
| 32 |
int baz( dchar[] a) { return 31; } |
| 33 |
// baz( const dchar[] a); |
| 34 |
// baz(immutable dchar[] a); |
| 35 |
|
| 36 |
int main() |
| 37 |
{ |
| 38 |
auto strn = "a"; |
| 39 |
auto strc = "a"c; |
| 40 |
auto strw = "a"w; |
| 41 |
auto strd = "a"d; |
| 42 |
|
| 43 |
assert(foo("a" ) == 13); |
| 44 |
assert(foo(strn) == 13); |
| 45 |
assert(foo("a"c) == 13); |
| 46 |
assert(foo(strc) == 13); |
| 47 |
assert(foo("a"w) == 23); |
| 48 |
assert(foo(strw) == 23); |
| 49 |
assert(foo("a"d) == 33); |
| 50 |
assert(foo(strd) == 33); |
| 51 |
|
| 52 |
assert(bar("a" ) == 12); |
| 53 |
assert(bar(strn) == 12); |
| 54 |
assert(bar("a"c) == 12); |
| 55 |
assert(bar(strc) == 12); |
| 56 |
assert(bar("a"w) == 22); |
| 57 |
assert(bar(strw) == 22); |
| 58 |
assert(bar("a"d) == 32); |
| 59 |
assert(bar(strd) == 32); |
| 60 |
|
| 61 |
static assert(!__traits(compiles, baz("a" ) )); |
| 62 |
static assert(!__traits(compiles, baz(strn) )); |
| 63 |
static assert(!__traits(compiles, baz("a"c) )); |
| 64 |
static assert(!__traits(compiles, baz(strc) )); |
| 65 |
static assert(!__traits(compiles, baz("a"w) )); |
| 66 |
static assert(!__traits(compiles, baz(strw) )); |
| 67 |
static assert(!__traits(compiles, baz("a"d) )); |
| 68 |
static assert(!__traits(compiles, baz(strd) )); |
| 69 |
|
| 70 |
return 0; |
| 71 |
} |