For testing or even applications which need to run a bunch of things at the same time, kicking off multiple threads at the same time is really nice. For instance, … Continue Reading How can I easily create several threads in C++?
/* Sometimes we need to construct several classes and then pass them somewhere to do something, but we don’t have an abstract storage method. The unique_ptr can help */ // … Continue Reading Creating a Vector with Class Storage using C++11 smart_pointers
I see so many people confused about the use of “std::endl” versus “\n”, so here I explain when they should be used… std::endl The use of std::endl will insert an … Continue Reading In C++ when should I use std::endl versus “\n”?
In C++11 the regex library was added which allows you to do regex directly: #include <string> #include <regex> … std::string workingOn(“this text string\n”); std::regex expressionStart(“^th”); std::string removed = std::regex_replace(workingOn, expressionStart,””); … Continue Reading In C++ how do I use regex to replace a string match
In a C++ implementation file I normally use: // *.cxx #include <mutex> namespace { std::mutex g_lock; } // anonymous namespace void MyClass::myThreadSafeMethod() { g_lock.lock(); // do something that is not … Continue Reading In C++, how do I create and use mutex?