[libcxx-commits] [libcxx] [libcxx] cbegin should always return a constant iterator (PR #99915)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 9 07:27:32 PDT 2024


================
@@ -277,6 +277,12 @@ struct is_same<T, T> { enum {value = 1}; };
     static_assert((test_macros_detail::is_same<__VA_ARGS__>::value), \
                  "Types differ unexpectedly")
 
+#define ASSERT_RUNTIME_AND_CONSTEXPR(...)                                                                              \
----------------
ldionne wrote:

The way we write tests for `constexpr` and non-`constexpr` elsewhere is as follows:

```
constexpr bool test() {
  std::span<T> span(...);
  assert(expression(span));
  // etc...

  return true;
}

int main() {
  test();
  static_assert(test(), "");
}
```

That way you can write the test code essentially like you'd write it for runtime-only execution and it still gets tested in a constexpr context.

https://github.com/llvm/llvm-project/pull/99915


More information about the libcxx-commits mailing list