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 ?

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s