vendredi 3 avril 2015

C++ static constexpr field with incomplete type

I'm trying to compile this code, but g++ complains about ZERO having an incomplete type. Does this mean that in C++ a struct cannot contain a static constexpr instance of itself? If so, why?



struct Cursor
{
size_t row,column;

static constexpr Cursor ZERO {0,0};
//error: constexpr const Cursor Cursor::ZERO has incomplete type
};


EDIT: I understand that Cursor cannot have a complete type when I declare ZERO. What I'd like to know is: it there any way I can have ZERO belonging to Cursor and still being constexpr?


Aucun commentaire:

Enregistrer un commentaire