mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 13:14:55 +00:00
Fix static_assert failure for zero-length array
The recursive template implemented for `validate_size` does not support incomplete types, like zero-length array. By splitting the `validate_size` struct in two parts: 1. `validate_size_eq` that does the actual size check, and 2. `validate_size` that preserves the previous interface and inherit from `validate_size_eq`, we get the same interface and feature than previously, but without the recursive template that doesn't support incomplete types.
This commit is contained in:
parent
cbeafba9bb
commit
fba0d527fd
@ -160,15 +160,14 @@ template <typename T, int32_t Id>
|
||||
struct DummyAllocator<T, 0, 1, Id>
|
||||
: DummyAllocatorBase<DummyAllocator, T, 0, 1, Id> {};
|
||||
|
||||
template <typename Type, size_t ExpectedSize, size_t ActualSize = 0>
|
||||
struct validate_size {
|
||||
template <typename Type, size_t ExpectedSize, size_t ActualSize>
|
||||
struct validate_size_eq {
|
||||
static constexpr bool value = true;
|
||||
static_assert(ExpectedSize == ActualSize);
|
||||
};
|
||||
|
||||
template <typename Type, size_t ExpectedSize>
|
||||
struct validate_size<Type, ExpectedSize>
|
||||
: validate_size<Type, ExpectedSize, sizeof(Type)> {};
|
||||
struct validate_size : validate_size_eq<Type, ExpectedSize, sizeof(Type)> {};
|
||||
|
||||
template <size_t ExpectedOffset, size_t ActualOffset>
|
||||
struct validate_offset {
|
||||
|
Loading…
Reference in New Issue
Block a user