fork(1) download
  1. #include <iostream>
  2.  
  3. /*
  4.  * This is a simple example code for defining a simpler, more verbose and possible more readable syntax for declaring types in C++11.
  5.  */
  6.  
  7. /*
  8.  * -- Helper definitions for "named type definitions" --
  9.  */
  10.  
  11. // For declaring pointers
  12. template <typename T>
  13. using ptr = T*;
  14.  
  15. // For declaring references
  16. template <typename T>
  17. using ref = T&;
  18.  
  19. // For declaring Arrays
  20. template <typename T, size_t N>
  21. using ary = T[N];
  22.  
  23. // For declaring function pointers
  24. template <typename R, typename... P>
  25. using fptr = R (*) (P...);
  26.  
  27. // For declaring "const"
  28. template <typename T>
  29. using cnst = const T;
  30.  
  31. // Define an example function with a "complex" signature
  32. const int& test (const int* x [7], int* (&y) [7] ) {
  33. return *(y[0]);
  34. }
  35.  
  36.  
  37. int main() {
  38. // Define some simple variables using the simplified syntax
  39.  
  40. cnst<int> a = 42; // Constant integer
  41. ary<double, 25> b; // Array
  42. ref<ary<double, 25>> c = b; // Reference to array
  43. ptr<ary<double, 25>> d = &b; // Pointer to array
  44.  
  45.  
  46. // Define a function pointer to the above function
  47. fptr<ref<cnst<int>>, ary<ptr<cnst<int>>,7>, ref<ary<ptr<int>, 7>>> myFun = &test;
  48. return 0;
  49. }
Success #stdin #stdout 0s 3292KB
stdin
Standard input is empty
stdout
Standard output is empty