c++boostcastingboost-lambda

Using static_cast in boost::lambda


I need to use boost::lambda for some conversion.

I've tried this:

static_cast<size_t>(boost::lambda::_1 * 60 * 1000)

But I've got error:

error C2440: 'static_cast' : cannot convert from 'const boost::lambda::lambda_functor' to 'size_t'

How to put this conversion inside of lambda?


Solution

  • You can use boost::phoenix::static_cast_ instead (and I suggest using Phoenix for lambda expressions in general, assuming you're using c++03).

    http://www.boost.org/doc/libs/1_57_0/boost/phoenix/object/static_cast.hpp