Disapproved responses are removed

What's wrong with cplusplus.com?


This may not be a perfectly apt forum for that question, but let me try, at the risk of being dragged away.

There are several references for the C ++ standard library, including the invaluable ISO standard, MSDN, IBM, cppreference, and cplusplus. Personally, when I write C ++ I need a reference with fast random access, short load times, and usage examples, and I found cplusplus.com to be quite useful. However, I've heard negative opinions about this website many times here on SO, so that's exactly what I want to go into:

What are the mistakes, misunderstandings or bad advice from cplusplus.com? What are the risks in using it to make coding decisions?

Let me add this point: I want to be able to answer questions here on SO with exact quotation marks of the standard and so I want to post links that can be used right away and cplusplus.com would have been my preferred website if it hadn't been for it this problem.






Reply:


Edit: The Documentation for has been fixed since this answer was written. Same goes for.

Let me give you an example to show you how cpluscplus.com can go wrong.

Consider the function of.

The fact is that the item is not removed from the container. Its because only working with a pair of iterators and knowing nothing about the containers which the elements actually contain. In fact, it is not possible to know the underlying container because it is impossible to tell from two iterators which container the iterators belong to. So you don't really remove the individual parts, simply because it can't . The only way to get an item indeed Removing from a container is to call a member function on that container.

So if you want to remove the elements, use Erase-Remove Idiom:

But there wrong Information about . It says

Note that this function ends the elements after the new does not change , the retain their old values and are still accessible .

that is not right. The iterator in the scope is still dereferencable, but that does NOT mean they are the old values ​​are retained and still accessible. They are not specified.


Similarly there is also wrong Information about . It says:

Note that a global algorithm function, remove, is present with a similar behavior, however, it works between two iterators.

that is completely wrong. Namely, global removal is not similar since we saw that the former is the elements Not really removed from the container, because it can't while the latter (the membership function) is the elements really removed , because it can .

This answer has been copied from my other answer in the following topic with few changes:

Note: Since I came across this recently while replying to the above topic, I remember it. There are many mistakes that I have encountered over the past two years that I don't remember. I could add a few more later when I get back over.







I'm going to take a slightly contrary opinion. There is a lot of good information on cplusplus.com. Choose it to death, and yes of course it has its problems, but which website doesn't? Certainly not this page . People who live in glass houses shouldn't throw stones. There is a lot of misinformation here too. There are accepted answers that are absolutely wrong, disparaged answers (some negative!) That are just right.

One problem with cplusplus.com is that it is a closed site. The same applies to most of the other reference pages mentioned. This contradicts a community developed site like Stack Overflow. It doesn't take long to acquire the ability to make trustworthy changes, and even the newest newbies can easily suggest improvements. Compare that with cplusplus.com. You are a never-ending newbie when you are not on their staff. Even if you are a key member of WG21, if you encounter an error anywhere on this site, you will need to go through the email reporting mechanism. Anathema!

One solution for us at this site would be to develop our own C ++ reference. This would take quite a bit of work. We would have to be careful that we are not too pedantic / too technical. It is evident that cplusplus.com employs at least some technical writers keeping the pedants at bay. We should keep the information well organized; The FAQ here are not well organized. We would also have to be very careful not to splash too much straight out of the standard; this is illegal







http://www.cplusplus.com/reference/clibrary/cstring/strncpy/

Doesn't mention that "If the copying is between overlapping objects, the behavior is undefined." (4.11.2.4 in the C89 standard. I don't have a copy of C90 on hand, which C ++ 03 actually refers to, but they're only supposed to differ in things like pagination.)






The documentation provided by cplusplus.com is often incorrect or incomplete.

As soon as there is such an example, the documentation is on cplusplus.com.

atoi
In the Return section, the return value 0 is not mentioned if no conversion can be performed while the function is being used.

The Return section of cplusplus.com reads: "... If the converted value is outside the range of representable values ​​due to an int, this leads to undefined behavior."

This is according to the standard " If the numeric value of the string cannot be represented in int, the behavior is undefined "correct.

However, the section is not full because 0 is not specified as a return value, which can be misleading. The sentence "... no conversion is performed and zero is returned." is previously met in the description paragraph, but it is important that it is in the section " Back "is included.

Many of the sample source codes listed on cplusplus.com are incorrect.
Many of the newbies who look up to these references lead to Ballant errors.

To give an example:

EDIT: The example I quoted earlier was wrong.







The documentation for tried to explain first but fails:

typeid can be applied directly to types. In this case it returns its information. Or objects. In this case, information about the object type is returned.

When typeid is applied to a dereferenced pointer to an object of a polymorphic class type (a class that declares or inherits a virtual function), it takes into account its dynamic type (that is, the type of the most derived object).

Now the second paragraph no longer matches the first. In, is applied to an expression. This is pretty important as the term and types only make sense in the context of the phrase, not in the context of objects. There are also missing cases like.

In addition, references are omitted in the second paragraph. They too can have static types that are different from the dynamic type of the object they reference.



The documentation of says that both elements are checked for equality. The documentation of says that the second elements are only taken into account if the first elements are the same.

In both cases the word "same" appears. But only in the first case does it really mean. In the second case means equal



We use cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content and targeted ads, to analyze our website traffic, and to understand where our visitors are coming from.

By continuing, you consent to our use of cookies and other tracking technologies and affirm you're at least 16 years old or have consent from a parent or guardian.

You can read details in our Cookie policy and Privacy policy.