[libcxx-commits] [libcxx] [libc++] P3168R2 Give std::optional Range Support (PR #146491)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 1 04:51:50 PDT 2025
dywoq wrote:
```c++
_LIBCPP_HIDE_FROM_ABI constexpr reference operator*() const {
if (__ptr_ == nullptr)
std::__throw_runtime_error("deferencering end iterator");
return *__ptr_;
}
_LIBCPP_HIDE_FROM_ABI constexpr pointer operator->() const {
if (__ptr_ == nullptr)
std::__throw_runtime_error("deferencering end iterator");
return *__ptr_;
}
```
Should these functions return `__ptr_` instead of throwing exceptions if `__ptr_` is nullptr? Throwing exceptions is not allowed in constexpr functions.
https://github.com/llvm/llvm-project/pull/146491
More information about the libcxx-commits
mailing list