Skip to content

Commit a0acbcf

Browse files
authored
Merge pull request #390 from elbeno/fix-explicit-constructor-clang-tidy
🚨 Relax `google-explicit-constructor` lint directives
2 parents 5b04291 + 639dd11 commit a0acbcf

4 files changed

Lines changed: 11 additions & 20 deletions

File tree

include/stdx/ct_string.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ concept format_convertible = requires(T t) {
2727
template <std::size_t N> struct ct_string {
2828
consteval ct_string() = default;
2929

30-
// NOLINTNEXTLINE(*-avoid-c-arrays, google-explicit-constructor)
30+
// NOLINTNEXTLINE(*-avoid-c-arrays)
3131
consteval explicit(false) ct_string(char const (&str)[N]) {
3232
for (auto i = std::size_t{}; i < N; ++i) {
3333
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-*)
@@ -36,7 +36,6 @@ template <std::size_t N> struct ct_string {
3636
}
3737

3838
template <detail::format_convertible T>
39-
// NOLINTNEXTLINE(google-explicit-constructor)
4039
consteval explicit(false) ct_string(T t) : ct_string(+t) {}
4140

4241
consteval explicit(true) ct_string(char const *str, std::size_t sz) {

include/stdx/env.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,15 @@ concept envlike = is_specialization_of_v<T, env>;
4444

4545
namespace _env {
4646
template <typename T> struct autowrap {
47-
// NOLINTNEXTLINE(google-explicit-constructor)
48-
consteval autowrap(T t) : value(t) {}
47+
consteval explicit(false) autowrap(T t) : value(t) {}
4948
T value;
5049
};
5150

5251
// NOLINTNEXTLINE(*-avoid-c-arrays)
5352
template <std::size_t N> using str_lit_t = char const (&)[N];
5453

5554
template <std::size_t N> struct autowrap<str_lit_t<N>> {
56-
// NOLINTNEXTLINE(google-explicit-constructor)
57-
consteval autowrap(str_lit_t<N> str) : value(str) {}
55+
consteval explicit(false) autowrap(str_lit_t<N> str) : value(str) {}
5856
stdx::ct_string<N> value;
5957
};
6058

include/stdx/span.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,15 @@ class span : public detail::span_base<T, Extent> {
9393
: base_t{first, sore}, ptr{stdx::to_address(first)} {}
9494

9595
template <typename U, std::size_t N>
96-
// NOLINTNEXTLINE(google-explicit-constructor)
97-
constexpr span(std::array<U, N> &arr LIFETIMEBOUND) noexcept
96+
constexpr explicit(false) span(std::array<U, N> &arr LIFETIMEBOUND) noexcept
9897
: base_t{std::data(arr), N}, ptr{std::data(arr)} {
9998
static_assert(Extent == dynamic_extent or Extent <= N,
10099
"Span extends beyond available storage");
101100
}
102101

103102
template <typename U, std::size_t N>
104-
// NOLINTNEXTLINE(google-explicit-constructor)
105-
constexpr span(std::array<U, N> const &arr LIFETIMEBOUND) noexcept
103+
constexpr explicit(false)
104+
span(std::array<U, N> const &arr LIFETIMEBOUND) noexcept
106105
: base_t{std::data(arr), N}, ptr{std::data(arr)} {
107106
static_assert(Extent == dynamic_extent or Extent <= N,
108107
"Span extends beyond available storage");
@@ -112,8 +111,7 @@ class span : public detail::span_base<T, Extent> {
112111
template <std::size_t N> using arr_t = type_identity_t<element_type> (&)[N];
113112

114113
template <std::size_t N>
115-
// NOLINTNEXTLINE(google-explicit-constructor)
116-
constexpr span(arr_t<N> arr LIFETIMEBOUND) noexcept
114+
constexpr explicit(false) span(arr_t<N> arr LIFETIMEBOUND) noexcept
117115
: base_t{std::data(arr), N}, ptr{std::data(arr)} {
118116
static_assert(Extent == dynamic_extent or Extent <= N,
119117
"Span extends beyond available storage");
@@ -136,8 +134,7 @@ class span : public detail::span_base<T, Extent> {
136134

137135
template <class U, std::size_t N>
138136
requires(dependent_extent<U> == dynamic_extent or N != dynamic_extent)
139-
// NOLINTNEXTLINE(google-explicit-constructor)
140-
constexpr span(span<U, N> const &s) noexcept
137+
constexpr explicit(false) span(span<U, N> const &s) noexcept
141138
: base_t{s.data(), s.size()}, ptr{s.data()} {}
142139

143140
[[nodiscard]] constexpr auto data() const noexcept -> pointer {

include/stdx/utility.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,8 @@ template <char... Chars> consteval auto operator""_z64() {
192192

193193
namespace cxv_detail {
194194
struct from_any {
195-
// NOLINTNEXTLINE(google-explicit-constructor)
196-
template <typename... Ts> constexpr from_any(Ts const &...) {}
197-
// NOLINTNEXTLINE(google-explicit-constructor)
198-
constexpr operator int() const { return 0; }
195+
template <typename... Ts>
196+
constexpr explicit(false) from_any(Ts const &...) {}
199197
};
200198

201199
struct value_marker {};
@@ -252,8 +250,7 @@ constexpr auto is_aligned_with = [](auto v) -> bool {
252250

253251
namespace detail {
254252
template <typename T> struct ct_helper {
255-
// NOLINTNEXTLINE(google-explicit-constructor)
256-
consteval ct_helper(auto t) : value(t) {}
253+
consteval explicit(false) ct_helper(auto t) : value(t) {}
257254
T value;
258255
};
259256

0 commit comments

Comments
 (0)