(A case for) Creating a stack-allocated Stack container in C++I've always looked inside the C++ STL and wondered why the library provided stack container is not allocated on the stack section but is actually allocated on the heap. A container which is allocated on stack would be handy in embedded systems where ...Oct 6, 2023 · 3 min readblog.srikanth.one
Swapping the position of the two words in a string represented by a singly linked listRecently I've been giving interviews as my last contract got completed. In one of the interviews, I was asked to write a data structure for a string using a singly linked list. The constraint was that the string would have exactly two words separated...Sep 23, 2023 · 6 min readblog.srikanth.one
Converting any class into a Singleton class in C++Singleton is one of the creational design patterns. A singleton class has only one instance and provides a global point of access to that instance. It's commonly used when you want to restrict the instantiation of a class to a single object, which ca...Aug 31, 2023 · 4 min readblog.srikanth.one
A tutorial for accessing C/C++ functions within a shared library (.dll/.so/.dylib) from Rust[19-09-2023] Updates: Add instructions and code for an alternative way to build and run using build.rs and cmake-rs Fix the reason why not to link to C++ functions directly Include <cstring> in the code and use free instead of delete as strdup gen...Dec 4, 2022 · 7 min readblog.srikanth.one
Correctly rotating an image to an arbitrary angle in OpenCVIntroduction Have you ever tried to rotate an image in OpenCV? It's damn simple, right? You include the OpenCV headers:#include <cmath> #include <iostream> #include <algorithm> #include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> #include <ope...Sep 10, 2022 · 3 min readblog.srikanth.one