TCLAP for command line argument parsing in C++

A long while ago I was looking for a way to handle command line arguments in a C++ program I was writing for Windows. At the time I only found Boost.Program_options. After a bit of experimenting I found that the pre-built Boost libs I found back then had some issues and after a bit of …

Continue reading ‘TCLAP for command line argument parsing in C++’ »

Share

Venting on C++

Lately I’ve used C++ for a tool I’ve been working on at the office. Here are some idiosyncrasies in the standard library that I’ve noticed: I was expecting the following code to compile: std::string f(“hello.txt”); std::ifstream in_file(f); But oh no! For some reason ifstream doesn’t have a constructor that accepts a standard C++ string. Instead …

Continue reading ‘Venting on C++’ »

Share

Having fun with C++’s auto_ptr

Sometimes RAII is difficult. The following code compiles without errors or warnings on Windows using Visual Studio 2005: #include <iostream> #include <memory> namespace Test { class Foo { public: bool should_do_stuff() { return false; } }; class Bar { public: Bar(std::auto_ptr<Foo> fp) : _fp(fp) {} void do_stuff() { if(_fp->should_do_stuff()) std::cout << “Do stuff” << std::endl; …

Continue reading ‘Having fun with C++’s auto_ptr’ »

Share