• <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毛片| 久久久久久久久波多野高潮| 久久超碰97人人做人人爱| 久久狠狠高潮亚洲精品| 日韩亚洲国产综合久久久| 日韩精品久久无码人妻中文字幕| 久久精品国产影库免费看| 久久亚洲精品国产亚洲老地址| 一本久久知道综合久久| 久久久久久国产精品美女| 久久丫精品国产亚洲av| 亚洲国产小视频精品久久久三级| 久久亚洲精品无码AV红樱桃| 久久综合色之久久综合| 久久精品成人免费网站| 亚洲中文字幕无码久久综合网 | av无码久久久久不卡免费网站| 69国产成人综合久久精品| 欧美日韩精品久久免费| 久久99精品国产麻豆不卡| 久久成人国产精品二三区| 色偷偷88888欧美精品久久久| 日本欧美国产精品第一页久久| 久久久久国产精品| 成人国内精品久久久久影院| 伊人久久大香线蕉亚洲五月天| 亚洲中文字幕伊人久久无码| 国产一区二区精品久久凹凸| 婷婷久久综合九色综合98| 久久亚洲精精品中文字幕| 亚洲AV无码久久精品色欲| 久久精品国产亚洲AV不卡| 久久夜色精品国产噜噜亚洲a | 亚洲精品无码久久一线| 久久久久久国产精品美女| 久久精品中文字幕一区| 香蕉久久久久久狠狠色| 亚洲乱码精品久久久久..| 久久精品aⅴ无码中文字字幕不卡 久久精品aⅴ无码中文字字幕重口 | 久久亚洲熟女cc98cm| 午夜久久久久久禁播电影|