briarpig

May 30, 2008

A little off topic, but it’s worth noting that the author of the treedragon and erys sites is back with briarpig, and lots on hardcore C++ performance engineering. Which, come to think of it, is highly relevant to etrading.

boost::cref

May 21, 2008

I’m continuing to discover the wonder of boost. Yesterday it was boost::lexical_cast(), a very neat way to do those peskly int to string conversions. Today, it’s boost::cref(). Why did I need it ?  I’m using boost::bind() to marshall parameters for dispatch across a thread boundary. All well and good til one of the parameters inherited from boost::noncopyable. Wrap the noncopyable in a boost::cref() invocation, and all is well again.

Apparently, boost::cref converts the reference to a pointer under the covers. Ironic, non ?

I wanted to use std::replace_if( ) to substitute spaces for the tilde symbol (~) in a string. The STL docs give an example that uses std::bind2nd. MS has a similar example in their knowledge base. This is what I came up with to do the job using boost::bind

std::string rep("one~two");
std::replace_if( rep.begin( ), rep.end( ), boost::bind( std::equal_to<char>( ), _1, '~'), ' ');

Effective Boost

May 1, 2008

I’ve long been a fan of Scott Meyer‘s Effective C++, More Effective C++ and Effective STL series of books. I have a 1992 first edition of Effective C++ on my desk that’s been very well thumbed. Today I asked a colleague who’s a heavy hitting C++ expert for Boost book recommendation. He suggested Karlsson’s book, which looks OK. But we really need Scott to write a book on Boost. Bring it on please Scott !!