-
C++ Empty Class and Function
More than 10 years ago, when I first debugged my Boost code, I stepped into empty class and empty function. At that time, I was wondering what empty class and function devoid of any code is good for. In this tip, I am going to use a simple endian swap example to demostrate the use […]
-
C++23: Mutable string_view
In the upcoming C++23, the mutable string_view proposal is under review for inclusion in the next Standard Library. As we all know the current immutable string_view has two members, a const pointer to a constant char array and a constant length whereas in the mutable sibling, both members are modifiable. Let me illustrate with a […]
-
Deleaker Review
What keeps a C++ developer awake at night? A nagging question at the back of his subconsciousness is “Does my application have a memory leak?”. Continual memory leaks can be detrimental to long-running programs and eventually, the system runs out of memory and is stopped in its operation. Detection and elimination of memory leak should […]
-
Visual C++ 6.0 Developer’s Reference
Came across this picture of Visual C++ 6.0 Developer’s Reference(1998) posted by raddevus. I had a C++ Master Reference published in 1999. It has 1500 pages of C++ language and library reference! I had perhaps only read one page(about atoi()). It is like a predecessor of Cppreference except it is printed on book and is […]
-
Running VC++ Executable on User Machine Without its DLLs
Since this question is asked on CodeProject today, I’ll answer it here. To deploy without having to install the Visual C++ DLLs, the program has to be linked statically. Linking to C runtime statically: Right-click on your project in the Solution Explorer and select Properties and go to C/C++ -> Code Generation. Select Multithreaded (/MT) […]
-
Floating-Point Article Win January Prize
My floating-point article won the best article prize for the articles posted in month of January 2020. The prize is a priceless CodeProject mug(above picture) which is just delivered to my house. The impetus to writing this article started with a rule enshrined in the company wiki that “all multiplications must be converted to divisions […]
-
Copy-On-Write Base Class Template
This tip presents a really simple Copy-On-Write(COW) class template (to be used as a base class) to ease developer effort to implement COW class. Copy-On-Write as its name implies, is a technique to duplicate(copy) shared resource upon write: the only exception to this write operation is when there is only one existing copy and not […]
-
Optimization Turns Out to Be Pessimization!
Benchmark is hosted at Github I have doing this optimization in my hobby OpenGL projects for years. My only sin is I did not measure their performance. I just assumed the one with less operation must be the faster one. Whenever a programmer wants to do get a fractional value of a maximum integer value, […]
-
C++17: codecvt_utf8 is deprecated
Last week, I got this compilation error after upgrading my Visual C++ project to C++17 for using codecvt_utf8 to convert UTF-8 string back and fro wchar_t string. error C4996: ‘std::codecvt_utf8<wchar_t,1114111,0>’: warning STL4017: std::wbuffer_convert, std::wstring_convert, and the <codecvt> header (containing std::codecvt_mode, std::codecvt_utf8, std::codecvt_utf16, and std::codecvt_utf8_utf16) are deprecated in C++17. (The std::codecvt class template is NOT deprecated.) […]
-
Real Case of Premature Micro-Optimization
The benchmark is hosted at Github I discovered a real case of premature micro-optimization when you don’t measure. You know it is pretty bad when you read premature and micro on the same sentence. On the page 44 of Optimizing C++ ebook by Agner Fog, it is written … In some cases it is possible […]