[libcxx-commits] [libcxx] [libc++] std::atomic primary template should not have a `difference_type` member type (PR #123236)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 20 06:07:02 PST 2025
================
@@ -29,163 +29,176 @@
# include <thread>
#endif
-template <class A, bool Integral>
-struct test_atomic
-{
- test_atomic()
- {
- A a; (void)a;
+// detect existence of the difference_type member type
+template <class...>
+using myvoid_t = void;
+template <typename T, typename = void>
+struct has_difference_type : std::false_type {};
+template <typename T>
+struct has_difference_type<T, myvoid_t<typename T::difference_type> > : std::true_type {};
+
+template <class A, bool IntegralOrFloating, bool Pointer>
----------------
ldionne wrote:
```suggestion
template <class T, bool IntegralOrFloating = (std::is_integral<T>::value && !std::is_same<T, bool>::value) || std::is_floating_point<T>::value, bool Pointer = std::is_pointer<T>::value>
```
We can take `T` directly here while we're at it, and then form `using A = std::atomic<T>`. That simplifies a few things.
https://github.com/llvm/llvm-project/pull/123236
More information about the libcxx-commits
mailing list