std::string in union...



  • struct Blub
    {
    int x;
    union
    {
    int y;
    int z;
    std::string A;
    };
    };

    Warum geht das nicht? Irgendwas mit Kopierkonstruktor...



  • der standard sagt was über typen, die in einer Union sein dürfen:

    9.5 schrieb:

    An object of a class with a non-trivial constructor , a non-trivial copy constructor , a non-trivial destructor, or a non-trivial copy assignment operator cannot be a member of a union, nor can an array of such objects.

    Und das erfüllt der String nunmal nicht.


Anmelden zum Antworten