소스 검색

Add example for tables

Ole 9 년 전
부모
커밋
495daa119d
2개의 변경된 파일24개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      Makefile
  2. 23 0
      examples/tables.cpp

+ 1 - 1
Makefile

@@ -12,7 +12,7 @@ TEST_OBJS       := $(TEST_SRCS:%.cpp=$(TEST_DIR)/%.o)
 
 # Example artifacts
 EXAMPLE_DIR     := examples
-EXAMPLE_SRCS    := types.cpp stack.cpp functions.cpp usertypes.cpp state.cpp
+EXAMPLE_SRCS    := types.cpp stack.cpp functions.cpp usertypes.cpp state.cpp tables.cpp
 EXAMPLE_DEPS    := $(EXAMPLE_SRCS:%.cpp=$(EXAMPLE_DIR)/%.d)
 EXAMPLE_OBJS    := $(EXAMPLE_SRCS:%.cpp=$(EXAMPLE_DIR)/%.out)
 

+ 23 - 0
examples/tables.cpp

@@ -0,0 +1,23 @@
+#include <luwra.hpp>
+
+#include <string>
+#include <iostream>
+
+using namespace luwra;
+
+int main() {
+	StateWrapper state;
+
+	state["t1"] = FieldVector {};
+
+	for (int i = 0; i < 10000; i++) {
+		state["t1"]["value"] = i;
+		int j = state["t1"]["value"];
+
+		if (j != i) {
+			return 1;
+		}
+	}
+
+	return 0;
+}