0

I have a c++ class with const& members which are initialized in the initialization list of the constructor.

The order of the initialization of the members is crucial, for which I rely on the order of member declarations in the class declaration and the corresponding order in the initialization list.

Compiles fine without errors or warnings.

My question is: can I by some means, like static_assert or similar, assure, that nobody ever changes the order of either the declarations or the initialization list?

I know, that doing so would trigger a compiler warning, but there are people out there who just don't care about compiler warnings. So, is there a way to turn this into an error message... ?

frithjofh
  • 11
  • 2
  • Try to avoid requiring this if possible. If you post your code, maybe we can suggest alternatives. – Neil Kirk Oct 26 '14 at 17:01
  • Thanks for the answers... I think I'll just pull the relevant code out of the initialization list and avoid the problem as Neil hinted. Seems to be the most intelligent thing to do... And as much as I would like the -Werror ... I just cannot be that despotic (and don't actualy have that power neither), but thx anyway. – frithjofh Oct 27 '14 at 15:42

0 Answers0