blueloveTH 2 лет назад
Родитель
Сommit
fb5220a925
2 измененных файлов с 13 добавлено и 1 удалено
  1. 3 1
      src/expr.h
  2. 10 0
      src/vector.h

+ 3 - 1
src/expr.h

@@ -36,7 +36,9 @@ struct Expr{
 struct CodeEmitContext{
     VM* vm;
     CodeObject_ co;
-    stack<Expr_> s_expr;
+    // some bugs on MSVC (error C2280) when using std::vector<Expr_>
+    // so we use stack_no_copy instead
+    stack_no_copy<Expr_> s_expr;
     int level;
     std::set<Str> global_names;
     CodeEmitContext(VM* vm, CodeObject_ co, int level): vm(vm), co(co), level(level) {}

+ 10 - 0
src/vector.h

@@ -141,4 +141,14 @@ public:
 	Container& data() { return vec; }
 };
 
+template <typename T, typename Container=std::vector<T>>
+class stack_no_copy: public stack<T, Container>{
+public:
+    stack_no_copy() = default;
+    stack_no_copy(const stack_no_copy& other) = delete;
+    stack_no_copy& operator=(const stack_no_copy& other) = delete;
+    stack_no_copy(stack_no_copy&& other) noexcept = default;
+    stack_no_copy& operator=(stack_no_copy&& other) noexcept = default;
+};
+
 } // namespace pkpy