Guest User

Untitled

a guest
Feb 11th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.50 KB | None | 0 0
  1. void foo(A, B, C)(A a, B b, C c) { writeln(a, b, c) }
  2.  
  3. // is logically equivalent to:
  4.  
  5. auto foo(A, B, C)
  6. {
  7.     // # means "expression that follows should be evaluated at compile-time".
  8.     // In this case, # forces the return value to be a compile-time function object
  9.     // (not run-time pointer)
  10.     return #(A a, B b, C c)-> { writeln(a, b, c) }
  11. }
  12.  
  13. void main()
  14. {
  15.     auto args = {1, "two", 3.0}
  16.     foo(args.typeof)(args.flat)
  17.    
  18.     alias bar = foo(bool, string)
  19.     bar(true, "blah")
  20. }
Add Comment
Please, Sign In to add comment