samedi 4 juin 2016

what about bind and reference in c++11

why this code compiled in c++11 the it2 and it4 is correct. but it1 and it3 is compiled error with non-static function? is it bug with std compiler? or i understand the wrong about these?

#include <iostream>
#include <functional>
using namespace std;
namespace test {
    class a {
        public:
            void funa() {}
    };

    class b : public a {
        public:
            void funb() { }
    };
    struct c {
        void func() {}
    };
}
int main()
{
    test::b b1;
    test::c c1;
    auto it1 = std::bind(&(test::c::func),&c1);
    auto it2 = std::bind(&test::c::func,&c1);
    auto it3 = std::bind(&test::a::funa, &b1);
    auto it4 = std::bind(&(test::a::funa),&b1);
}

Aucun commentaire:

Enregistrer un commentaire