codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
import std.stdio; import std.conv; import std.algorithm; struct Foo { float stepFloat; float smallStepFloat; float largeStepFloat; string label = "label"; int flags; int minInteger; int maxInteger; int stepInteger; int largeStepInteger; string shortLabel = "short"; short displayIndex; short category; short numParametersInCategory; short reserved; void func() { } int func2(int x, int y) { return 1; } } void printFields(T)(T args) { auto values = args.tupleof; size_t max; size_t temp; foreach (index, value; values) { temp = T.tupleof[index].stringof.length; if (max < temp) max = temp; } max += 1; foreach (index, value; values) { writefln("%-" ~ to!string(max) ~ "s %s", T.tupleof[index].stringof, value); } } void main() { Foo properties; writeln(); printFields(properties); }
Private
[
?
]
Run code
Submit