Skip to content

Commit 9c0a9a3

Browse files
committed
cc ydb: fix zero-length array warning from StructMemberNames
commit_hash:75aa2a27a9c10ad59bfc92e483b0f00081888343
1 parent 9bbd9fd commit 9c0a9a3

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

ydb/include/userver/ydb/io/structs.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ constexpr NotStruct DetectStructMemberNames(Args&&...) noexcept {
4141
return NotStruct{};
4242
}
4343

44+
// To avoid including heavy <array> header for std::array<T, 0>.
45+
template <typename T>
46+
class EmptyRange final {
47+
public:
48+
constexpr T* begin() const noexcept { return nullptr; }
49+
constexpr T* end() const noexcept { return nullptr; }
50+
};
51+
4452
} // namespace impl
4553

4654
/// @see ydb::CustomMemberNames
@@ -57,6 +65,13 @@ struct StructMemberNames final {
5765
CustomMemberName custom_names[N];
5866
};
5967

68+
/// @cond
69+
template <>
70+
struct StructMemberNames<0> final {
71+
impl::EmptyRange<CustomMemberName> custom_names;
72+
};
73+
/// @endcond
74+
6075
// clang-format off
6176
StructMemberNames() -> StructMemberNames<0>;
6277
// clang-format on

0 commit comments

Comments
 (0)