Skip to content

Commit c77af00

Browse files
diamante0018philnik777
authored andcommitted
[libc++] mark barrier constructor as explicit in <barrier>
If I read the standard correctly, the public constructor of "barrier" should be marked as "constexpr explicit". I see some of the internal classes used by the barrier header are correctly marked but I think, if I'm not mistaken, the standard would like the public class to have the correct definition as well. Because the implementation that llvm uses by default is not constexpr friendly at this time, this revision will focus on only marking it as explicit. Reviewed By: #libc, philnik, Mordante Spies: philnik, Mordante, libcxx-commits Differential Revision: https://reviews.llvm.org/D154590
1 parent 6071273 commit c77af00

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

libcxx/include/barrier

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public:
298298
}
299299

300300
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
301-
barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF())
301+
explicit barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF())
302302
: __b_(__count, _VSTD::move(__completion)) {
303303
}
304304

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// UNSUPPORTED: no-threads
10+
// UNSUPPORTED: c++03, c++11
11+
12+
// <barrier>
13+
14+
// explicit barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF());
15+
16+
// Make sure that the ctor of barrier is explicit.
17+
18+
#include <barrier>
19+
20+
#include "test_convertible.h"
21+
22+
static_assert(!test_convertible<std::barrier<>, std::ptrdiff_t>(), "This constructor must be explicit");

0 commit comments

Comments
 (0)