I am trying to implement a basic mixin using CRTP.
When I try to create an object of my class I get the following warning:
error: missing initializer for member 'my_mixin::<anonymous>' [-Werror=missing-field-initializers]
My code is as follow
template<typename U, template<typename...> class... CRTP>
struct ops: CRTP<U>... {};
template<typename T>
struct listed { using list = std::vector<T>; };
template<typename T>
struct eq { bool operator==(const eq<T>& other) const = default; };
struct my_mixin: ops<my_mixin,listed,eq> {
uint32_t uuid;
std::string name;
};
int main(int, char**) {
const my_mixin carrier = {
.uuid = 1234,
.name = std::string{"name"},
};
}
Example on compiler explorer: https://godbolt.org/z/eY4McoK69
What am I missing?
Is it possible to get past the issue without disabling the warning in the compiler?
Additional: This compiles without issue on Clang 16 and MSVC 19. As @barry pointed out it appears to be a gcc bug.