Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % cat allclasses1.d
- import std.array;
- import std.stdio;
- import std.traits;
- string GetMembers(T)() {
- auto members = [__traits(allMembers, T)];
- return join(result, ", ");
- }
- void main() {
- stdout.writefln("Got members: %s", GetMembers!std.stdio);
- }
- % rdmd allclasses1.d
- allclasses1.d(11): Error: template instance GetMembers!(std) GetMembers!(std) does not match template declaration GetMembers(T)()
- Failed: 'dmd' '-v' '-o-' 'allclasses1.d' '-I.'
- % cat allclasses2.d
- import std.array;
- import std.stdio;
- import std.traits;
- void main() {
- auto members = [__traits(allMembers, std.stdio)];
- auto joined = join(members, ", ");
- stdout.writefln("Got members: %s", members);
- }
- % rdmd allclasses2.d
- Got members: ["object", "core", "std", "fileno", "GENERIC_IO", "flockfile", "funlockfile", "fputc_unlocked", "fputwc_unlocked", "fgetc_unlocked", "fgetwc_unlocked", "FPUTC", "FPUTWC", "FGETC", "FGETWC", "FLOCK", "FUNLOCK", "ByRecord", "byRecord", "File", "LockingTextReader", "writefx", "isFileHandle", "isStreamingDevice", "write", "writeln", "writef", "writefln", "readf", "readln", "fopen", "popen", "binaryWrite", "lines", "chunks", "StdioException", "std_stdio_static_this", "stdin", "stdout", "stderr", "readlnImpl"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement