Reading the documentation of the ternary operator, I've realized that there are two special cases that I've never used:
- you can use it with functions that return void :
bool ? void : void
- you can throw inside a ternary operator
So is the following valid, completely defined, and oftenly used (assuming that this is a class member, and the class owns a Type _data[Size]
) ?
Type& at(const unsigned int i)
{
return (i < Size) ? (_data[i]) : (throw std::out_of_range("ERROR"));
}