木隶念什么| 奇可以加什么偏旁| 海边有什么| 高血糖主食吃什么好| 蛇盘疮吃什么药好得快| 青椒是什么意思| 杨梅吃了有什么好处| 关节炎用什么药最好| 胰腺炎是什么原因引起的| 什么药可以延长时间| 一个山一个见读什么| essence什么意思| 白交念什么| 诺欣妥是什么药| 巴西龟吃什么食物| 十指纤纤尽夸巧是什么生肖| 群星是什么意思| 大力念什么| 脂肪瘤去医院挂什么科| 截胡什么意思| apm是什么| 抵牾是什么意思| 什么是猝死| 天蝎男和什么星座最配| 碱性磷酸酶高是什么意思| 蒌蒿是什么| 清华大学校长是什么级别| 夏至是什么| 葛根的作用是什么| 舌吻有什么好处| 欲购从速什么意思| 一金有什么用| 什么叫钙化| 老公的弟弟叫什么| 血压高吃什么药比较好| 吃什么东西可以降压| 长沙开福寺求什么最灵| 手足口病疫苗什么时候打| 神经性头痛吃什么药| 左眼皮跳跳好事要来到是什么歌| 激情什么意思| 动态心电图能检查出什么病| 地位是什么意思| 人瘦是什么原因造成的| 吃鸡是什么意思| jnby是什么牌子| 子宫内膜增生是什么原因| 谷雨是什么意思| 吃什么容易怀孕| 最好的补钙方法是什么| ot是什么意思| 易烊千玺的真名叫什么| 拔指甲挂什么科| 大男子主义是什么意思| 大是大非是什么意思| 啪啪是什么意思| 烧烤烤什么好吃| 起付线是什么意思| 小孩过敏性咳嗽吃什么药| 妤字属于五行属什么| 不可小觑什么意思| edf是什么意思| 白球比偏低吃什么补| 今年农历是什么年| 细菌性前列腺炎吃什么药| 梦见抓龙虾是什么意思| 尿常规异常是什么意思| 白牌黑字是什么车牌| 六点半是什么时辰| 12月13日是什么星座| 梦见晒衣服是什么意思| mama是什么意思| 血小板高什么原因| 外科检查一般检查什么| 促甲状腺激素低是什么原因| 蝴蝶兰什么时候开花| 孕检挂什么科| 长宽高用什么字母表示| eur是什么意思| 合胞病毒吃什么药| 菠萝蜜不能跟什么一起吃| 儿童干咳吃什么药效果好| 卵巢多囊症是什么原因造成| 补休是什么意思| 嘴唇轻微发麻什么病兆| 男性霉菌感染用什么药| 脖子发痒是什么原因| 喉咙有痰咳嗽是什么原因| 脚背浮肿是什么原因引起的| 淋巴结节什么症状| 秽是什么意思| fdi是什么意思| 硬结灶是什么意思| 心焦是什么意思| 名媛什么意思| 错综复杂是什么意思| 长痘吃什么水果好| 手腕血管疼是什么原因| 至加秦是什么字| 什么饼不能吃脑筋急转弯| 喝藏红花有什么好处| 什么的云海| 睡美人最怕什么脑筋急转弯| 头皮痒头皮屑多是什么原因| 嗓子痒咳嗽吃什么药| 老人说胡话是什么征兆| 双抗是什么意思| 什么色| 干涸是什么意思| 花心大萝卜是什么意思| 唾手可得是什么意思| 银手镯变黑是什么原因| 纪年是什么意思| 海是什么生肖| 咳嗽吃什么菜好| 诗五行属性是什么| 白菜什么时候种| 膝盖疼痛吃什么药好| 梦见野猪是什么预兆| 看男科挂什么门诊| 百合什么时候收获| 徐才厚什么级别| 胰岛素抵抗是什么| 2008年出生的属什么| momo是什么意思| 四个火读什么字| 琼瑶剧是什么意思| 甘草配什么泡水喝最好| 胃炎吃什么食物好养胃| 牙齿突然出血是什么原因| 吃什么可以去湿气| 言字五行属什么| 做梦车丢了有什么预兆| 87属什么| 小孩肚脐眼上面疼是什么原因| 吃什么药头脑立刻清醒| 洗牙为什么要验血| 陶渊明什么朝代| 东京热是什么| 1987年属什么今年多大| 小老弟是什么意思| 封闭是什么意思| 干预是什么意思| 老是掉头发是什么原因| lhc是什么意思| 送男人什么礼物最难忘| 早泄是什么原因| 涤棉是什么材质| 什么面条好吃| 郑州有什么好玩的景点| 掌眼什么意思| 脂肪瘤是什么引起的| 鲶鱼效应是什么意思| 超细旦是什么面料| 韩国古代叫什么| 胆汁为什么会反流到胃里面| 下肢水肿是什么原因| 狗狗不能吃什么| 2008属什么| 尿道炎是什么原因引起的| 11月16号是什么星座| 名落孙山的意思是什么| 受精卵着床是什么意思| 1919年发生了什么| 昆仑玉是什么玉| 又拉肚子又呕吐是什么原因| 嬗变是什么意思| 晗是什么意思| 胃疼看病挂什么科| 情绪波动是什么意思| 阴茎硬不起吃什么药| 相对是什么意思| 痛风吃什么中药| 霉菌性阴道炎吃什么消炎药| 外感风热是什么意思| 六三年属什么生肖| 快乐是什么意思| 血小板低有什么危险| 八十岁是什么之年| 缺维生素e有什么症状| 什么是英语自然拼读| 530是什么意思| 驴血为什么是白色的| 27属什么| 肝区回声密集是什么意思| 胰腺炎挂什么科| 宫腔镜检查后需要注意什么| 15朵玫瑰花代表什么意思| 中午吃什么| 就诊卡是什么| 突然抽搐失去意识是什么原因| 二龙戏珠是什么意思| 淋巴细胞百分比偏低是什么意思| 子宫内膜异位症是什么意思| 忤是什么意思| 水落石出开过什么生肖| 忽必烈和成吉思汗是什么关系| 经常扁桃体发炎是什么原因| 哮喘用什么药| 包浆是什么意思| 捐肾对身体有什么影响| 脂肪肝什么东西不能吃| 跟腱为什么会断裂| 清真是什么意思啊| 韩愈字什么| 皿是什么意思| 讳莫如深什么意思| 大蒜泡酒治什么病| 首级是什么意思| 小孩拉肚子吃什么药好| 印度属于什么亚| 最坚固的锁怕什么| 走后门什么意思| 有什么好| 朱元璋为什么杀李善长| 秒后面是什么单位| 瘘管是什么症状| 晚霞是什么颜色的| 人体缺少蛋白质会有什么症状| 男性囊肿是什么原因引起的| 洁颜蜜是什么| insun是什么牌子| c表示什么| 痰饮是什么意思| 灵芝有什么作用| showroom是什么意思| 草是什么植物| 妈妈的妈妈叫什么| 经常吃秋葵有什么好处| 尼泊尔人是什么人种| 被动什么意思| 幽门螺旋杆菌感染吃什么药| 查甲功挂什么科| 什么东西燃烧脂肪最快| 军统是什么| 吃芒果不能和什么一起吃| 眼睛闪光是什么症状| 直肠指检能检查出什么| 什么大什么功| 来月经喝红糖水有什么好处| 睡前一杯牛奶有什么好处| 陈皮和什么泡水喝最好| 1981年属什么生肖| 对牛弹琴代表什么生肖| 肺部钙化是什么意思啊| 姨妈安全期是什么时候| 什么都不做| 人脉是什么意思| 乐松是什么药| 心脏不好的人吃什么好| 品是什么意思| 啫啫煲为什么念jue| 煮海带放什么容易烂| 左下腹有什么器官| 光明会到底是干什么的| 螃蟹用什么呼吸| 吃了螃蟹后不能吃什么| 专柜是什么意思| 倒数第二颗牙齿叫什么| 前列腺炎吃什么好| 血窦是什么意思| 胸口长痘痘是什么原因| 牡丹花代表什么生肖| 什么是墨菲定律| 百度
Home Backend Development C++ Is Redundant Template Parameter Listing in C 20 Class Template Constructors Allowed?

