• <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++可以進行簡單的模板導出。
            精品久久久久久久国产潘金莲| 国产精品久久久久9999高清| 日日狠狠久久偷偷色综合96蜜桃| 精品久久久久久久久久久久久久久| 久久久久99精品成人片| 国产99久久久国产精品小说| 国内精品伊人久久久久av一坑 | 国产V综合V亚洲欧美久久| 国产精品视频久久| 中文字幕无码久久人妻| 国产精品久久久久久吹潮| 伊人色综合九久久天天蜜桃| 久久香蕉一级毛片| 色欲av伊人久久大香线蕉影院| 国产综合成人久久大片91| 人妻无码αv中文字幕久久| 色天使久久综合网天天| .精品久久久麻豆国产精品| 久久久高清免费视频| 国产精品99久久久久久董美香| 亚洲欧美伊人久久综合一区二区 | 奇米综合四色77777久久| 久久综合五月丁香久久激情| 久久精品亚洲中文字幕无码麻豆 | 亚洲国产日韩欧美综合久久| 久久久久久久综合日本亚洲| 久久夜色精品国产噜噜噜亚洲AV| 久久精品国产精品亚洲人人| 免费观看久久精彩视频| AV狠狠色丁香婷婷综合久久| 久久综合久久自在自线精品自 | 久久精品国产99国产精品| 国产精品九九九久久九九| 日本久久久久亚洲中字幕| 无码精品久久久天天影视| 亚洲成色WWW久久网站| 国内精品伊人久久久久777| 欧美激情一区二区久久久| 精产国品久久一二三产区区别 | 久久精品免费大片国产大片| 久久久无码精品亚洲日韩软件|