Guest User

Untitled

a guest
Jul 16th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #include <variant>
  2.  
  3. struct Nil {};
  4. struct Number { };
  5. struct String { };
  6.  
  7. struct Function {
  8. int idx_;
  9.  
  10. template<typename ...Args>
  11. Value call(Args && ...args) {
  12. pushArgs(std::forward<Args>(args)...);
  13.  
  14. callLuaFunction(idx_);
  15.  
  16. return popValue();
  17. }
  18. };
  19.  
  20. using Value = std::variant<Nil, Number, String, Function>;
  21.  
  22. Value popValue() {
  23. Value v = Nil{};
  24. //...
  25. return v;
  26. }
  27.  
  28. #include <variant>
  29.  
  30. struct Nil {};
  31. struct Number { };
  32. struct String { };
  33.  
  34. struct Function; // <-- Предварительное объявление класса
  35. struct Table; //UPD
  36.  
  37. using Value = std::variant<Nil, Number, String, Function, Table>;
  38.  
  39. Value popValue(); // <-- Объявление функции
  40.  
  41. struct Function {
  42. int idx_;
  43.  
  44. template<typename ...Args>
  45. Value call(Args && ...args) {
  46. // ...
  47. return popValue();
  48. }
  49. };
  50.  
  51. //------------UPD------------
  52. struct Table {
  53. Value member() {
  54. return popValue();
  55. }
  56. };
  57. //---------------------------
  58.  
  59. Value popValue() {
  60. Value v = Nil{};
  61. //...
  62. return v;
  63. }
  64.  
  65. #include <variant>
  66.  
  67. struct Nil {};
  68. struct Number { };
  69. struct String { };
  70.  
  71. struct Function; // <-- Предварительное объявление класса
  72.  
  73. using Value = std::variant<Nil, Number, String, Function>;
  74.  
  75. Value popValue(); // <-- Объявление функции
  76.  
  77. struct Function {
  78. int idx_;
  79.  
  80. template<typename ...Args>
  81. Value call(Args && ...args) {
  82. // ...
  83. return popValue();
  84. }
  85. };
  86.  
  87. Value popValue() {
  88. Value v = Nil{};
  89. //...
  90. return v;
  91. }
Add Comment
Please, Sign In to add comment