jeudi 7 janvier 2021

No operator '&' matches these operands [closed]

I have this structure:

struct Token {
        enum class Type { 
            Array         = 1 << 0, 
            Colon         = 1 << 1, 
            Comma         = 1 << 2, 
            WhiteSpace    = 1 << 3, 
            String        = 1 << 4, 
            Undefined     = 1 << 5, 
            None          = 1 << 6, 
            Integer       = 1 << 7, 
            Double        = 1 << 8, 
            Boolean       = 1 << 9,
            Constructable = Array|String|None|Integer|Double|Boolean 
        };

        Token(std::string s, Type t) : str(s), type(t) {};
        Token() : str(""), type(Type::Undefined) {};

        std::string str;
        Type type;
    };

And the std::vector:

std::vector<Token> tokens;

And when I try to do this:

if ( tokens[i].type & Token::Type::Constructable);

I get this message from Visual Studio 2019:

No operator '&' matches these operands. operand types are: Token::Type & Token::Type

And this one from vs compiler:

binary '&': 'bnn::`anonymous-namespace'::Token::Type' does not define this operator or a conversion to a type acceptable to the predefined operator

Aucun commentaire:

Enregistrer un commentaire