• <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++可以進行簡單的模板導出。
            久久久久国产亚洲AV麻豆| 久久亚洲精品无码AV红樱桃| 久久香蕉一级毛片| 久久精品无码av| 日韩精品久久久久久久电影蜜臀| 久久婷婷国产麻豆91天堂| 亚洲国产成人精品91久久久| 人人狠狠综合久久88成人| 国产午夜免费高清久久影院| 亚洲国产精品无码久久青草| 国产精品无码久久久久久| 亚洲乱码日产精品a级毛片久久| 久久久一本精品99久久精品88| 亚洲国产精品久久久久网站| 亚洲精品乱码久久久久久按摩 | 精品多毛少妇人妻AV免费久久| 久久强奷乱码老熟女网站| 国产叼嘿久久精品久久| 亚洲精品乱码久久久久久| 久久国产精品二国产精品| 久久精品蜜芽亚洲国产AV| 亚洲人成网站999久久久综合| 国产L精品国产亚洲区久久| 久久精品国产亚洲AV麻豆网站| 久久免费看黄a级毛片| 国产精品中文久久久久久久| 久久久受www免费人成| 九九热久久免费视频| 久久香蕉国产线看观看99| 国产欧美久久久精品| 国产亚洲综合久久系列| 色偷偷偷久久伊人大杳蕉| 亚洲精品乱码久久久久久蜜桃不卡| 久久精品日日躁夜夜躁欧美| 思思久久99热免费精品6| 91麻豆国产精品91久久久| 久久久久久久精品妇女99 | 精品久久久久久久无码| 久久天天躁夜夜躁狠狠躁2022| 久久人人添人人爽添人人片牛牛| 日本WV一本一道久久香蕉|