- T const - 5 Updates
"Christian Hanné" <the.hanne@gmail.com>: Nov 07 10:06AM +0100 East const is the only logigal way to attach constness. That's while constness to a pointer is also attached right to the *. |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Nov 07 04:16PM +0100 > http://slashslash.info/2018/02/a-foolish-consistency/ > https://www.reddit.com/r/cpp/comments/80k8hc/a_blog_rant_on_east_const/ > I'm glad Jon is speaking up about this. To support consistent left `const` simply define template< class T > using Type_ = T; Now you can write e.g. const Type_<const char*> s = "Aha"; But that's a construed example; in practice I'd instead write that specific example as const auto& s = "Aha"; ... which is shorter and preserves the string length information. - Alf |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Nov 07 08:41PM On 07/11/2020 15:16, Alf P. Steinbach wrote: > But that's a construed example; in practice I'd instead write that specific example as > const auto& s = "Aha"; > ... which is shorter and preserves the string length information. Alf, pack this fucking nonsense in, pls. /Flibble -- ¬ |
Brian Wood <woodbrian77@gmail.com>: Nov 07 01:53PM -0800 On Saturday, November 7, 2020 at 9:17:07 AM UTC-6, Alf P. Steinbach wrote: > > I'm glad Jon is speaking up about this. > To support consistent left `const` simply define > template< class T > using Type_ = T; What's the quote about there not being bugs in the line you didn't write? But would: template< class T > using Type_ = T const; be helfpul? > Now you can write e.g. > const Type_<const char*> s = "Aha"; Brian Ebenezer Enterprises - Enjoying programming again. https://github.com/Ebenezer-group/onwards |
Brian Wood <woodbrian77@gmail.com>: Nov 07 02:00PM -0800 On Saturday, November 7, 2020 at 3:53:45 PM UTC-6, Brian Wood wrote: > But would: > template< class T > using Type_ = T const; > be helfpul? Not sure, but maybe the answer is no. I think you would get: char * const rather than: char const* . |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment