vendredi 29 juin 2018

How can I fix this error "the value of 'x1' is not usable in a constant expression" ? static_assert

Given the following code ( only for the example) :

    int x1 = 4;
    int x2 = 5;
    static_assert(x1 != x2 ,"Error");

I get the following error:

the value of 'x1' is not usable in a constant expression

How can I fix it ?


Note: I looking for a way to fix it without change the definitions of the variables in this way:

const int x1 = 4;
const int x2 = 5;

But, I want to fix it only by change the the line of static_assert(..)

Aucun commentaire:

Enregistrer un commentaire