Comment by Peter - Reinstate Monica on C# loop — break vs. continue
@MichaelStum See Apple's SSL bug. Btw -- that blog post, ironically, concludes that the missing braces were not the main problem, if at all.
View ArticleComment by Peter - Reinstate Monica on C# loop — break vs. continue
You might add just why some people don't like them: At their core, they are jumps, i.e., gotos in disguise, with all the problems that come with gotos. The problems are somewhat restricted because the...
View ArticleAnswer by Peter - Reinstate Monica for Why does "int *find(const vector&vec,...
Well, the idea is that not only is the vector constant but the standard library designers figured that the most reasonable semantics for a constant vector object is that its data is treated as constant...
View ArticleComment by Peter - Reinstate Monica on Seeking an explanation for the change...
@Charlieface One thing that comes to mind is performance. The double computation may be more costly. I don't know whether there are implementations without floating point hardware out there but on such...
View ArticleComment by Peter - Reinstate Monica on Declaring multiple sequential...
Why don't you show us how you want to use the variables you define? You mention that you are thinking of a loop; an array is the proper data structure for loops, single variables are, by contrast, not....
View ArticleComment by Peter - Reinstate Monica on Why double pointer has a type
You are almost right ;-). On "typical" implementations, pointers to data types have the same size; alas, there is no guarantee. Originally, in early C, pointers were indeed basically treated as...
View ArticleComment by Peter - Reinstate Monica on Why double pointer has a type
I suppose the OP refers to the double in double* when they ask "why does a pointer have a type". And of course you can have void pointers which have "no type" in that sense, and you can of course...
View ArticleComment by Peter - Reinstate Monica on Command to open file with git
What's the advantage of defining a throw-away function as opposed to directly issuing the command?
View ArticleComment by Peter - Reinstate Monica on How can i convert IEnumerable into...
@Magnus Exactly. For a set of "properties" (in the general sense, i.e., data) of the same type -- here: string -- it makes more sense to have a dictionary indexed with a suitable enum. This makes loops...
View ArticleComment by Peter - Reinstate Monica on What's the difference between "C...
@interjay It is a (large) superset of the standard library, but the section 2 is explicitly system dependent.
View ArticleComment by Peter - Reinstate Monica on Difference between "if constexpr()" Vs...
@ReinstateMonica3167040 Well, this states the rules but not the reason: The compiler "knows" perfectly well which branch will be executed, constexpr or not, and could hence compile it perfectly...
View ArticleComment by Peter - Reinstate Monica on How do I successfully test this...
A different but easier take would be to have an array of function pointers plus a function pointer to f() next to each other in memory, e.g. as local variables in main. Fill the array with pointers to...
View ArticleComment by Peter - Reinstate Monica on How do I successfully test this...
All you say is so true it is actually a truism. It is clear to all but the greenest neophytes and is actually the basis for this assignment. Additionally, while the standard which describes all...
View ArticleComment by Peter - Reinstate Monica on C inserting multiple strings into...
On the other hand, the positions of the placements stay constant if you start replacing from the back. That may be interesting if you are indeed given an array of positions.
View ArticleComment by Peter - Reinstate Monica on How to make shared pointer from raw...
Interesting that the standard basically has a solution tailored to the OP's problem. Apparently, others have had similar problems.
View ArticleComment by Peter - Reinstate Monica on c++ typewriter effect delay issues?
From the Microsoft documentation on Sleep(): "Use caution when calling timeBeginPeriod, as frequent calls can significantly affect the system clock, system power usage, and the scheduler. If you call...
View ArticleComment by Peter - Reinstate Monica on Copy Assignment Operator with...
while data_ptr is (presumably) a pointer to a (single) int, that int is actually the first element in an array. You need to allocate the entire array with data_ptr = new int[v.capacity]; and then...
View ArticleComment by Peter - Reinstate Monica on Static C++ check for pure virtual...
@PepijnKramer Don't you have a this ptr in the constructor?
View ArticleComment by Peter - Reinstate Monica on Can a std::vector of std::shared_ptr...
The actual quoted error concerns the type conversion which is impossible with private inheritance, not the missing default ctor. As an aside, the error message is quite bad in my opinion (also in...
View ArticleComment by Peter - Reinstate Monica on How do I make good, tasty brownies...
Please go to cooking.stackexchange.com for cooking questions. Also, try to write concisely and avoid language that's too casual. Also, do prior research: What keeps you from reading and following any...
View Article