Why is does this not work (Visual C++ 2012 Update 1), and what is the proper way to fix it?
#include <boost/lambda/bind.hpp>
namespace bll = boost::lambda;
struct Adder
{
int m;
Adder(int m = 0) : m(m) { }
int foo(int n) const { return m + n; }
};
#define bindm(obj, f, ...) bind(&decltype(obj)::f, obj, __VA_ARGS__)
int main()
{
return bll::bindm(Adder(5), foo, bll::_1)(5);
}
decltype
as a nested-name-specifier was added into C++11 at a relatively late stage; n3049 as the resolution to DR 743 (and DR 950). n3049 was published in March 2010, which is probably why it hasn't found its way into VC++ yet.
The workaround is to use the identity typefunction:
template<typename T> using id = T;
id<decltype(expression)>::member;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With