mardi 29 mars 2016

static const vs constexpr member fields in C++11/14?

What is the difference between these member variables:

struct my_class {
    static const int i = 0;
    static constexpr int j = 0;
    constexpr int k = 0;
};

If my understanding is correct, i am able to use both i and j as compile time constants.
eg. something like std::array<int, my_class::i> or std::array<int,my_class::j> both should work.

Aucun commentaire:

Enregistrer un commentaire