Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #119854
| From | Andrey Tarasevich <andreytarasevich@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: General Preference in C++ |
| Date | 2024-08-20 20:07 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <va3llv$3nijk$1@dont-email.me> (permalink) |
| References | <va3fk7$ui68$1@paganini.bofh.team> |
On 08/20/24 6:30 PM, Jack wrote: > > constexpr size_t N = 12; > #define N 12 > > constexpr is modern way of doing things but in terms of efficiency what > is the best way to do? > There's no difference in efficiency. One can probably come up with a few reasons to prefer a macro for this purpose, like 1. Compatibility with C in cross-compiled header files 2. Ability to use a named constant in subsequent preprocessor directives (e.g. `#if`) 3. Probably something else... But these reasons are focused rather narrowly of some niche applications. When you _have_ a choice, there's no reason to avoid `constexpr`. -- Best regards, Andry
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
General Preference in C++ Jack <noreply@mandrill.com> - 2024-08-21 01:30 +0000
Re: General Preference in C++ Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-20 18:53 -0700
Re: General Preference in C++ Chris Ahlstrom <OFeem1987@teleworm.us> - 2024-08-22 13:18 -0400
Re: General Preference in C++ scott@slp53.sl.home (Scott Lurndal) - 2024-08-22 17:54 +0000
Re: General Preference in C++ Bonita Montero <Bonita.Montero@gmail.com> - 2024-08-22 20:08 +0200
Re: General Preference in C++ David Brown <david.brown@hesbynett.no> - 2024-08-23 09:08 +0200
Re: General Preference in C++ Chris Ahlstrom <OFeem1987@teleworm.us> - 2024-08-23 09:41 -0400
Re: General Preference in C++ Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-08-20 20:07 -0700
Re: General Preference in C++ David Brown <david.brown@hesbynett.no> - 2024-08-21 09:07 +0200
Re: General Preference in C++ Bonita Montero <Bonita.Montero@gmail.com> - 2024-08-22 11:33 +0200
csiph-web