I have doubts on how the constructor's body works in case of initialization lists. If the value passed by the constructor are not admitted value and an exception needs to be thrown, is it correct to do something like this?
Foo(int a_) : a(a_) {
if (a>0)
throw std::invalid_argument("positive value!");
};
I am having doubt on how this is evaluated, in case of more complex situations.
According to cppreference, it is absolutely safe to assume the initializer list will be completed before the 'body' of the constructor is executed (bolding of item 4 is mine):
Now, although cppreference isn't the actual standard, it's normally accurate on such matters.
EDIT: The draft C++14 (ยง 12.6.2) standard (pp. 283-284 of that PDF) confirms what cppreference states. (Yes, I know the OP specified
C++11- but I couldn't get a link to that standard online, and I very much doubt that the standard in that matter has changed between 11, 14 and 17!)