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

為什么允許嵌套類模板的部分特化,而不允許完

Why is partial specialization of a nested class template allowed, while complete isn#39;t?(為什么允許嵌套類模板的部分特化,而不允許完全特化?)
本文介紹了為什么允許嵌套類模板的部分特化,而不允許完全特化?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..
    template<int x> struct A {                                                                                                    
        template<int y> struct B {};.                                                                                             
        template<int y, int unused> struct C {};                                                                                  
    };                                                                                                                            

    template<int x> template<> 
    struct A<x>::B<x> {}; // error: enclosing class templates are not explicitly specialized

    template<int x> template<int unused> 
    struct A<x>::C<x, unused> {}; // ok

那么,如果外部類也不是專門化的,那么為什么不允許對內部嵌套類(或函數)進行顯式專門化?奇怪的是,如果我只部分通過簡單地添加一個虛擬模板參數來專門化內部類,我就可以解決這個問題.讓事情變得更丑陋和更復雜,但它有效.

So why is the explicit specialization of a inner, nested class (or function) not allowed, if the outer class isn't specialized too? Strange enough, I can work around this behaviour if I only partially specialize the inner class with simply adding a dummy template parameter. Makes things uglier and more complex, but it works.

我會將完全特化視為部分特化的子集 - 特別是因為您可以通過添加虛擬參數將每個完全特化表示為部分特化.因此,對部分專業化和完全專業化之間的這種消歧對我來說并沒有什么意義.

I would consider complete specializations as a subset of partial specializations - especially because you can express every complete specialization as a partial with adding a dummy parameter. So this disambiguation between partial and full specialization doesn't really make sense for me.

不幸的是,comp.std.c++ 中沒有人敢回答,所以我懸賞再次將其放在這里.

Unfortunatly nobody at comp.std.c++ dared to answer, so I am putting it up here again with a bounty.

注意:對于一組外部類的內部類的遞歸模板,我需要此功能,并且內部參數的特化確實取決于外部模板參數.

Note: I need this feature for recursive templates of the inner class for a set of the outer class and the specialization of the inner parameter does depend on the outer template parameter.

推薦答案

我猜測為什么會發生這種情況:完整的專業化不再是模板類/函數",它們是真正的"類/方法,并且有真實的(鏈接器可見的)符號.但是對于部分專業模板中的完全專業模板,這將不是真的.可能做出這個決定只是為了簡化編譯器編寫者的生活(并在此過程中讓編碼人員的生活更加艱難:P).

My guess as to why this happens: complete specializations are no longer "template classes/functions", they are are "real" classes/methods, and get to have real (linker-visible) symbols. But for a completely-specialized template inside a partially-specialized one, this would not be true. Probably this decision was taken just to simplify the life of compiler-writers (and make life harder for coders, in the process :P ).

這篇關于為什么允許嵌套類模板的部分特化,而不允許完全特化?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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在线播放网站 | 自拍视频在线观看 | 98久久| 国产精品视频二区三区 | 性高湖久久久久久久久 | 亚洲精品白浆高清久久久久久 | 欧美视频成人 | 人人精品 | 亚洲视频一区二区三区 | 狠狠操在线 | 国产成人久久精品一区二区三区 | 国产日韩精品一区二区 | 美女黄网 | 美国黄色一级片 | av网站免费在线观看 | 亚洲欧美日韩中文字幕一区二区三区 | 国产欧美日韩综合精品一区二区 | 亚洲精品第一国产综合野 | 黄色在线免费观看 | 全免费a级毛片免费看视频免 | 日本又色又爽又黄的大片 | 免费在线观看黄网站 | 久久久91精品国产一区二区三区 | 色久在线 | www.五月婷婷.com | 国产精品久久久久久福利一牛影视 | 国产精品美女久久久久久久久久久 | 国产成人精品久久二区二区 | 免费欧美 | 国产一级黄色网 | 精品国产成人 | 国产91久久精品一区二区 | 中文字幕精品一区二区三区在线 | av一级久久| 拍真实国产伦偷精品 | 亚洲国产在 | 日日摸夜夜添夜夜添精品视频 | 亚洲高清av | 欧美片网站免费 |