[libcxx-commits] [libcxx] [libc++] Vectorize std::mismatch with trivially equality comparable types (PR #87716)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 5 10:25:08 PDT 2024


================
@@ -43,6 +43,27 @@ _LIBCPP_PUSH_MACROS
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+template <class _Tp>
+inline constexpr bool __can_map_to_integer_v =
+    sizeof(_Tp) == alignof(_Tp) && (sizeof(_Tp) == 1 || sizeof(_Tp) == 2 || sizeof(_Tp) == 4 || sizeof(_Tp) == 8);
+
+template <class _Tp>
----------------
ldionne wrote:

I would suggest using a more classical approach here. I think the compile-times would be better and it would be easier to understand

```c++
template <class _Tp, size_t = sizeof(_Tp)>
struct __get_as_integer_type;

template <class _Tp, size_t = sizeof(_Tp)>
struct __get_as_integer_type<_Tp, 1> { using type = uint8_t; };

// etc..
```

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


More information about the libcxx-commits mailing list