• <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++可以進行簡單的模板導出。
            亚洲成色999久久网站| 国产精品99久久久精品无码| 韩国三级大全久久网站| 国产亚洲精品自在久久| 久久国产成人亚洲精品影院| 久久香综合精品久久伊人| 亚洲AV无一区二区三区久久| 免费精品99久久国产综合精品| 久久国产成人| 久久99亚洲网美利坚合众国| 国产女人aaa级久久久级| 青春久久| 久久男人Av资源网站无码软件| 久久se这里只有精品| 国内精品人妻无码久久久影院| 热RE99久久精品国产66热| 久久se精品一区二区| 久久无码专区国产精品发布| 国产精品亚洲美女久久久| 久久国产精品一国产精品金尊 | 99久久综合国产精品免费| 狠狠色丁香久久综合五月| 狠狠色噜噜色狠狠狠综合久久| 精品无码久久久久久国产| 麻豆AV一区二区三区久久| 伊色综合久久之综合久久| 久久国产福利免费| 国产99精品久久| 久久久久成人精品无码中文字幕 | 久久天堂AV综合合色蜜桃网| 久久影视国产亚洲| 国内精品久久久久久麻豆| 国产精品久久久久影院色| 久久av无码专区亚洲av桃花岛| 伊人久久无码中文字幕| 99久久99久久精品国产片果冻| 亚洲美日韩Av中文字幕无码久久久妻妇| 99久久免费国产精品热| 久久99国产精一区二区三区| 国产精品女同久久久久电影院| 久久久久人妻一区精品性色av|