Date: Thu, 6 Jul 2023 13:45:16 +0200
On 7/6/23 03:35, trtaab trtaab via Std-Proposals wrote:
> By introducing the "silent_at" method, we provide an alternative
> approach that allows for efficient bounds checking without the overhead
> and potential performance implications of exceptions. The "silent_at"
> method ensures controlled program termination through a crash mechanism,
> such as __builtin_trap(), in the event of an out-of-bounds access.
You may consider using a free function instead
template <typename T>
auto silent_at(const T& container, size_type index) noe
{
if (container.size() <= index)
{
// Your project-specific termination
std::terminate();
}
return container[index];
}
> By introducing the "silent_at" method, we provide an alternative
> approach that allows for efficient bounds checking without the overhead
> and potential performance implications of exceptions. The "silent_at"
> method ensures controlled program termination through a crash mechanism,
> such as __builtin_trap(), in the event of an out-of-bounds access.
You may consider using a free function instead
template <typename T>
auto silent_at(const T& container, size_type index) noe
{
if (container.size() <= index)
{
// Your project-specific termination
std::terminate();
}
return container[index];
}
Received on 2023-07-06 11:45:19