• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 311, comments - 0, trackbacks - 0, articles - 0
              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            (地基工)TOLUA_TEMPLATE_BIND

            Posted on 2012-08-21 15:27 點點滴滴 閱讀(850) 評論(0)  編輯 收藏 引用 所屬分類: 02 編程語言
            One of the additional features of tolua++ is the support for class templates, by using the TOLUA_TEMPLATE_BIND directive. For example:
            class vector {
            
            	TOLUA_TEMPLATE_BIND(T, int, string, Vector3D, double)
            
            	void clear();
            	int size() const;
            
            	const T& operator[](int index) const;
            	T& operator[](int index);
            	void push_back(T val);
            
            	vector();
            	~vector();
            };
            
            The TOLUA_TEMPLATE_BIND directive has to be the first thing on the class declaration, otherwise it will be ignored. This code will create 4 versions of the class vector, one for each type specified on the TOLUA_TEMPLATE_BIND parameters, each replacing the macro T (specified as the first argument of TOLUA_TEMPLATE_BIND). Thus, the functions operator[], &operator[] and push_back will have different signatures on each version of the object. The objects will be recognized as vector<type> on further declarations, and the name of the table on Lua will be vector_type_. Thus, the following Lua code could be used:
            string_vector = vector_string_:new_local()
            string_vector:push_back("hello")
            string_vector:push_back("world")
            print(string_vector[0].." "..string_vector[1])
            
            Similarily, a template with more than 1 macro could be bound, and it could also inherit from another template:
            class hash_map : public map<K,V> {
            
            	TOLUA_TEMPLATE_BIND(K V, int string, string vector<double>)
            
            	V get_element(K key);
            	void set_element(K key, V value);
            
            	hash_map();
            	~hash_map();
            };
            結論:tolua++可以進行簡單的模板導出。
            日本强好片久久久久久AAA | 亚洲а∨天堂久久精品9966| 色妞色综合久久夜夜 | 久久久久久一区国产精品| 免费观看成人久久网免费观看| 久久午夜羞羞影院免费观看| 亚洲精品无码久久久久久| 中文精品久久久久人妻不卡| 国产精品一区二区久久精品涩爱| 欧美粉嫩小泬久久久久久久 | 国产精品99久久久久久猫咪| 国产成人综合久久精品尤物| 国产高潮国产高潮久久久91 | 国内精品久久久久久久久电影网| 久久99精品久久久久久秒播| 久久影院午夜理论片无码| 久久久综合香蕉尹人综合网| 伊人色综合久久天天人守人婷| 2021国内久久精品| 久久精品无码专区免费东京热| 久久久精品国产sm调教网站| 97久久超碰国产精品旧版| 99久久国产综合精品成人影院 | 东京热TOKYO综合久久精品| 99久久无色码中文字幕| 国产AV影片久久久久久| 久久精品国产99国产精品导航 | 亚洲欧洲久久久精品| 久久精品一本到99热免费| 国产精品日韩深夜福利久久| 一本色道久久88综合日韩精品| 色婷婷综合久久久中文字幕| 2021国产成人精品久久| 久久久久免费精品国产| 久久精品国产91久久综合麻豆自制 | 午夜精品久久影院蜜桃| 久久九九精品99国产精品| 三级韩国一区久久二区综合| 国产精品美女久久久久久2018| 久久亚洲AV永久无码精品| 久久er热视频在这里精品|