This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct MetaArray(seq...) | |
{ | |
alias seq Expand; | |
// CTFE-capable | |
bool opEquals(rhsSeq...)(MetaArray!rhsSeq ) | |
{ | |
return is(MetaArray!seq == MetaArray!rhsSeq); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <errno.h> | |
#include <fcntl.h> | |
#include <unistd.h> | |
int main() | |
{ | |
int fdesc = open("test-out.dat", O_RDWR | O_CREAT, 0744); | |
{ | |
char store[10]; | |
ssize_t r; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Optionalを使って() | |
{ | |
ubyte[] buf; | |
if (Optional!size_t r = read(buf)) | |
{ | |
if (r == 0) | |
{ | |
// EAGAIN | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.meta; | |
void main() | |
{ | |
Struct!(int, "x", double, "y") s; | |
s.x = 10; | |
s.y = 20.35; | |
} | |
struct Struct(TypesNames...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module meta; | |
@safe: | |
/** | |
*/ | |
template StaticTuple(seq...) | |
{ | |
alias seq StaticTuple; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio; | |
void main() | |
{ | |
auto src = Source(__FILE__); | |
auto buf = Buffer(src); | |
auto stm = TextStream(buf); | |
foreach (i; 1 .. 10) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
出力 | |
0,0 | |
1,0 | |
2,0 | |
3,0 | |
*/ | |
import std.stdio; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module std.meta; | |
// Workaround for a weird error: | |
// Error: "identifier 'length' of 'seq.length' is not defined" | |
private template staticLength_(seq...) | |
{ | |
enum staticLength_ = seq.length; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.format; | |
import std.stdio; | |
void main() | |
{ | |
formattedWrite((in char[] s) | |
{ | |
writeln(">> '", s, "'"); | |
}, | |
"%s %s %s", 1, 2, 3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface BinaryOperand(RHS, string op : "+") | |
{ | |
BinaryOperand opAdd(RHS other); | |
final BinaryOperand opBinary(string op : "+")(RHS other) | |
{ | |
return opAdd(other); | |
} | |
} |