lundi 21 mars 2022

function call operator in class or method?

class foo
{
public:
    struct bar
    {
        bar() {}
        int bar_var;
    };

    operator std::vector<bar>() {
        return m_list;
    }

private:
    std::vector<bar> m_list;
    int foo_var;
};

Here defined a class foo, what is the semantic "operator std:vector<bar>()" mean here? I don't think it is an overloaded function call operator.

Compile with the above code works OK

Aucun commentaire:

Enregistrer un commentaire