[libc++] counting_semaphore should not be default-constructible.
Neither the current C++2b draft, nor any revision of [p1135],
nor libstdc++, claims that `counting_semaphore` should be
default-constructible. I think this was just a copy-paste issue
somehow.
Also, `explicit` was missing from the constructor.
Also, `constexpr` remains missing; but that's probably more of a
technical limitation, since apparently there are some platforms
where we don't (can't??) use the atomic implementation and
have to rely on pthreads, which obviously isn't constexpr.
Differential Revision: https://reviews.llvm.org/D110042
NOKEYCHECK=True
GitOrigin-RevId: c9af0e61fa85842ce280ddab8ab491de38a7ae5b
diff --git a/include/semaphore b/include/semaphore
index 906f62e..4f9ecd0 100644
--- a/include/semaphore
+++ b/include/semaphore
@@ -82,7 +82,7 @@
public:
_LIBCPP_INLINE_VISIBILITY
- __atomic_semaphore_base(ptrdiff_t __count) : __a(__count)
+ constexpr explicit __atomic_semaphore_base(ptrdiff_t __count) : __a(__count)
{
}
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
@@ -136,7 +136,7 @@
public:
_LIBCPP_INLINE_VISIBILITY
- __platform_semaphore_base(ptrdiff_t __count) :
+ explicit __platform_semaphore_base(ptrdiff_t __count) :
__semaphore()
{
__libcpp_semaphore_init(&__semaphore, __count);
@@ -190,7 +190,7 @@
}
_LIBCPP_INLINE_VISIBILITY
- counting_semaphore(ptrdiff_t __count = 0) : __semaphore(__count) { }
+ constexpr explicit counting_semaphore(ptrdiff_t __count) : __semaphore(__count) { }
~counting_semaphore() = default;
counting_semaphore(const counting_semaphore&) = delete;