public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "joseph.h.garvin at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/52032] New: Function and class attributes should optionally take a bool parameter enabling them Date: Sat, 28 Jan 2012 23:46:00 -0000 [thread overview] Message-ID: <bug-52032-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52032 Bug #: 52032 Summary: Function and class attributes should optionally take a bool parameter enabling them Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: joseph.h.garvin@gmail.com Summary: Attributes like packed, always_inline, etc. should support taking a bool to enable them, similar to how 'noexcept' works in C++11. Details: In C++11, one can add the 'noexcept' specifier on to a function to indicate that it doesn't throw exceptions, e.g.: void foo() noexcept { // ... } However, to assist with template metaprogramming, noexcept can take compile time constant bool to switch whether it's in effect: struct MyCallback { }; template<class CallbackT> void foo() noexcept(!CallbackT::ThrowsExceptions) { CallbackT::action(); } It would reduce redundant code if GCC let you do this in general for its attributes. For example, currently if you want both a packed and unpacked version of a struct, you are forced to either define the struct twice or generate both versions with a macro. Ideally you could do this: template<bool should_pack=false> struct __attribute__((__packed__(should_pack))) MyStruct { // ... members } typedef MyStruct<true> PackedMyStruct; This functionality could be useful for pretty much all of GCC's attributes.
next reply other threads:[~2012-01-28 23:17 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-01-28 23:46 joseph.h.garvin at gmail dot com [this message] 2012-01-30 10:06 ` [Bug c++/52032] " rguenth at gcc dot gnu.org 2012-01-30 13:43 ` joseph.h.garvin at gmail dot com 2012-01-30 13:47 ` rguenth at gcc dot gnu.org 2012-01-30 21:39 ` joseph.h.garvin at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-52032-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).