Why is std::is_aggregate an aggregate? Unicorn Meta Zoo #1: Why another podcast? ...

Why is arima in R one time step off?

Processing ADC conversion result: DMA vs Processor Registers

Is it accepted to use working hours to read general interest books?

Married in secret, can marital status in passport be changed at a later date?

What *exactly* is electrical current, voltage, and resistance?

How was Lagrange appointed professor of mathematics so early?

Stretch a Tikz tree

Bright yellow or light yellow?

What's the difference between using dependency injection with a container and using a service locator?

Why does Java have support for time zone offsets with seconds precision?

Is Bran literally the world's memory?

Will I be more secure with my own router behind my ISP's router?

What to do with someone that cheated their way though university and a PhD program?

How to translate "red flag" into Spanish?

My admission is revoked after accepting the admission offer

Does using the Inspiration rules for character defects encourage My Guy Syndrome?

TV series episode where humans nuke aliens before decrypting their message that states they come in peace

Putting Ant-Man on house arrest

What's called a person who works as someone who puts products on shelves in stores?

Israeli soda type drink

Does a Draconic Bloodline sorcerer's doubled proficiency bonus for Charisma checks against dragons apply to all dragon types or only the chosen one?

false 'Security alert' from Google - every login generates mails from 'no-reply@accounts.google.com'

When speaking, how do you change your mind mid-sentence?

Is it OK if I do not take the receipt in Germany?



Why is std::is_aggregate an aggregate?



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!What are Aggregates and PODs and how/why are they special?std::wstring VS std::stringWhy can templates only be implemented in the header file?How to find out if an item is present in a std::vector?Why is “using namespace std” considered bad practice?What are Aggregates and PODs and how/why are they special?Why are elementwise additions much faster in separate loops than in a combined loop?Why is reading lines from stdin much slower in C++ than Python?Why is it faster to process a sorted array than an unsorted array?Why should I use a pointer rather than the object itself?Is it permissible for standard library implementation to have class definition that is different from the C++ standard?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







7















I always was under the impression that types like std::is_same, std::is_void, or std::is_aggregate are supposed to inherit from std::integral_constant, or more specifically from std::bool_constant.



However, aggregate classes must not have a base class by definition, but when I use these types as T in std::is_aggregate_v<T>, I get true. So apparently, they are not derived from std::bool_constant?



So my question is:



Why is std::is_aggregate_v<std::is_aggregate<void>> true, at least with GCC and Clang? Doesn't the standard specify that std::is_aggregate is derived from std::bool_constant? If not, does this mean it leaves the value of the above line as an implementation detail?










share|improve this question




















  • 2





    en.cppreference.com/w/cpp/language/aggregate_initialization Non-virtual public base classes are allowed in C++17

    – KABoissonneault
    14 hours ago






  • 1





    Scroll down on the page you linked; read the whole page ;)

    – Lightness Races in Orbit
    14 hours ago











  • Yeah, didn't realize that the linked text continues over multiple answers ;)

    – x432ph
    14 hours ago






  • 1





    @x432ph It's usually a good idea to read all (or at least most) answers on a page; there's a reason we have a one-to-many Q&A model!

    – Lightness Races in Orbit
    14 hours ago


















7















I always was under the impression that types like std::is_same, std::is_void, or std::is_aggregate are supposed to inherit from std::integral_constant, or more specifically from std::bool_constant.



However, aggregate classes must not have a base class by definition, but when I use these types as T in std::is_aggregate_v<T>, I get true. So apparently, they are not derived from std::bool_constant?



So my question is:



Why is std::is_aggregate_v<std::is_aggregate<void>> true, at least with GCC and Clang? Doesn't the standard specify that std::is_aggregate is derived from std::bool_constant? If not, does this mean it leaves the value of the above line as an implementation detail?










share|improve this question




















  • 2





    en.cppreference.com/w/cpp/language/aggregate_initialization Non-virtual public base classes are allowed in C++17

    – KABoissonneault
    14 hours ago






  • 1





    Scroll down on the page you linked; read the whole page ;)

    – Lightness Races in Orbit
    14 hours ago











  • Yeah, didn't realize that the linked text continues over multiple answers ;)

    – x432ph
    14 hours ago






  • 1





    @x432ph It's usually a good idea to read all (or at least most) answers on a page; there's a reason we have a one-to-many Q&A model!

    – Lightness Races in Orbit
    14 hours ago














7












7








7








I always was under the impression that types like std::is_same, std::is_void, or std::is_aggregate are supposed to inherit from std::integral_constant, or more specifically from std::bool_constant.



