Victor A. Wagner, Jr. wrote:
> I finally had a chance to go back and look at an attempt to use lambda in
> one of my commercial endeavors. It turns out that I was getting "ambiguous
> _1" with my compiler (VC.net2003) between lambda and bind.
Boost.lambda places _1 in the boost::lambda namespace.
Boost.bind places _1 in the global namespace. This is fine
so long as you avoid using directives and are careful with
using declarations.
As soon as you have a using directive for the boost::lambda
namespace, boost::lambda::_1 will be injected into the
global namespace -- even if the using directive is at block
scope -- and any use of _1 will be ambiguous.
If you have translation units that use both Boost.bind and
Boost.lambda, the safest advice is (i) avoid all using
directives for namespace boost::lambda; (ii) put using
declarations at block scope. For example,
int main()
{
boost::function< int (int, int) > times;
{
using boost::lambda::_1;
using boost::lambda::_2;
times = _1 * _2;
}
boost::function< int (int) > square
( boost::bind( times, _1, _1 ) );
std::cout << times(10,20) << std::endl;
std::cout << square(9) << std::endl;
}
--
Richard Smith
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost