Code Vault
From codegorilla
Here I will show some of the code and tips I have done in my past to act as a place to share information and to remind me when I forget things as well.
Contents |
Code
- C++ Bits Library - using boost (1.36) to produce a combined compile and runtime bit library that I developed when implementing the STUN2 draft protocol.
- C++ Variant Factory - using boost (1.36) to create a generic class factory based on the variant type.
- C++ Asio Repeating Timer - using boost (1.36) to extend the Asio timer functionality to provide a safe deterministic repeating timer. Something similar may now be in boost but it wasn't last time I looked in 1.36.
Small Problems Solved
- The not any type - preventing a type from being stored in a boost::any type.
- Specializing for array types - technique for overload/specialiation of functions based on if they are arrays or not.
Reminders
Tips
- First tip for anyone developing in C++ on windows (I hope you are using Visual Studio) is to invest in a Whole Tomato license
- If your using C++, you should really be using or at least know of its existence the boost libraries
- If you know of boost, you must have used boost::shared_ptr, which is great - but don't forget about boost::weak_ptr which is even better. I only found out about this a few years after using shared_ptr and I regret not knowing of it sooner - can solve a lot of problems on lifetime and ownership issues.
- If you think what you are doing is new and unique, spend a bit of time surfing the internet just to make sure - best not reinvent the wheel unless you have to.
- When writing any software remember the programmers dozen - a pdf of Kevlin Henneys presentaion is available online [1]
- For those times when you need to write a regex - then regexpal provides simple online testing, and for more posix stuff then larsolavtorvik is for you.
- Have a read up on Inversion of Control(IoC) (aka Dependency Injection(DI)) on wikipedia, and then check out PocoCapsule
- Are you a member of the ACCU? If not then seriously consider it, for just a small charge (£35 last time I looked) you get sent some great magazines (Overload and C Vu) which cover many languages and many techniqes. You also support a great organisation consisting of some of the best Software engineers in the business.
- Using Visual Studio for development and debugging? Then this place has hints and tips on the lesser known features.
- Magic numbers in memory - sometime finding the exact meaning of those numbers the debug versions put in memory can be tricky, luckily wikipedia has some(all?) listed. Some more specific examples for Win32 CRT
Useful (or Useless) bits of information
- Those warning which are turned off by default in MSVC - useful if you are going down the road of turning on the highest warning level and treating all warnings as errors.