However, aggregate classes must not have a base class by definition, but when I use these types as T in std::is_aggregate_v<T>, I get true. So apparently, they are not derived from std::bool_constant?



So my question is:



Why is std::is_aggregate_v<std::is_aggregate<void>> true, at least with GCC and Clang? Doesn't the standard specify that std::is_aggregate is derived from std::bool_constant? If not, does this mean it leaves the value of the above line as an implementation detail?










share|improve this question
















I always was under the impression that types like std::is_same, std::is_void, or std::is_aggregate are supposed to inherit from std::integral_constant, or more specifically from std::bool_constant.



However, aggregate classes must not have a base class by definition, but when I use these types as T in std::is_aggregate_v<T>, I get true. So apparently, they are not derived from std::bool_constant?



So my question is:



Why is std::is_aggregate_v<std::is_aggregate<void>> true, at least with GCC and Clang? Doesn't the standard specify that std::is_aggregate is derived from std::bool_constant? If not, does this mean it leaves the value of the above line as an implementation detail?







c++ std c++17 typetraits






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 14 hours ago









Lightness Races in Orbit

296k55480820




296k55480820










asked 14 hours ago









x432phx432ph

2145




2145








  • 2





    en.cppreference.com/w/cpp/language/aggregate_initialization Non-virtual public base classes are allowed in C++17

    – KABoissonneault
    14 hours ago






  • 1





    Scroll down on the page you linked; read the whole page ;)

    – Lightness Races in Orbit
    14 hours ago











  • Yeah, didn't realize that the linked text continues over multiple answers ;)

    – x432ph
    14 hours ago






  • 1





    @x432ph It's usually a good idea to read all (or at least most) answers on a page; there's a reason we have a one-to-many Q&A model!

    – Lightness Races in Orbit
    14 hours ago














  • 2





    en.cppreference.com/w/cpp/language/aggregate_initialization Non-virtual public base classes are allowed in C++17

    – KABoissonneault
    14 hours ago






  • 1





    Scroll down on the page you linked; read the whole page ;)

    – Lightness Races in Orbit
    14 hours ago











  • Yeah, didn't realize that the linked text continues over multiple answers ;)

    – x432ph
    14 hours ago






  • 1





    @x432ph It's usually a good idea to read all (or at least most) answers on a page; there's a reason we have a one-to-many Q&A model!

    – Lightness Races in Orbit
    14 hours ago








2




2





en.cppreference.com/w/cpp/language/aggregate_initialization Non-virtual public base classes are allowed in C++17

– KABoissonneault
14 hours ago





en.cppreference.com/w/cpp/language/aggregate_initialization Non-virtual public base classes are allowed in C++17

– KABoissonneault
14 hours ago




1




1





Scroll down on the page you linked; read the whole page ;)

– Lightness Races in Orbit
14 hours ago





Scroll down on the page you linked; read the whole page ;)

– Lightness Races in Orbit
14 hours ago













Yeah, didn't realize that the linked text continues over multiple answers ;)

– x432ph
14 hours ago





Yeah, didn't realize that the linked text continues over multiple answers ;)

– x432ph
14 hours ago




1




1





@x432ph It's usually a good idea to read all (or at least most) answers on a page; there's a reason we have a one-to-many Q&A model!

– Lightness Races in Orbit
14 hours ago





@x432ph It's usually a good idea to read all (or at least most) answers on a page; there's a reason we have a one-to-many Q&A model!

– Lightness Races in Orbit
14 hours ago












2 Answers
2






active

oldest

votes


















10















However, aggregate classes must not have a base class by definition




This is no longer true. [dcl.init.aggr]/1 defines an aggregate as




An aggregate is an array or a class with




  • no user-provided, explicit, or inherited constructors ([class.ctor]),


  • no private or protected non-static data members (Clause [class.access]),


  • no virtual functions, and


  • no virtual, private, or protected base classes ([class.mi]).



[ Note: Aggregate initialization does not allow accessing protected and private base class' members or constructors.  — end note ]




There is no longer a condition that it does not have a base class like it did in C++14 and earlier. As long as it has a public, non virtual base class that is now allowed. This means that the type traits are now considered aggregates as long as the above holds true for them






share|improve this answer





















  • 1





    And std::is_aggregate is new in C++17 so OP must be using it 👍

    – Lightness Races in Orbit
    14 hours ago











  • Pertinent link into the OP's source (they didn't read it all)

    – Lightness Races in Orbit
    14 hours ago











  • @LightnessRacesinOrbit Oh, cool. I was about to write a comment on the top answer to have it edited but if there is a C++17 specific answer I'll just add a link to it so its easier to see that changes have happened.

    – NathanOliver
    14 hours ago











  • Yep, there are answers for all standards published so far - OP over there should re-accept, ideally

    – Lightness Races in Orbit
    14 hours ago













  • @LightnessRacesinOrbit I've updated the main answer to point to them to make it more obvious.

    – NathanOliver
    14 hours ago



















