• <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++可以進行簡單的模板導出。
            国内精品久久久久久久久电影网| 亚洲?V乱码久久精品蜜桃| 久久免费的精品国产V∧ | 亚洲欧美日韩精品久久亚洲区| 久久免费99精品国产自在现线| 中文字幕无码精品亚洲资源网久久| 少妇精品久久久一区二区三区| 狠狠色综合网站久久久久久久| 伊人久久大香线蕉AV一区二区| 久久亚洲日韩看片无码| 久久精品免费观看| 狠狠色丁香久久婷婷综合图片| 国产精品久久久久久影院| 久久人人爽人人爽人人爽| 亚洲欧美日韩精品久久| 日本欧美久久久久免费播放网| 国产精品伦理久久久久久| 久久无码人妻一区二区三区午夜| 久久免费视频一区| 伊人久久综合热线大杳蕉下载| 久久久无码精品亚洲日韩按摩| 四虎国产精品免费久久| 精品久久久久久国产免费了| 精品综合久久久久久97超人| 久久久久久精品成人免费图片| 久久亚洲国产精品五月天婷| 久久免费精品一区二区| 久久人人爽爽爽人久久久| 亚洲伊人久久大香线蕉综合图片 | 亚洲中文字幕无码久久综合网| 久久精品二区| 久久精品女人天堂AV麻| 一本久久久久久久| 国产精品热久久毛片| 国产精品欧美久久久久无广告| 久久99精品久久久久久噜噜 | 狠狠色丁香久久综合婷婷| 国内精品久久久久久99| 久久精品国产免费| 久久99精品久久久久久秒播| 久久露脸国产精品|