久久久久久久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?(取消引用已刪除的指針總是會導致訪問沖突?)
主站蜘蛛池模板: 欧美中文字幕一区二区三区亚洲 | 欧美久久一级特黄毛片 | 精品欧美乱码久久久久久 | 亚洲在线视频 | 久久精品aaa | 在线日韩精品视频 | 天天久久| 在线播放第一页 | 精品国产91乱码一区二区三区 | 欧美日韩淫片 | 精品av | 国产一级黄色网 | 91 在线| 国产乱码精品一区二三赶尸艳谈 | 久久久久久看片 | 天天久久 | 午夜精品福利视频 | 99视频在线| 国产精品视频观看 | 午夜在线 | 91视频在线观看 | 粉嫩一区二区三区性色av | 不卡欧美| 欧美日韩一区在线 | 久久综合久久自在自线精品自 | 免费在线观看av的网站 | 日韩淫片免费看 | 日韩成人一区 | 一区二区三区四区在线 | 欧美 日韩 国产 成人 | 欧美在线一区二区三区 | 在线观看亚洲一区二区 | 91精品国产91久久久久久最新 | 精品美女视频在线观看免费软件 | 91中文| 91色视频在线观看 | 日韩一区在线视频 | 午夜视频一区二区 | 欧美日韩精品一区 | 国产电影一区 | а天堂中文最新一区二区三区 |