[libcxx-commits] [libcxx] [libc++] Add assumption for align of begin and end pointers of vector. (PR #108961)

Peng Liu via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 28 11:32:38 PST 2025


================
@@ -775,6 +780,17 @@ class _LIBCPP_TEMPLATE_VIS vector {
   }
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector&, false_type) _NOEXCEPT {}
+
+  static _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer __add_alignment_assumption(pointer __p) _NOEXCEPT {
+#ifndef _LIBCPP_CXX03_LANG
+    if constexpr (is_pointer<pointer>::value) {
----------------
winner245 wrote:

@ldionne Are we using `constexpr if` in C++11/14 as a compiler extension here? I've also noticed several other usages of `constexpr if` in C++14 mode in libc++. 
Does this imply that we can generally use `constexpr if` within the context of C++11/14 in libc++?

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


More information about the libcxx-commits mailing list