From the std::ranges::find, std::ranges::find_if, std::ranges::find_if_not page, it does not mention exceptions, but neither are marked as noexcept.
I’m assuming that the behaviour will be the same as std::find, std::find_if, std::find_if_not. In this page it mentions the following:
Exceptions
The overloads with a template parameter named ExecutionPolicy report errors as follows:
- If execution of a function invoked as part of the algorithm throws an exception and ExecutionPolicy is one of the standard policies, std::terminate is called. For any other ExecutionPolicy, the behavior is implementation-defined.
- If the algorithm fails to allocate memory, std::bad_alloc is thrown.
So, I have two questions: 1. Is my assumption correct, and 2. will the following function be noexcept(true)?
bool checkExtensionSupport(std::span<vk::ExtensionProperties> availableExtensions, const char* extensionName) noexcept(?)
{
auto match = [extensionName](const vk::ExtensionProperties& p) {
return std::strcmp(p.extensionName, extensionName) == 0;
};
auto result = std::ranges::find_if(availableExtensions, match);
return result != availableExtensions.end();
}
because the lambda does not do any dynamic allocations, and strcmp is noexcept.