• <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 點點滴滴 閱讀(850) 評論(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++可以進行簡單的模板導出。
            久久久SS麻豆欧美国产日韩| 久久最新精品国产| 91精品国产色综久久| 狠狠色噜噜狠狠狠狠狠色综合久久| 久久久久久国产精品免费无码| 久久人做人爽一区二区三区| 97视频久久久| 久久青青草原精品国产| 精品少妇人妻av无码久久| 欧美精品一本久久男人的天堂| 四虎国产精品免费久久久| 久久99精品久久久久久不卡| 久久久久久av无码免费看大片| 亚洲国产小视频精品久久久三级 | 99久久国产亚洲综合精品| 精品无码久久久久国产动漫3d| 亚洲va国产va天堂va久久| 精品国产乱码久久久久久1区2区| 97久久精品人妻人人搡人人玩| 国产99久久久国产精品~~牛| 久久亚洲精品无码观看不卡| 久久久www免费人成精品| 久久久青草青青亚洲国产免观| 久久综合久久鬼色| 亚洲欧美成人综合久久久| 久久99国产亚洲高清观看首页| 久久天天躁狠狠躁夜夜2020老熟妇 | 精品久久久久久无码专区| 精品国产乱码久久久久久浪潮| 97久久国产露脸精品国产| 久久久久无码精品| 久久人人爽人人爽人人AV| 国产午夜精品理论片久久 | 亚洲精品乱码久久久久久自慰| 久久精品国产99国产电影网| 中文字幕亚洲综合久久菠萝蜜| 99久久精品国内| 国产偷久久久精品专区| 久久久久亚洲av毛片大| 伊人久久大香线蕉精品| 99久久国产热无码精品免费|