glaze: gcc and msvc compilation error with explicit constructors
Hello, Please consider the following:
#include <glaze/glaze.hpp>
#include <filesystem>
struct S1
{
int a{};
int b{};
std::filesystem::path fn{};
};
static_assert( glz::detail::count_members<S1> == 3 );
Does not compile under gcc 13 & 14 (and maybe more compilers). Because count_members returns 2… (and of course tuplification is broken you would have guessed)
Here is what I think is the adequate fix:
--- a/include/glaze/reflection/to_tuple.hpp
+++ b/include/glaze/reflection/to_tuple.hpp
@@ -51,7 +51,7 @@ namespace glz
requires(std::is_aggregate_v<std::remove_cvref_t<T>>)
inline constexpr auto count_members = [] {
using V = std::remove_cvref_t<T>;
- if constexpr (requires { V{{Args{}}..., {any_t{}}}; } == false) {
+ if constexpr (requires { V{Args{}...,any_t{}}; } == false) {
return sizeof...(Args);
}
else {
Hopefully no regression for decent compilers… Enjoy, and best! (and pardon me for not making a fork + PR for a one-liner 😉 )
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 23 (15 by maintainers)
You’re my hero-porter !