美开始第二例基因编辑治疗试验 美媒:患者反映良好

Nov 26, 2024 am 06:54 AM

百度 第三,巩固拓展落实中央八项规定精神成果。

Is Redundant Template Parameter Listing in C  20 Class Template Constructors Allowed?

Redundant Template Parameter Lists in Class Template Constructors in C 20

The validity of class template constructors having redundant template parameter lists has been debated since the introduction of C 20. Here's the issue and its resolution:

In C 17, the code below was considered well-formed:

template<typename T>
struct S {
    S<T>();
};

However, in C 20, the same code triggers an error in some compilers (e.g., gcc trunk) under -std=c 20:

error: expected unqualified-id before ')' token
    3 |     S<T>();
                 ^

Change in C 20

The C 20 standard mandates a change in the syntax of class template constructor declarations. The following delta in the standard's compatibility section highlights this:

[diff.cpp17.class]

...

Change: A simple-template-id is no longer valid as the declarator-id of a constructor or destructor.
Rationale: Remove potentially error-prone option for redundancy.
...

Essentially, the "redundant" template parameter list, S(), used in the previous code is no longer permitted. Instead, the injected class name, S, must be used:

template<typename T>
struct S {
    S(); // CORRECT C++20 syntax
};

Rationale

The rationale for this change is to reduce the risk of errors by disallowing the use of simple template IDs. By enforcing the explicit use of the injected class name, the compiler can more accurately resolve the intended constructor.

