samedi 1 juillet 2017

chained std::bind compile error with VS2015

I'm using VS2015 and I'm playing with std::function and std::bind I found a strange errors.

I have a 2 chained bind operation:

int main()
{


    auto func1 = [](int i) -> int {
        return i + 1;
    };

    auto func2 = [](float f, function<int(int)>&& func) -> float {
        return f + func(f);
    };


    auto func2_instance = std::bind(func2, std::placeholders::_1, func1);

    cout << func2_instance(0.2) << endl;

    auto func3 = [](double d, function<float(float)>&& func)->double {
        return d + func(d);
    };
   //doesn't work
auto func3_instance = std::bind(func3, std::placeholders::_1, std::move(func2_instance));
  //works
auto func3_instance = std::bind(func3, std::placeholders::_1, [funcmv = std::move(func2_instance)](float a)->float{
        return funcmv(a);
    });

    func3_instance(0.2);


}

the error I got is related to line func3_instance(0.2)

D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits(1468): error C2893: Failed to specialize function template 'unknown-type std::invoke(_Callable &&,_Types &&...)'

Could you please help? What I miss related to std::bind?

Merci in advance.

Aucun commentaire:

Enregistrer un commentaire