daily pastebin goal
56%
SHARE
TWEET

Untitled

a guest Feb 11th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top