@DevSolar Well, the more legible version is ~30% shorter, lacks a cast and is otherwise equivalent. My question therefore stands: "What's the point of making it a oneliner?" — sehe1 min ago
I liked the conversation between Alexandrescu and Herb in the last C++ and Beyond video: Alexandrescu: "Why isn't make_unique in the standard?" Herb: "It's an oversight." Alexandrescu: "A big one.."
Actually it just takes a little practice. You should create a list of 100 bit manipulation exercises ordered by increasing difficulty. If you'd do that then you'll do better than most of us here.
Overlearning is a pedagogical concept according to which newly acquired skills should be practiced well beyond the point of initial mastery, leading to automaticity. Once one has overlearned a task, one's skill level is higher than the challenge level for that task (see Control region in the graph).
The Yerkes–Dodson law predicts that overlearning can improve performance in states of high arousal.
Rohrer et al. define overlearning as “the immediate continuation of practice beyond the criterion of one perfect instance." Past research has referred to overlearning as an effective means of mo...
This FAQ is about Aggregates and PODs and covers the following material:
What are Aggregates?
What are PODs (Plain Old Data)?
How are they related?
How and why are they special?
What changes for C++11?
@EtiennedeMartel Also use static assert with is_pod and also static assert to check if the pod size is what you expect it to be. (AFAIK POD can still have padding.)
@TonyTheLion private inheritance is a part of C++ language. Maybe composition is better than this - but it is just easier to use. — PiotrNycz26 secs ago
@R.MartinhoFernandes I read this answer from David Rodriguez recently about how you can use C-style casts to get around private inheritance. Never tried it myself though
@kbok Unless you have some use for scalar_results other than to act as a base for results, it's polluting the global namespace without accomplishing anything. If, however, it was (for example) in the anonymous namespace in the implementation file, it wouldn't be quite so bad. Problem is that to use results elsewhere, the definition of scalar_results also has to be visible.
@TonyTheLion As I noted once previously, once you look closely you see that "extension" is really entirely the wrong word -- it has the same distinction between "reference types" and "value types" as C#, which makes it a different sort of language entirely, not just an extension.
@Ell If you keep C compatibility, you're stuck with at least a whole lot of the same problems as C++. If you don't care about C compatibility, you might as well start from an entirely different base.
@R.MartinhoFernandes Even C binary compatibility (unless you do some sort of automatic-wrapping) seems like a problem -- e.g., to support calling C functions that take raw pointers, you need some way to create raw pointers.
@kbok I think it would probably have been best to state that up-front. Without the reasoning stated, it doesn't look terrible, but still seems a bit warped for no good reason.
@R.MartinhoFernandes: I noticed your comment on that question about Platform::String, that it's immutable. I'm not too familiar with C++/CX, do you know, is this documentation for String::Begin an error? It says it returns a pointer to non-const char16. How does that work, if it's immutable?
Platform::String::Data() will return a wchar_t const* pointing to the contents of the string (similar to std::wstring::c_str()). Platform::String represents an immutable string, so there's no accessor to get a wchar_t*. You'll need to copy its contents, e.g. into a std::wstring, to make changes...
@JamesMcNellis If String is immutable, why does String::Begin return a char16 * and not a char16 const*? Is it legal to modify an individual character using this pointer? — Prætorian26 secs ago
@TonyTheLion Bottom line: When they invented std::string, they thought of it in isolation, like strings were unique unto themselves. I think it's safe to say that the current view is that most of the uniqueness of string is a mistake, and it's generally better to view it as a container, not much different from other containers. My own view: it's often reasonable to use std::vector<char> instead.
@R.MartinhoFernandes Close, but one other detail: std::string is really only intended to be instantiated over types that are exception free -- e.g., assigning them can never throw. std::vector is designed to be sane in the face of exceptions where std::string assumes they can't happen.
@Prætorian: The documentation is wrong. Begin() and End() both return char16 const*. You can see their definitions in <vccorlib.h>. You may not modify the pointed-to characters (strings are reference counted, and if there are other owners and you modify the string, those other owners will be very surprised to discover that their string has changed). I'll see what I can do to get the documentation fixed. Thanks for the heads-up. — James McNellis4 mins ago
Is the below function definition is legal
T& GetMax(const T& t1, const T& t2)
{
....
}
It is written that :
"At the return statements, compiler would complain that t1 or t2 cannot be converted to non-const."
Does it mean that it is illegal ,if not what else? Could you provide exa...