Conclusion

This change in C 20 does not constitute a bug, but rather an intentional breaking change to enhance the clarity and correctness of class template constructor declarations. While this may cause compatibility issues with existing code relying on the previous syntax, it ultimately improves the overall safety and reliability of C applications.

The above is the detailed content of Is Redundant Template Parameter Listing in C 20 Class Template Constructors Allowed?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72
Using std::chrono in C Using std::chrono in C Jul 15, 2025 am 01:30 AM

std::chrono is used in C to process time, including obtaining the current time, measuring execution time, operation time point and duration, and formatting analysis time. 1. Use std::chrono::system_clock::now() to obtain the current time, which can be converted into a readable string, but the system clock may not be monotonous; 2. Use std::chrono::steady_clock to measure the execution time to ensure monotony, and convert it into milliseconds, seconds and other units through duration_cast; 3. Time point (time_point) and duration (duration) can be interoperable, but attention should be paid to unit compatibility and clock epoch (epoch)

What is the volatile keyword in C  ? What is the volatile keyword in C ? Jul 04, 2025 am 01:09 AM

volatile tells the compiler that the value of the variable may change at any time, preventing the compiler from optimizing access. 1. Used for hardware registers, signal handlers, or shared variables between threads (but modern C recommends std::atomic). 2. Each access is directly read and write memory instead of cached to registers. 3. It does not provide atomicity or thread safety, and only ensures that the compiler does not optimize read and write. 4. Constantly, the two are sometimes used in combination to represent read-only but externally modifyable variables. 5. It cannot replace mutexes or atomic operations, and excessive use will affect performance.

How to get a stack trace in C  ? How to get a stack trace in C ? Jul 07, 2025 am 01:41 AM

There are mainly the following methods to obtain stack traces in C: 1. Use backtrace and backtrace_symbols functions on Linux platform. By including obtaining the call stack and printing symbol information, the -rdynamic parameter needs to be added when compiling; 2. Use CaptureStackBackTrace function on Windows platform, and you need to link DbgHelp.lib and rely on PDB file to parse the function name; 3. Use third-party libraries such as GoogleBreakpad or Boost.Stacktrace to cross-platform and simplify stack capture operations; 4. In exception handling, combine the above methods to automatically output stack information in catch blocks

What is a POD (Plain Old Data) type in C  ? What is a POD (Plain Old Data) type in C ? Jul 12, 2025 am 02:15 AM

