Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <variant>
- struct Nil {};
- struct Number { };
- struct String { };
- struct Function {
- int idx_;
- template<typename ...Args>
- Value call(Args && ...args) {
- pushArgs(std::forward<Args>(args)...);
- callLuaFunction(idx_);
- return popValue();
- }
- };
- using Value = std::variant<Nil, Number, String, Function>;
- Value popValue() {
- Value v = Nil{};
- //...
- return v;
- }
- #include <variant>
- struct Nil {};
- struct Number { };
- struct String { };
- struct Function; // <-- Предварительное объявление класса
- struct Table; //UPD
- using Value = std::variant<Nil, Number, String, Function, Table>;
- Value popValue(); // <-- Объявление функции
- struct Function {
- int idx_;
- template<typename ...Args>
- Value call(Args && ...args) {
- // ...
- return popValue();
- }
- };
- //------------UPD------------
- struct Table {
- Value member() {
- return popValue();
- }
- };
- //---------------------------
- Value popValue() {
- Value v = Nil{};
- //...
- return v;
- }
- #include <variant>
- struct Nil {};
- struct Number { };
- struct String { };
- struct Function; // <-- Предварительное объявление класса
- using Value = std::variant<Nil, Number, String, Function>;
- Value popValue(); // <-- Объявление функции
- struct Function {
- int idx_;
- template<typename ...Args>
- Value call(Args && ...args) {
- // ...
- return popValue();
- }
- };
- Value popValue() {
- Value v = Nil{};
- //...
- return v;
- }
Add Comment
Please, Sign In to add comment