- +1 - 2 Updates
- "Use Stronger Types!" - 15 Updates
- Change in default or value initialization from C++11 to C++14 - 4 Updates
- Undefined symbol : typeinfo for eckit::Exception - 1 Update
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Nov 04 10:14PM Replying to a Usenet post with just: +1 or: -1 is almost as annoying as replying to a Usenet post with just: +0 Usenet isn't Stack Overflow so stop wasting bandwidth. /Flibble |
Real Troll <real.troll@trolls.com>: Nov 04 06:30PM -0400 On 04/11/2016 22:14, Mr Flibble wrote: > +0 > Usenet isn't Stack Overflow so stop wasting bandwidth. > /Flibble Did you get the permission from Rick Hodgin to post this? Why did you not mention Jesus Christ in your post? |
Lynn McGuire <lynnmcguire5@gmail.com>: Nov 03 06:33PM -0500 "Use Stronger Types!" http://arne-mertz.de/2016/11/stronger-types/ Lynn |
woodbrian77@gmail.com: Nov 03 08:04PM -0700 On Thursday, November 3, 2016 at 6:34:07 PM UTC-5, Lynn McGuire wrote: > "Use Stronger Types!" > http://arne-mertz.de/2016/11/stronger-types/ > Lynn Jorgen Grahn has been saying something similar here in the past. |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Nov 04 02:30PM On 03/11/2016 23:33, Lynn McGuire wrote: > "Use Stronger Types!" > http://arne-mertz.de/2016/11/stronger-types/ Wrapping the fundamental types with a unique domain specific wrapper class is pure craziness; better would be a more generic constrained template wrapper that is then typedef'd with a domain specific name: template <typename IntegerType, IntegerType MinimumValue, IntegerType MaximumValue> class constrained_integer { public: constrained_integer(IntegerType aValue) : iValue(aValue) { /* throw if out of range. */ } public: /* accessor/mutator methods */ private: IntegerType iValue; }; typedef constrained_integer<unsigned int, 0u, 150u> age; int main() { age oldCodger = 64u; } I believe there is a proper strong typedef proposal for C++ which we might get soon that would also be useful. /Flibble |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Nov 04 02:48PM On 04/11/2016 14:30, Mr Flibble wrote: > } > I believe there is a proper strong typedef proposal for C++ which we > might get soon that would also be useful. If you want to prevent two unrelated "strong types" with the same constraints and value_type from being assigned to each other then simply add a strong type tag: template <typename StrongType, typename IntegerType, IntegerType MinimumValue, IntegerType MaximumValue> class constrained_integer { public: constrained_integer(IntegerType aValue) : iValue(aValue) { /* throw if out of range. */ } public: /* accessor/mutator methods */ private: IntegerType iValue; }; struct age_tag {}; struct order_qty_tag {}; typedef constrained_integer<age_tag, unsigned int, 0u, 150u> age; typedef constrained_integer<order_qty_tag, unsigned int, 0u, 150u> order_qty; /Flibble |
woodbrian77@gmail.com: Nov 04 08:10AM -0700 On Friday, November 4, 2016 at 9:48:41 AM UTC-5, Mr Flibble wrote: > typedef constrained_integer<order_qty_tag, unsigned int, 0u, 150u> > order_qty; > /Flibble I'm somewhat persuaded by Jon Kalb's advice to not use unsigned for quantities: https://www.youtube.com/watch?v=wvtFGa6XJDU . Brian Ebenezer Enterprises - A tale of two turkeys -- Hillary and Trump. Please pray for the USA. http://webEbenezer.net |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Nov 04 03:22PM >> /Flibble > I'm somewhat persuaded by Jon Kalb's advice to not use > unsigned for quantities: If this "Jon Kalb" bloke advises that then this "Job Kalb" bloke doesn't know what he is talking about and you are wrong to follow his advice. And no I didn't watch the video nor do I intend to. /Flibble |
jacobnavia <jacob@jacob.remcomp.fr>: Nov 04 04:53PM +0100 Le 04/11/2016 à 16:22, Mr Flibble a écrit : > know what he is talking about and you are wrong to follow his advice. > And no I didn't watch the video nor do I intend to. > /Flibble int a = 1; unsigned b = -1; if (b < a) printf("OK¡n"); else printf("????¡n"); This is the problem he is talking about. What do you say to this problem? Of course you say there is no problem, isn't it? |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Nov 04 03:58PM On 04/11/2016 15:53, jacobnavia wrote: > This is the problem he is talking about. > What do you say to this problem? > Of course you say there is no problem, isn't it? What I say to that problem is that you shouldn't compare signed and unsigned values. /Flibble |
woodbrian77@gmail.com: Nov 04 09:16AM -0700 On Friday, November 4, 2016 at 10:53:23 AM UTC-5, jacobnavia wrote: > > /Flibble > int a = 1; > unsigned b = -1; I don't think you reproduced that right. In the video it's signed int a{-1}; unsigned int b{1}; |
scott@slp53.sl.home (Scott Lurndal): Nov 04 04:51PM >> /Flibble >int a = 1; >unsigned b = -1; WTF? If you want -1, use signed. or 'unsigned b = ~0' if you want all ones. >if (b < a) Every compiler I use will generate an error on this. (with -Werror, which we use on all our code, otherwise the compiler will generate a nice warning.) Use the appropriate type for the job. If a function returns size_t, use size_t. If it returns a size and an error indication (-1), use ssize_t. If you need an unsigned value, use an unsigned type. If you must mix signed and unsigned, use signed. |
Lynn McGuire <lynnmcguire5@gmail.com>: Nov 04 01:26PM -0500 > Ebenezer Enterprises - A tale of two turkeys -- Hillary and > Trump. Please pray for the USA. > http://webEbenezer.net I do not like unsigned. Just seems unnatural to me. Lynn |
red floyd <dont.bother@its.invalid>: Nov 04 11:41AM -0700 On 11/4/2016 11:26 AM, Lynn McGuire wrote: > I do not like unsigned. Just seems unnatural to me. It makes a little more sense when defined as in Modula-2. The type name in that language is CARDINAL. It's natural when you think of it as counting stuff... |
Daniel <danielaparker@gmail.com>: Nov 04 01:51PM -0700 On Friday, November 4, 2016 at 2:27:13 PM UTC-4, Lynn McGuire wrote: > I do not like unsigned. Just seems unnatural to me. Kind of like the undead. Daniel |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Nov 04 08:59PM On Fri, 04 Nov 2016 16:51:31 GMT > >unsigned b = -1; > WTF? If you want -1, use signed. > or 'unsigned b = ~0' if you want all ones. 'unsigned b = -1' is the correct form if you want all bits set on an unsigned integer value. It is guaranteed to set all bits irrespective of the signed representation and the size of the integer: see §4.7/2 of C++11/14. 'unsigned b = ~0' will fail to set all bits on non-2's complement systems (on a 1's complement system it will have the same effect as 'unsigned b = -0' which results in no bits set after the implicit cast to unsigned has been completed). |
Lynn McGuire <lynnmcguire5@gmail.com>: Nov 04 05:02PM -0500 On 11/4/2016 3:51 PM, Daniel wrote: >> I do not like unsigned. Just seems unnatural to me. > Kind of like the undead. > Daniel +1 Lynn |
Tom Allebrandi <wyrles@ytram.com>: Nov 04 12:48AM -0700 -1 to me for mispelling Flibble |
Tom Allebrandi <wyrles@ytram.com>: Nov 04 12:44AM -0700 +1 for Brian's comment about not using vulgar language. -1 for Fibble's use of vulgar language. Note that downvoting is (probably) OK with Fibble since s/he only complained about upvoting. --- tom |
red floyd <dont.bother@its.invalid>: Nov 04 09:18AM -0700 Get the fuck off of your high horse already. |
Lynn McGuire <lynnmcguire5@gmail.com>: Nov 04 01:28PM -0500 On 11/4/2016 2:48 AM, Tom Allebrandi wrote: > -1 to me for mispelling Flibble +1 Lynn |
Jerry <jerryleo@gmail.com>: Nov 04 02:11AM -0700 On Wednesday, October 19, 2016 at 9:27:51 PM UTC+8, Paavo Helde wrote: > > } > > }; > > </code> Paavo, Thanks for your kindly inputs. '-Wl,-no-undefined' did give a lot help to find all missing stuff, and help to fix the issue. Appreciating your time Regards Jerry |
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