A warning – comparison between signed and unsigned integer expressions

It is usually a good idea to declare variables as unsigned or size_t if they will be compared to sizes, to avoid this issue. Whenever possible, use the exact type you will be comparing against (for example, use std::string::size_type when comparing with a std::string‘s length). Compilers give warnings about comparing signed and unsigned types because the ranges of signed and unsigned ints … Read more

libstdc++-6.dll not found

If you are using MingW to compile C++ code on Windows, you may like to add the options -static-libgcc and -static-libstdc++ to link the C and C++ standard libraries statically and thus remove the need to carry around any separate copies of those. Version management of libraries is a pain in Windows, so I’ve found this approach the quickest … Read more

How to trim a std::string?

EDIT Since c++17, some parts of the standard library were removed. Fortunately, starting with c++11, we have lambdas which are a superior solution. Thanks to https://stackoverflow.com/a/44973498/524503 for bringing up the modern solution. Original answer: I tend to use one of these 3 for my trimming needs: They are fairly self-explanatory and work very well. EDIT: BTW, I have std::ptr_fun in … Read more

Thread pooling in C++11

This is copied from my answer to another very similar post: Start with maximum number of threads the system can support:int num_threads = std::thread::hardware_concurrency(); For an efficient threadpool implementation, once threads are created according to num_threads, it’s better not to create new ones, or destroy old ones (by joining). There will be a performance penalty, an … Read more

Understanding “corrupted size vs. prev_size” glibc error

OK, so I’ve managed to overcome this issue. First of all – A practical cause to “corrupted size vs. prev_size” is quite simple – memory chunk control structure fields in the adjacent following chunk are being overwritten due to out-of-bounds access by the code. if you allocate x bytes for pointer p but wind up writing beyond x in regards to … Read more

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