C++ Logo

std-proposals

Advanced search

[std-proposals] Efficient and silent bounds checking with silent_at()

From: trtaab trtaab <tvfvof_at_[hidden]>
Date: Wed, 5 Jul 2023 23:38:13 +0000
Dear ISO C++ Committee,

I am writing to propose the addition of a new method, "reference silent_at(size_type index) noexcept," to all random access containers in C++. This proposal aims to address the concern of bounds checking in a manner that balances efficiency and safety.

To provide further clarity and support for this proposal, I would like to share some code references that demonstrate the proposed silent_at() method and its benefits.

By studying these code references, it becomes evident that the proposed silent_at() method can offer a pragmatic compromise between the unchecked operator[] and the exception-throwing at() methods. It enables efficient bounds checking while ensuring controlled program termination without producing any output.

I sincerely appreciate your consideration of this proposal and the opportunity to contribute to the ongoing development of the C++ language. I eagerly await your feedback and the possibility of engaging in further discussions regarding this idea.

Thank you for your time and attention.

References:
silent_at:
https://godbolt.org/z/4v7Eo3ce9

at with supposed implementation:
https://godbolt.org/z/soK98Prjh

libstdc++ with _GLIBCXX_ASSERTIONS :
https://godbolt.org/z/vWzsxshGv

Rust Inefficiency due to too much debugging output:
https://godbolt.org/z/M455GqsE6


Sincerely,

Shengdun Wang
tvfvof_at_[hidden]

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows


Received on 2023-07-05 23:38:18