GCC 15 में C++ की नई सुविधाएँ
(developers.redhat.com)- GCC 15 ने बड़ी संख्या में C++26 फीचर्स जोड़े हैं, और कुछ C++23 फीचर्स में भी सुधार किया है
- प्रमुख नई सुविधाओं में Pack Indexing, Variadic Friends, हटाने का कारण बताना, structural binding conditionals आदि शामिल हैं
- नए compiler options और warnings भी जोड़े गए हैं, जिससे developer experience बेहतर हुआ है
- C++ modules सपोर्ट को मजबूत किया गया है, और template compilation speed का optimization किया गया है
- GCC 15 को Fedora 42 के default compiler के रूप में अपनाया गया है, और जल्द ही Red Hat GCC Toolset में भी उपलब्ध कराया जाएगा
GCC 15 में C++ की नई सुविधाएँ
- GCC 15.1 को 25 अप्रैल 2025 को जारी किया गया, और इसमें C++26 फीचर्स को गंभीरता से शामिल किया गया है
- डिफ़ॉल्ट standard अभी भी
gnu++17है, जबकि-std=c++23,-std=c++26आदि के ज़रिए नए फीचर्स सक्षम किए जा सकते हैं - C++20, C++23, C++26 फीचर्स अभी भी experimental हैं
C++26 की प्रमुख सुविधाएँ
-
Pack Indexing
- Variadic Template arguments में किसी खास element को
pack...[N]syntax से सीधे access किया जा सकता है - बार-बार के tricks के बिना पहले argument आदि को साफ़ तरीके से refer किया जा सकता है
- Variadic Template arguments में किसी खास element को
-
Structured Bindings में attributes देना
- structured binding से बने हर variable पर अलग-अलग
[[attribute]]लागू किया जा सकता है - उदाहरण के लिए, किसी खास binding variable को ही
[[deprecated]]किया जा सकता है
- structured binding से बने हर variable पर अलग-अलग
-
deleted function में विवरण जोड़ना
= delete("कारण")syntax के ज़रिए deleted function call error में message दिया जा सकता है
-
Variadic Friends
- template class में कई types को एक साथ
friendघोषित किया जा सकता है - Passkey pattern की तरह access control को मजबूत करने में उपयोगी है
- template class में कई types को एक साथ
-
constexpr Placement New
std::allocatorऔर placement new को constexpr context में इस्तेमाल किया जा सकता है
-
conditionals में structured binding का उपयोग
if,while,switchconditionals के भीतर structured binding declaration संभव है- condition evaluation compiler द्वारा बनाए गए internal variable के आधार पर होता है
-
incomplete type को delete करने पर रोक
- अगर
deleteयाdelete[]का उपयोग incomplete type पर किया जाता है, तो C++26 mode में compile error होगा
- अगर
-
Oxford comma warning
- Variadic function declaration में
, ...के बिना सिर्फ...उपयोग करने के pattern पर C++26 में warning दी जाएगी
- Variadic function declaration में
-
array comparison हटाया गया
- arrays के बीच
==comparison वाले code को error माना जाएगा - पहले C++20 में यह warning थी, लेकिन अब C++26 mode में इसे compile error बना दिया गया है
- arrays के बीच
-
#embed directive
- binary data को source code में सीधे शामिल करने के लिए
#embedका समर्थन
- binary data को source code में सीधे शामिल करने के लिए
अभी कोई टिप्पणी नहीं है.