• <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 點點滴滴 閱讀(857) 評論(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++可以進行簡單的模板導出。
            亚洲精品乱码久久久久久久久久久久 | 日本加勒比久久精品| 国产午夜精品理论片久久 | 天天影视色香欲综合久久| 亚洲人成无码网站久久99热国产| 99久久这里只精品国产免费| 亚洲av日韩精品久久久久久a| 精品精品国产自在久久高清| 久久九色综合九色99伊人| 奇米综合四色77777久久| 精品熟女少妇aⅴ免费久久| 欧美噜噜久久久XXX| 久久综合一区二区无码| 97久久精品国产精品青草| 2021国内精品久久久久久影院| 狠狠色丁香婷婷综合久久来| 超级97碰碰碰碰久久久久最新| 亚洲国产精品热久久| 久久久久免费看成人影片| 亚洲精品无码久久久| 久久AAAA片一区二区| jizzjizz国产精品久久| 性高湖久久久久久久久| 久久亚洲精品国产精品婷婷| 久久se精品一区二区影院| 久久国产乱子伦精品免费强| 久久狠狠高潮亚洲精品| 日产精品久久久久久久| 国产成人精品综合久久久久| 亚洲国产一成久久精品国产成人综合 | 久久精品国产亚洲AV香蕉| 要久久爱在线免费观看| 久久久久无码精品国产app| 亚洲天堂久久精品| 97久久精品人人做人人爽| 久久无码av三级| 超级碰久久免费公开视频| 久久久久久久尹人综合网亚洲 | 亚洲精品成人久久久| 亚洲午夜精品久久久久久app| 蜜桃麻豆www久久国产精品|