• <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++可以進行簡單的模板導出。
            97超级碰碰碰碰久久久久| 伊人久久精品影院| 蜜桃麻豆www久久| 97香蕉久久夜色精品国产| 国产ww久久久久久久久久| 一本一道久久综合狠狠老 | 72种姿势欧美久久久久大黄蕉| 91精品国产综合久久香蕉 | 国产A三级久久精品| 伊人久久大香线焦综合四虎| 久久人人爽人人爽人人片AV东京热| 91精品国产91久久久久久蜜臀| 久久成人小视频| 久久久久亚洲AV无码专区网站| 精品久久久久久久久中文字幕| 久久亚洲中文字幕精品有坂深雪| 亚洲综合精品香蕉久久网| 久久精品二区| 亚洲国产精品无码久久青草 | 久久久精品久久久久久| 国产精品99久久99久久久| 99久久精品国产麻豆| 亚洲中文久久精品无码| 亚洲?V乱码久久精品蜜桃| 久久婷婷人人澡人人| 国产2021久久精品| 中文精品久久久久国产网址| 国内精品久久久久影院免费| 久久综合亚洲欧美成人| 无码国产69精品久久久久网站| 国产精品久久久久jk制服| 色婷婷综合久久久久中文| 久久一日本道色综合久久| 国产美女久久精品香蕉69| 精品免费久久久久久久| 成人综合伊人五月婷久久| 久久香蕉国产线看观看乱码| 色综合久久88色综合天天| 精品久久久久国产免费| 一本色道久久88—综合亚洲精品| 亚洲愉拍99热成人精品热久久|