4h
comment why is operator-> implemented by operator* in C++ STL library?
@Ulrich: I was referring to your first sentence. InputIterator requirements are that i->m is valid and equivalent to (*i).m: nothing about i.operator->() being valid (and even that guarantee is only if i is dereferenceable). i->m will be undefined behavior if cur is null; it just happens after the call to operator->() rather than during.
4h
comment why is operator-> implemented by operator* in C++ STL library?
@Ulrich: Huh. It never crossed my mind that operator-> can be called outside of the context of member access (which would promptly trigger UB). Technically, I think doing so is undefined behavior anyways, since that's not on the list of expressions guaranteed to be meaningful for any of the iterator concepts.
4h
comment why is operator-> implemented by operator* in C++ STL library?
@Stiles: And I've seen enough cases where methods get out of sync in the real world. People aren't perfect. We can at least not go out of our way to make our jobs harder.
4h
comment why is operator-> implemented by operator* in C++ STL library?
(also, nothing inlining during debug mode is an issue of the quality of your compiler)
4h
comment why is operator-> implemented by operator* in C++ STL library?
@StilesCrisis: For your research, the general principle here is called "Don't Repeat Yourself" (DRY).
5h
comment How does the existence of a limit imply that a function is uniformly continuous
@Jubbles: $[0, +\infty]$ is not a subset of $\mathbb{R}$, so the characterization of compact subsets of $\mathbb{R}$ doesn't apply.
23h
awarded Critic
23h
answered C++ array of vectors of pointers initialization
1d
comment How can I get my character immunity to compulsion effects?
Aren't there control undead-type spells?
1d
comment What does "context" in "context-free grammar" refer to?
In more detail, this answer talks about an unrestricted grammar, whereas @MSalters points out that context sensitive grammar would make for a better example of the meaning of context.
1d
comment Is this Tetris puzzle solvable?
As an aside, just because it's a puzzle doesn't mean it has a solution; the 15 puzzle, for example, had a popularized unsolvable configuration.
1d
comment thrust::raw_pointer_cast and multiple GPU, weird behaviour
Are they still similar looking address, though? My next best guess is that the problem is that both vectors are located at "reasonable" addresses, so the wrong pointer is still pointing to a valid memory address and so you're just corrupting random memory. But passing in the uninitialized pointer gives a totally unreasonable memory address.
1d
comment thrust::raw_pointer_cast and multiple GPU, weird behaviour
Print the data pointers of both device_vectors, not just the first one.
1d
revised How to floor a number using the NTL library (C++)
deleted 3 characters in body
1d
comment How to floor a number using the NTL library (C++)
Incidentally, even if you had arbitrary precision floating point available, the pure integer version is still probably the better way to do the calculation.
1d
comment How to floor a number using the NTL library (C++)
.. specifically, the header comments x = floor(a^{1/2}) (a >= 0)
1d
answered How to floor a number using the NTL library (C++)
1d
comment Python: create list of random integers where state space is limted
@Cleb: Since you know how long the list is, I think I would first initialize the list to the correct size (e.g. mylist = [0] * x) and then overwrite its entries with random values, rather than build the list by appending to it. I expect this to perform better if x is large, as it would avoid reallocations. (of course, this whole issue is obviated if you use the generator-based approach)
1d
comment Python: create list of random integers where state space is limted
@hgwells: That's not an issue here: ignore is not being modified or returned or anything like that.
1d
answered c++ templates - (type deduction compile time error)
1 2 3 4 5