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

C++模板中實(shí)例化和特化的區(qū)別

Difference between instantiation and specialization in c++ templates(C++模板中實(shí)例化和特化的區(qū)別)
本文介紹了C++模板中實(shí)例化和特化的區(qū)別的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

C++ 模板上下文中的特化和實(shí)例化有什么區(qū)別.根據(jù)我目前閱讀的內(nèi)容,以下是我對(duì)特化和實(shí)例化的理解.

What is the difference between specialization and instantiation in context of C++ templates. From what I have read so far the following is what I have understood about specialization and instantiation.

template <typename T>
struct Struct
{

     T x;
};

template<>
struct Struct <int> //specialization
{

    //code
};

int main()
{
   Struct <int> s; //specialized version comes into play
   Struct <float> r; // Struct <float> is instantiated by the compiler as shown below

}

編譯器對(duì) Struct 的實(shí)例化

template <typename T=float>
struct Struct
{
    float x;
}

我對(duì)模板實(shí)例化和特化的理解是否正確?

Is my understanding of template instantiation and specialization correct?

推薦答案

(隱式)實(shí)例化

這就是您所說(shuō)的實(shí)例化(如問(wèn)題中所述)

(Implicit) Instantiation

This is what you refer to as instantiation (as mentioned in the Question)

這是當(dāng)您告訴編譯器使用給定類(lèi)型實(shí)例化模板時(shí),如下所示:

This is when you tell the compiler to instantiate the template with given types, like this:

template Struct<char>; // used to control the PLACE where the template is inst-ed

(顯式)專(zhuān)業(yè)化

這就是您所說(shuō)的專(zhuān)業(yè)化(如問(wèn)題中所述)

(Explicit) Specialization

This is what you refer to as specialization (as mentioned in the Question)

這是當(dāng)您為類(lèi)型的子集提供模板的替代定義時(shí),如下所示:

This is when you give an alternative definition to a template for a subset of types, like this:

template<class T> class Struct<T*> {...} // partial specialization for pointers

這篇關(guān)于C++模板中實(shí)例化和特化的區(qū)別的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Difference between std::reference_wrapper and simple pointer?(std::reference_wrapper 和簡(jiǎn)單指針的區(qū)別?)
Difference between const. pointer and reference?(常量之間的區(qū)別.指針和引用?)
How to access the contents of a vector from a pointer to the vector in C++?(c++ - 如何從指向向量的指針訪(fǎng)問(wèn)向量的內(nèi)容?)
Meaning of *amp; and **amp; in C++(*amp; 的含義和**amp;在 C++ 中)
Why can#39;t I do polymorphism with normal variables?(為什么我不能對(duì)普通變量進(jìn)行多態(tài)?)
Dereferencing deleted pointers always result in an Access Violation?(取消引用已刪除的指針總是會(huì)導(dǎo)致訪(fǎng)問(wèn)沖突?)
主站蜘蛛池模板: 不卡视频在线 | 中文字幕动漫成人 | 午夜激情在线 | 久久不卡| 国产免费又色又爽又黄在线观看 | 色精品| 国产免费人成xvideos视频 | 91精品久久久久久久99 | 国产一区二区三区久久久久久久久 | 国产视频中文字幕 | 久久久久久国产精品免费免费狐狸 | 精品日韩一区二区三区 | 国产你懂的在线观看 | 午夜激情在线 | 久久亚洲一区二区三区四区 | 久草a√ | 国产一区精品在线 | 国产97色| 国产在线一区二区三区 | 国产ts人妖系列高潮 | 99久久久无码国产精品 | 国产精品高清在线 | 涩涩视频网站在线观看 | 亚洲综合在线视频 | 日韩在线 | 成年女人免费v片 | 亚洲深夜福利 | 精彩视频一区二区三区 | 美女在线观看国产 | 国产精品欧美日韩 | 久久国产一区二区 | 免费在线视频精品 | 一区二区在线不卡 | 亚洲综合二区 | 亚洲一区免费在线 | 国产成人免费网站 | 亚洲欧美在线观看 | www日日日| 欧美中文在线 | 精品国产鲁一鲁一区二区张丽 | 成人精品啪啪欧美成 |