久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

模板 typedefs - 你的工作是什么?

Template typedefs - What#39;s your work around?(模板 typedefs - 你的工作是什么?)
本文介紹了模板 typedefs - 你的工作是什么?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

C++ 0x 具有模板別名(有時稱為模板 typedef).請參閱此處.C++ 的當前規范沒有.

C++ 0x has template aliases (sometimes referred to as template typedefs). See here. Current spec of C++ does not.

你喜歡用什么來解決?容器對象還是宏?你覺得值得嗎?

What do you like to use as work around ? Container objects or Macros ? Do you feel its worth it ?

推薦答案

你喜歡用什么來解決?容器對象還是宏?你覺得值得嗎?

What do you like to use as work around ? Container objects or Macros ? Do you feel its worth it ?

規范的方法是使用像這樣的元函數:

The canonical way is to use a metafunction like thus:

template <typename T>
struct my_string_map {
    typedef std::map<std::string, T> type;
};

// Invoke:

my_string_map<int>::type my_str_int_map;

這也用于 STL (allocator::rebind) 和許多庫,包括 Boost.我們在生物信息庫中廣泛使用它.

This is also used in the STL (allocator::rebind<U>) and in many libraries including Boost. We use it extensively in a bioinformatical library.

它很臃腫,但在 99% 的情況下都是最好的選擇.在這里使用宏是不值得的.

It's bloated, but it's the best alternative 99% of the time. Using macros here is not worth the many downsides.

(我修改了代碼以反映 Daniel 在評論中指出的 Boost/STL 約定.)

( I've amended the code to reflect Boost/STL conventions as pointed out by Daniel in his comment.)

這篇關于模板 typedefs - 你的工作是什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Difference between std::reference_wrapper and simple pointer?(std::reference_wrapper 和簡單指針的區別?)
Difference between const. pointer and reference?(常量之間的區別.指針和引用?)
How to access the contents of a vector from a pointer to the vector in C++?(c++ - 如何從指向向量的指針訪問向量的內容?)
Meaning of *amp; and **amp; in C++(*amp; 的含義和**amp;在 C++ 中)
Why can#39;t I do polymorphism with normal variables?(為什么我不能對普通變量進行多態?)
Dereferencing deleted pointers always result in an Access Violation?(取消引用已刪除的指針總是會導致訪問沖突?)
主站蜘蛛池模板: 午夜久久久 | 美女久久久久 | 一区二区影院 | 久久精品日产第一区二区三区 | 九九av| 亚洲九九色 | 福利精品| 亚洲黄色网址视频 | 97免费视频在线观看 | 男女爱爱网站 | 中文字幕在线一区 | 国产精品射 | 超碰综合| 亚洲午夜小视频 | www亚洲免费国内精品 | 国产成人精品久久二区二区91 | 国产99视频精品免费视频7 | 一色一黄视频 | 黑人巨大精品欧美一区二区免费 | 特黄色一级毛片 | 精品一区二区三区四区五区 | 亚洲国产欧美一区 | 一级二级三级在线观看 | 草久久| 久久机热 | 9191在线播放| 精品国产伦一区二区三区观看说明 | 伦理午夜电影免费观看 | 欧美激情综合色综合啪啪五月 | 一区二视频 | 欧美激情视频一区二区三区免费 | 久久精品视频播放 | 国产精品视频播放 | 婷婷福利视频导航 | 妞干网视频 | 性国产丰满麻豆videosex | 久久婷婷香蕉热狠狠综合 | 青青草久久 | 亚洲视频一区在线 | 亚洲激情视频在线 | 欧美亚洲第一区 |