Skip to content

Commit

Permalink
Fix building with MSVC.
Browse files Browse the repository at this point in the history
The original code mysteriously causes an error
`use of undefined type 'riegeli::Dependency<Handle,InlineManagers>'`.

PiperOrigin-RevId: 667928744
  • Loading branch information
QrczakMK committed Aug 27, 2024
1 parent 92fda25 commit e5ec82a
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions riegeli/base/any.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ constexpr size_t AnyBase<Handle, inline_size, inline_align>::kAvailableAlign;
// erasing the `Manager` parameter from the type of the `Any`, or is empty.
template <typename Handle, size_t inline_size = 0, size_t inline_align = 0>
class Any : public any_internal::AnyBase<Handle, inline_size, inline_align> {
private:
// Indirection through `InliningImpl` is needed for MSVC for some reason.
template <typename... InlineManagers>
struct InliningImpl {
using type =
Any<Handle,
UnsignedMax(inline_size,
sizeof(Dependency<Handle, InlineManagers>)...),
UnsignedMax(inline_align,
alignof(Dependency<Handle, InlineManagers>)...)>;
};

public:
// `Any<Handle>::Inlining<InlineManagers...>` enlarges inline storage of
// `Any<Handle>`.
Expand All @@ -222,12 +234,7 @@ class Any : public any_internal::AnyBase<Handle, inline_size, inline_align> {
// `Dependency<Handle, Manager>` fits there regarding size and alignment.
// By default inline storage is enough for a pointer.
template <typename... InlineManagers>
using Inlining =
Any<Handle,
UnsignedMax(inline_size,
sizeof(Dependency<Handle, InlineManagers>)...),
UnsignedMax(inline_align,
alignof(Dependency<Handle, InlineManagers>)...)>;
using Inlining = typename InliningImpl<InlineManagers...>::type;

// Creates an empty `Any`.
Any() noexcept { this->Initialize(); }
Expand Down

0 comments on commit e5ec82a

Please sign in to comment.