Private aggregate initialization

Viewed 275

Is it possible to define as private the aggregate initialization for an aggregate class? I would like that the class can only be aggregate-initialized by its own static private members.

Example:

struct Size
{
    const unsigned int width;
    const unsigned int height;

    static const Size big;
    static const Size small;

private:

    Size( ) = default;

    // something to declare the aggregare initialization as private
};

const Size Size::big = { 480, 240 };
const Size Size::small = { 210, 170 };
0 Answers
Related