In C, the POD (PlainOldData) type refers to a type with a simple structure and compatible with C language data processing. It needs to meet two conditions: it has ordinary copy semantics, which can be copied by memcpy; it has a standard layout and the memory structure is predictable. Specific requirements include: all non-static members are public, no user-defined constructors or destructors, no virtual functions or base classes, and all non-static members themselves are PODs. For example structPoint{intx;inty;} is POD. Its uses include binary I/O, C interoperability, performance optimization, etc. You can check whether the type is POD through std::is_pod, but it is recommended to use std::is_trivia after C 11.

How to call Python from C  ? How to call Python from C ? Jul 08, 2025 am 12:40 AM

To call Python code in C, you must first initialize the interpreter, and then you can achieve interaction by executing strings, files, or calling specific functions. 1. Initialize the interpreter with Py_Initialize() and close it with Py_Finalize(); 2. Execute string code or PyRun_SimpleFile with PyRun_SimpleFile; 3. Import modules through PyImport_ImportModule, get the function through PyObject_GetAttrString, construct parameters of Py_BuildValue, call the function and process return

What is function hiding in C  ? What is function hiding in C ? Jul 05, 2025 am 01:44 AM

FunctionhidinginC occurswhenaderivedclassdefinesafunctionwiththesamenameasabaseclassfunction,makingthebaseversioninaccessiblethroughthederivedclass.Thishappenswhenthebasefunctionisn’tvirtualorsignaturesdon’tmatchforoverriding,andnousingdeclarationis

How to pass a function as a parameter in C  ? How to pass a function as a parameter in C ? Jul 12, 2025 am 01:34 AM

In C, there are three main ways to pass functions as parameters: using function pointers, std::function and Lambda expressions, and template generics. 1. Function pointers are the most basic method, suitable for simple scenarios or C interface compatible, but poor readability; 2. Std::function combined with Lambda expressions is a recommended method in modern C, supporting a variety of callable objects and being type-safe; 3. Template generic methods are the most flexible, suitable for library code or general logic, but may increase the compilation time and code volume. Lambdas that capture the context must be passed through std::function or template and cannot be converted directly into function pointers.

What is a null pointer in C  ? What is a null pointer in C ? Jul 09, 2025 am 02:38 AM

AnullpointerinC isaspecialvalueindicatingthatapointerdoesnotpointtoanyvalidmemorylocation,anditisusedtosafelymanageandcheckpointersbeforedereferencing.1.BeforeC 11,0orNULLwasused,butnownullptrispreferredforclarityandtypesafety.2.Usingnullpointershe

See all articles
腿上的肉疼是什么原因 鼻窦炎是什么 狗毛对人体有什么危害 眼睛痒什么原因 吃力不讨好是什么意思
什么油适合高温油炸 前白蛋白是什么意思 备孕期间不能吃什么 怀孕前三个月为什么不能告诉别人 手上有湿疹是什么原因引起的
ufc是什么意思 黄瓜籽粉有什么作用 四妙丸有什么功效与作用 为什么会长花斑癣 快递什么时候上班
肿瘤和囊肿有什么区别 不是你撞的为什么要扶 柠檬有什么功效 起痱子是什么原因 1994年是什么命
气短吃什么药效果好hcv8jop7ns3r.cn 人夫是什么意思mmeoe.com 什么情况需要根管治疗hcv9jop5ns6r.cn 九月是什么星座hcv8jop6ns0r.cn 曜字五行属什么hcv7jop7ns2r.cn
心悸是什么感觉bjcbxg.com 为什么医院不推荐钡餐检查hcv9jop7ns3r.cn 糖尿病患者主食应该吃什么hcv8jop3ns5r.cn 劲旅是什么意思hcv8jop3ns2r.cn 缺铁性贫血吃什么药最好hcv9jop1ns6r.cn
卵巢囊肿有什么症状hcv8jop6ns6r.cn 茄子炒什么好吃hcv8jop5ns3r.cn 六月二十八是什么日子hcv7jop7ns4r.cn 什么米最贵hcv8jop1ns7r.cn y3是什么牌子hcv9jop4ns6r.cn
风湿性心脏病是什么原因引起的kuyehao.com 金银花有什么功效hcv9jop2ns0r.cn 海怪是什么海鲜hcv8jop7ns9r.cn 什么是假性狐臭hcv9jop0ns3r.cn 梦见出血是什么征兆hcv8jop6ns8r.cn
百度