Why does `std::string::find()` not return the end iterator on failures?

To begin with, the std::string interface is well known to be bloated and inconsistent, see Herb Sutter’s Gotw84 on this topic. But nevertheless, there is a reasoning behind std::string::find returning an index: std::string::substr. This convenience member function operates on indices, e.g. const std::string src = “https://stackoverflow.com/questions/58430288/abcdefghijk”; std::cout << src.substr(2, 5) << “\n”; You could implement … Read more

How similar are Boost.Filesystem and the C++ standard filesystem library?

There are a number of differences. Some were, I believe, Boost changes that were never propagated. For example, there is no path.filename_is_dot() query (as discussed below, it would be less useful in std::filesystem anyway). There was also a good bit of late-breaking news on this front: Support for non-POSIX-like filesystems: Specify whether a string is … Read more

Why does pow(n,2) return 24 when n=5, with my compiler and OS?

Here is what may be happening here. You should be able to confirm this by looking at your compiler’s implementation of the pow function: Assuming you have the correct #include’s, (all the previous answers and comments about this are correct — don’t take the #include files for granted), the prototype for the standard pow function … Read more

Should reading negative into unsigned fail via std::cin (gcc, clang disagree)?

I think that both are wrong in C++171 and that the expected output should be: 4294967295 0 While the returned value is correct for the latest versions of both compilers, I think that the ios_­base​::​failbit should be set, but I also think there is a confusion about the notion of field to be converted in … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)