Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #119853
| Path | csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
| Newsgroups | comp.lang.c++ |
| Subject | Re: General Preference in C++ |
| Date | Tue, 20 Aug 2024 18:53:28 -0700 |
| Organization | None to speak of |
| Lines | 27 |
| Message-ID | <87v7zubq07.fsf@nosuchdomain.example.com> (permalink) |
| References | <va3fk7$ui68$1@paganini.bofh.team> |
| MIME-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Date | Wed, 21 Aug 2024 03:53:28 +0200 (CEST) |
| Injection-Info | dont-email.me; posting-host="7a2cb821a5a9c1554a17483648fb73a0"; logging-data="3900798"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ka45hAJfC348CcXApuuoV" |
| User-Agent | Gnus/5.13 (Gnus v5.13) |
| Cancel-Lock | sha1:iEInsqmyy6PPviQmwvV6hSx5K/4= sha1:jf9YyhbsPPvwNk8ROY2fIxZVY98= |
| Xref | csiph.com comp.lang.c++:119853 |
Show key headers only | View raw
Jack <noreply@mandrill.com> writes:
> Do you guys have any preference in C++ to use something like this:
>
> constexpr size_t N = 12;
> #define N 12
The first N is of type size_t. The second is of type int (the type of
the literal 12).
> constexpr is modern way of doing things but in terms of efficiency what
> is the best way to do?
There is unlikely to be any difference in efficiency.
> You can then define an array like so:
>
> double numbers[N] {0};
>
> I wonder if you guys have anything to say about this.
I believe the general consensus (and my own preference) is to use core
language features rather than macros unless there's a very good reason
to use a macro.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
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