boost.lambda and std::abs(double)

Hi,
why does the following code not compile?
---8<---
#include <iostream>
#include

AMDG Olaf Peter wrote:
Hi,
why does the following code not compile?
---8<--- #include <iostream> #include
#include #include <algorithm> #include <cmath> int main() { using namespace ::boost::lambda;
const boost::array
factor = { 1e12, 1e9, 1e6, 1e3, 1, 1e-3, 1e-6, 1e-9, 1e-12, 1e-15 }; boost::array
values; std::transform( factor.begin(), factor.end(), values.begin(), std::abs( ret<double>( 1e3 / _1 ) ) );
} --->8---
std::abs is only overloaded for numeric types. A lambda function
is not a numeric type nor is it convertible to a numeric type. Thus,
there is no matching overload. There is no lazy version of std::abs
provided with lambda, so the easiest way is to use lambda::bind
#include <iostream>
#include
participants (2)
-
Olaf Peter
-
Steven Watanabe