3














Since C++17, classes with non-virtual, not private or protected bases are aggregates: https://en.cppreference.com/w/cpp/language/aggregate_initialization






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55813081%2fwhy-is-stdis-aggregatet-an-aggregate%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    10















    However, aggregate classes must not have a base class by definition




    This is no longer true. [dcl.init.aggr]/1 defines an aggregate as




    An aggregate is an array or a class with




    • no user-provided, explicit, or inherited constructors ([class.ctor]),


    • no private or protected non-static data members (Clause [class.access]),


    • no virtual functions, and


    • no virtual, private, or protected base classes ([class.mi]).



    [ Note: Aggregate initialization does not allow accessing protected and private base class' members or constructors.  — end note ]




    There is no longer a condition that it does not have a base class like it did in C++14 and earlier. As long as it has a public, non virtual base class that is now allowed. This means that the type traits are now considered aggregates as long as the above holds true for them






    share|improve this answer





















    • 1





      And std::is_aggregate is new in C++17 so OP must be using it 👍

      – Lightness Races in Orbit
      14 hours ago











    • Pertinent link into the OP's source (they didn't read it all)

      – Lightness Races in Orbit
      14 hours ago











    • @LightnessRacesinOrbit Oh, cool. I was about to write a comment on the top answer to have it edited but if there is a C++17 specific answer I'll just add a link to it so its easier to see that changes have happened.

      – NathanOliver
      14 hours ago











    • Yep, there are answers for all standards published so far - OP over there should re-accept, ideally

      – Lightness Races in Orbit
      14 hours ago













    • @LightnessRacesinOrbit I've updated the main answer to point to them to make it more obvious.

      – NathanOliver
      14 hours ago
















    10















    However, aggregate classes must not have a base class by definition




    This is no longer true. [dcl.init.aggr]/1 defines an aggregate as




    An aggregate is an array or a class with




    • no user-provided, explicit, or inherited constructors ([class.ctor]),


    • no private or protected non-static data members (Clause [class.access]),


    • no virtual functions, and


    • no virtual, private, or protected base classes ([class.mi]).



    [ Note: Aggregate initialization does not allow accessing protected and private base class' members or constructors.  — end note ]




    There is no longer a condition that it does not have a base class like it did in C++14 and earlier. As long as it has a public, non virtual base class that is now allowed. This means that the type traits are now considered aggregates as long as the above holds true for them






    share|improve this answer





















    • 1





      And std::is_aggregate is new in C++17 so OP must be using it 👍

      – Lightness Races in Orbit
      14 hours ago











    • Pertinent link into the OP's source (they didn't read it all)

      – Lightness Races in Orbit
      14 hours ago











    • @LightnessRacesinOrbit Oh, cool. I was about to write a comment on the top answer to have it edited but if there is a C++17 specific answer I'll just add a link to it so its easier to see that changes have happened.

      – NathanOliver
      14 hours ago











    • Yep, there are answers for all standards published so far - OP over there should re-accept, ideally

      – Lightness Races in Orbit
      14 hours ago













    • @LightnessRacesinOrbit I've updated the main answer to point to them to make it more obvious.

      – NathanOliver
      14 hours ago














    10












    10








    10








    However, aggregate classes must not have a base class by definition




    This is no longer true. [dcl.init.aggr]/1 defines an aggregate as




    An aggregate is an array or a class with




    • no user-provided, explicit, or inherited constructors ([class.ctor]),


    • no private or protected non-static data members (Clause [class.access]),


    • no virtual functions, and


    • no virtual, private, or protected base classes ([class.mi]).



    [ Note: Aggregate initialization does not allow accessing protected and private base class' members or constructors.  — end note ]




    There is no longer a condition that it does not have a base class like it did in C++14 and earlier. As long as it has a public, non virtual base class that is now allowed. This means that the type traits are now considered aggregates as long as the above holds true for them






    share|improve this answer
















    However, aggregate classes must not have a base class by definition




    This is no longer true. [dcl.init.aggr]/1 defines an aggregate as




    An aggregate is an array or a class with




    • no user-provided, explicit, or inherited constructors ([class.ctor]),


    • no private or protected non-static data members (Clause [class.access]),


    • no virtual functions, and


    • no virtual, private, or protected base classes ([class.mi]).



    [ Note: Aggregate initialization does not allow accessing protected and private base class' members or constructors.  — end note ]




    There is no longer a condition that it does not have a base class like it did in C++14 and earlier. As long as it has a public, non virtual base class that is now allowed. This means that the type traits are now considered aggregates as long as the above holds true for them







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 14 hours ago

























    answered 14 hours ago









    NathanOliverNathanOliver

    99.7k16139220




    99.7k16139220








    • 1





      And std::is_aggregate is new in C++17 so OP must be using it 👍

      – Lightness Races in Orbit
      14 hours ago











    • Pertinent link into the OP's source (they didn't read it all)

      – Lightness Races in Orbit
      14 hours ago











    • @LightnessRacesinOrbit Oh, cool. I was about to write a comment on the top answer to have it edited but if there is a C++17 specific answer I'll just add a link to it so its easier to see that changes have happened.

      – NathanOliver
      14 hours ago











    • Yep, there are answers for all standards published so far - OP over there should re-accept, ideally

      – Lightness Races in Orbit
      14 hours ago













    • @LightnessRacesinOrbit I've updated the main answer to point to them to make it more obvious.

      – NathanOliver
      14 hours ago














    • 1





      And std::is_aggregate is new in C++17 so OP must be using it 👍

      – Lightness Races in Orbit
      14 hours ago











    • Pertinent link into the OP's source (they didn't read it all)

      – Lightness Races in Orbit
      14 hours ago











    • @LightnessRacesinOrbit Oh, cool. I was about to write a comment on the top answer to have it edited but if there is a C++17 specific answer I'll just add a link to it so its easier to see that changes have happened.

      – NathanOliver
      14 hours ago











    • Yep, there are answers for all standards published so far - OP over there should re-accept, ideally

      – Lightness Races in Orbit
      14 hours ago













    • @LightnessRacesinOrbit I've updated the main answer to point to them to make it more obvious.

      – NathanOliver
      14 hours ago








    1




    1





    And std::is_aggregate is new in C++17 so OP must be using it 👍

    – Lightness Races in Orbit
    14 hours ago





    And std::is_aggregate is new in C++17 so OP must be using it 👍

    – Lightness Races in Orbit
    14 hours ago













    Pertinent link into the OP's source (they didn't read it all)

    – Lightness Races in Orbit
    14 hours ago





    Pertinent link into the OP's source (they didn't read it all)

    – Lightness Races in Orbit
    14 hours ago













    @LightnessRacesinOrbit Oh, cool. I was about to write a comment on the top answer to have it edited but if there is a C++17 specific answer I'll just add a link to it so its easier to see that changes have happened.

    – NathanOliver
    14 hours ago





    @LightnessRacesinOrbit Oh, cool. I was about to write a comment on the top answer to have it edited but if there is a C++17 specific answer I'll just add a link to it so its easier to see that changes have happened.

    – NathanOliver
    14 hours ago













    Yep, there are answers for all standards published so far - OP over there should re-accept, ideally

    – Lightness Races in Orbit
    14 hours ago







    Yep, there are answers for all standards published so far - OP over there should re-accept, ideally

    – Lightness Races in Orbit
    14 hours ago















    @LightnessRacesinOrbit I've updated the main answer to point to them to make it more obvious.

    – NathanOliver
    14 hours ago





    @LightnessRacesinOrbit I've updated the main answer to point to them to make it more obvious.

    – NathanOliver
    14 hours ago













    3














    Since C++17, classes with non-virtual, not private or protected bases are aggregates: https://en.cppreference.com/w/cpp/language/aggregate_initialization






    share|improve this answer




























      3














      Since C++17, classes with non-virtual, not private or protected bases are aggregates: https://en.cppreference.com/w/cpp/language/aggregate_initialization






      share|improve this answer


























        3












        3








        3







        Since C++17, classes with non-virtual, not private or protected bases are aggregates: https://en.cppreference.com/w/cpp/language/aggregate_initialization






        share|improve this answer













        Since C++17, classes with non-virtual, not private or protected bases are aggregates: https://en.cppreference.com/w/cpp/language/aggregate_initialization







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 14 hours ago









        SergeyASergeyA

        45.3k53990




        45.3k53990






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55813081%2fwhy-is-stdis-aggregatet-an-aggregate%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

            Tribunal Administrativo e Fiscal de Mirandela Referências Menu de...

            looking for continuous Screen Capture for retroactivly reproducing errors, timeback machineRolling desktop...