Soviet_Mario <SovietMario@CCCP.MIR>: Oct 23 05:39PM +0200 Il 21/10/19 16:34, Öö Tiib ha scritto: > (whose implementation is expecting allocators to meet requirements > to allocators that your example violates) instead of simply having > something like static std::array<uint8_t, 4096>? intresting example, which I would have misunderstood in most context I mean : I would have considered the class object (array instance) itself to be static, but not (or not necessarily) its content, which, if I'm not wrong again, does not (necessarily) dwell inside the object Instead it seems that the STATIC prefix makes the whole object, both "helper" members and the main content (the DATA) static as well. Why so ? I mean : the static clause is transitive and "propagates" recursively to non-embedded sub-objects ? It would be a handy feature, but I did not know it existed -- 1) Resistere, resistere, resistere. 2) Se tutti pagano le tasse, le tasse le pagano tutti Soviet_Mario - (aka Gatto_Vizzato) |
Keith Thompson <kst-u@mib.org>: Oct 23 03:15PM -0700 Soviet_Mario <SovietMario@CCCP.MIR> writes: [...] > I mean : the static clause is transitive and "propagates" > recursively to non-embedded sub-objects ? > It would be a handy feature, but I did not know it existed For a std::vector or std::string, for example, the contained data is not part of the object itself. std::array is a bit unusual in that the array elements *are* part of the std::array object, which means that the elements will have the same storage duration as the std::array object itself. (That's why the number of elements in a std::array has to be known at compile time.) A std::array object is essentially a structure with an array as its only member. You can see this by printing the value of `sizeof a`, where `a` is a std::array object. For a vector, the size is going to be a fixed value (which will vary depending on the implementation, and *maybe*, but probably not, on the element type). -- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */ |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Oct 24 12:19AM +0100 On 23/10/2019 23:15, Keith Thompson wrote: > means that the elements will have the same storage duration as the > std::array object itself. (That's why the number of elements in > a std::array has to be known at compile time.) Wrong. std::string usually employs the "small string optimization" whereby small strings are allocated within the object itself. I have also created a "vecarray" container that does a similar thing for vectors. /Flibble -- "Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin "You won't burn in hell. But be nice anyway." – Ricky Gervais "I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Bryne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
Paavo Helde <myfirstname@osa.pri.ee>: Oct 23 05:13PM +0300 On 23.10.2019 16:47, Bonita Montero wrote: >> That's why in all STL algorithms the iterator type is a template >> parameter. > And this helps a function to accept all the three above types? They are function templates, not functions. Of course they do support all those three types, and more. That's a major feature of STL. int array[] = {1,3,2,4}; std::sort(std::begin(array), std::end(array)); // or: std::sort(array, array+sizeof(array)/sizeof(array[0])); etc... |
Bonita Montero <Bonita.Montero@gmail.com>: Oct 23 04:26PM +0200 > They are function templates, not functions. Of course they do support > all those three types, and more. That's a major feature of STL. For the discussed case that's all simply syntactic sugar. |
Christian Gollwitzer <auriocus@gmx.de>: Oct 23 05:29PM +0200 Am 23.10.19 um 15:48 schrieb Bonita Montero: >> void f(iterator start, iterator end); >> will work for any pair of iterators, *including* your pointers. > Of course, but for the above three types this pure syntactic sugar. so? |
James Kuyper <jameskuyper@alumni.caltech.edu>: Oct 23 01:18PM -0400 On 10/23/19 3:14 AM, Frederick Gotham wrote: > On Tuesday, October 22, 2019 at 4:10:35 PM UTC+1, Keith Thompson wrote: ... >>> in the first place. >> That's called trolling. Please don't do that. > No it's not. It would be trolling if I was doing something wrong and then trying to make the wrong thing look more grotesque. The defining characteristic of trolling is saying something for the purpose of provoking a reaction. Which is precisely the reason you gave for doing this. It's derived from the word "troll" as it is used in fishing, with the provocation corresponding to the bait, and the reaction that you've provoked corresponding to a fish taking the bait. It really doesn't matter whether the bait is "wrong" or "right" in any absolute sense, only that people will react to it. |
Keith Thompson <kst-u@mib.org>: Oct 23 02:48PM -0700 Frederick Gotham <cauldwell.thomas@gmail.com> writes: [...] > hours, but that's far less harmful than what you've been doing for a > few years (including your personal email follow-up's). > With that said, I don't think you realise what you're doing. I'll reply to this by email. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */ |
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