mercredi 30 octobre 2019

What is the correct way to call this method?

I'm trying to understand placeholders but i can't call this method. I have an implicit parameters Dummy{}, float and LastDummy{}. When i call function i skip these parameters. Also my call doesn't work.

struct AnotherDummy {};
struct YetAnotherDummy {};
struct LastDummy {};

class X { public:
    void foo(std::string one, Dummy two, int three, AnotherDummy four, 
             float five, YetAnotherDummy six, double seven, int eight, LastDummy nine)
    {

    }
};

int main()
{
    using namespace std::placeholders;

    auto functor = std::bind(&X::foo, _6, _3, Dummy{}, _5, _1, 5.0f, _4, _2, _7, LastDummy{});

    X obj;
    functor(&obj, YetAnotherDummy{}, 1, 2.3f, 'x', AnotherDummy{}, Dummy{}, 2.3);

    return 0;
}

Aucun commentaire:

Enregistrer un commentaire