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

非命名空間范圍內的顯式特化不會在 GCC 中編譯

Explicit specialization in non-namespace scope does not compile in GCC(非命名空間范圍內的顯式特化不會在 GCC 中編譯)
本文介紹了非命名空間范圍內的顯式特化不會在 GCC 中編譯的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

以下代碼在 Clang 中編譯,但在 GCC 中不編譯:

The following code compiles in Clang but does not in GCC:

template<typename T>
struct Widget
{
    template<typename U>
    void foo(U)
    {
    }

    template<>
    void foo(int*)
    {
    }
};

根據 C++ 標準([temp.expl.spec],第 2 段):

According to the C++ standard ([temp.expl.spec], paragraph 2):

可以在任何范圍內聲明顯式特化,其中相應的主模板可以定義

An explicit specialization may be declared in any scope in which the corresponding primary template may be defined

這是 GCC 中的錯誤嗎?如果是,我如何在其錯誤跟蹤器中找到它?

Is this a bug in GCC and if so how can I find it in its bug tracker?

這是 GCC 的輸出:

This is GCC's output:

prog.cc:13:14: error: explicit specialization in non-namespace scope 'struct Widget<T>'
     template<>
              ^

我使用的是 GCC HEAD 8.0.1,帶有 -std=c++2a.

I'm using GCC HEAD 8.0.1, with -std=c++2a.

推薦答案

這應該是 GCC 錯誤.在任何范圍內都應該允許完全特化,包括在類定義中.

This should be a GCC bug. Full specialization should be allowed in any scope, including in class definition.

根據 CWG 727,[temp.expl.spec] 第 2 段已更改為

According to CWG 727, [temp.expl.spec] paragraph 2 was changed from

(強調我的)

顯式特化應在包含特化模板的命名空間中聲明.聲明符 id 或 class-head-name 未限定的顯式特化應在模板的最近封閉命名空間中聲明,或者,如果命名空間是內聯的 (10.3.1 [namespace.def]),則應在其內部的任何命名空間中聲明.封閉命名空間集.這樣的聲明也可以是定義.如果聲明不是定義,則可以稍后定義特化(10.3.1.2 [namespace.memdef]).

An explicit specialization shall be declared in a namespace enclosing the specialized template. An explicit specialization whose declarator-id or class-head-name is not qualified shall be declared in the nearest enclosing namespace of the template, or, if the namespace is inline (10.3.1 [namespace.def]), any namespace from its enclosing namespace set. Such a declaration may also be a definition. If the declaration is not a definition, the specialization may be defined later (10.3.1.2 [namespace.memdef]).

(強調我的)

顯式特化可以在任何范圍內聲明,其中可以定義相應的主模板(10.3.1.2 [namespace.memdef]、12.2 [class.mem]、17.6.2 [temp.mem]).

An explicit specialization may be declared in any scope in which the corresponding primary template may be defined (10.3.1.2 [namespace.memdef], 12.2 [class.mem], 17.6.2 [temp.mem]).

似乎 GCC 沒有遵循這一點.

It seems GCC fails to follow this.

編輯

我已將該問題報告為錯誤 85282.

這篇關于非命名空間范圍內的顯式特化不會在 GCC 中編譯的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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?(取消引用已刪除的指針總是會導致訪問沖突?)
主站蜘蛛池模板: 黄网站涩免费蜜桃网站 | 欧美色视频免费 | 国产一区二区三区视频免费观看 | 99热.com | 午夜一区二区三区在线观看 | 国产精品视频一二三区 | 国产精品久久久久久久 | 欧美日韩在线观看一区二区三区 | 欧美午夜影院 | 欧美v免费 | 毛片a | 精品亚洲一区二区三区四区五区 | 亚洲高清在线观看 | 国产精品入口 | 色呦呦在线 | 婷婷色婷婷| 免费成人高清在线视频 | 99热这里| 国产精品久久777777 | 精品综合在线 | 超碰超碰 | 亚洲精品视频在线播放 | 欧美一级特黄aaa大片在线观看 | 欧美精品在线一区 | 亚洲欧美日韩久久久 | av色噜噜| 亚洲一区二区久久久 | 欧美日韩国产精品一区二区 | 国产一区二区三区四区 | 人成精品| 欧美日韩国产三级 | 国产日韩一区二区三免费高清 | 在线观看三级av | 成人性生交大片免费看中文带字幕 | 国产欧美一区二区三区在线看 | 久久人人爽人人爽 | 欧美在线一区视频 | 日本精品在线观看 | 欧美国产中文字幕 | 亚洲综合色婷婷 | 91久久看片 |