samedi 9 juin 2018

Do bitwise operations of constexpr result in constexpr?

I defined a few constants in a way showed below

constexpr int a = 1;
constexpr int b = 2;

My question is whether all arithmetic and bitwise operations that only use a and b will be considered as constexpr by the compiler?

For example, I'm wondering whether compiler is guaranteed to calculate the expression for c compile time? If not, is there a way to ask for compile time calculations?

c = (a + b) & (a | b);

Aucun commentaire:

Enregistrer un commentaire