On Thursday, December 21, 2023, Jason McKesson via Std-Proposals wrote:
If the "throws: nothing" functions actually do throw (violating the standard, BTW),
Let's say I'm writing a C++ compiler for my new 128-Bit germanium-based supercooled microcontroller, and I want to implement 'std::align' whose prototype is as follows:
void *align( std::size_t alignment,
std::size_t size,
void*& ptr,
std::size_t& space );
This function does not have 'noexcept' written after it, even though it's not supposed to throw. Let's say my first line in the body of this function is:
if ( nullptr == p ) throw std::runtime_error("Cannot align a nullptr");
Is my implementation of 'std::align' in violation of the Standard? If so, then is the following statement true?
"The C++ Standard does not mark 'std::align' as 'noexcept' in order to accommodate implementations that violate the Standard".
This whole 'Lakos' thing isn't making sense to me. I've glanced over the papers where people are hoping 'myvector.front()' will throw if the vector is empty, but if the Standard says that 'vector::front' doesn't throw then why accommodate the violators?
I've never had a problem doing:
if ( vec.empty() ) throw SomeThing();
vec.front().InvokeSomeMethod();
Or more frequently:
assert( false == vec.empty() );
vec.front().InvokeSomeMethod(); a