• [^] # Re: Clay

    Posté par . En réponse au journal Clay Style Sheet. Évalué à 2.

    Juste pour préciser, depuis C++ > 11 seul l'ordre est obligatoire pour l'initialisation des designated initializers.

    struct foo_type {
     int a = 1;
     int b;
     int c = 1;
     int* ptr = nullptr;
     ~foo_type()
     {
     delete ptr;
     }
    };
    int main()
    {
     auto foo_1 = foo_type{
     .b = 1,
     .ptr = new int(1)
     };
     auto foo_2 = foo_type{
     .a = 1,
     .b = 1,
     .c = 1,
     };
     auto foo_3 = foo_type{
     .a = 1,
     .c = 1,
     // .b = 1, Error
     };
    }