lundi 18 juillet 2022

Does calling a member variable of constexpr struct omits a whole constructor evaluation?

Let's say I have the following structure:

struct MyData {
    int minSteps{1};
    int maxSteps{64};
    double volume{0.25/7};
};

constexpr MyData data()
{
    return MyData();
}

Does any of expressions below make an instance of the MyData structure constructed somewhere before the value is assigned?

int steps = data().minSteps;
const int maxSteps = data().maxSteps;
constexpr double volume = data().volume;

Aucun commentaire:

Enregistrer un commentaire