[llvm] SmallVector: add missing constexpr annotations (NFC) (PR #98296)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 10 07:35:18 PDT 2024
artagnon wrote:
> > For instance, a constexpr computation involving SmallVector::size() cannot be marked constexpr. Not marking it as constexpr will not give us an inlining-guarantee, for instance. Another example of a serious issue is that we can't use a compile-time assertion on a non-constexpr expression: we'd have to use a runtime assertion instead.
>
> Isn't a constexpr constructor a prerequisite for using these in the constexpr context anyway?
I don't quite understand. What prevents me from having the following?
```cpp
template <typename T, size_t NRows, size_t NCols>
struct Matrix {
static_assert(NRows * NCols == Data.size());
SmallVector<T> Data;
...
}
```
https://github.com/llvm/llvm-project/pull/98296
More information about the llvm-commits
mailing list