lundi 3 août 2015

Struct initialization of derived struct with a templated base type

I am trying to use struct initialization on a derived from template struct. The code goes something like this:

template <class Derived>
struct Event{
protected:
    Event() = default;
};

struct MoveEvent: Event<MoveEvent>{
    int x, y;
};


int main(){
    //how do I make this work?
  //MoveEvent event = {.x =5, .y = 4};
}

I thought it might have something to do with CTRP, but changing Event<MoveEvent> to Event<int> yields the same problem. Furthermore, I thought it was an issue with POD, but std::is_pod returns true for MoveEvent. So what's the problem here? Why can't I use struct initialization?

Aucun commentaire:

Enregistrer un commentaire