pfr
pfr copied to clipboard
names_as_array returns an incorrect type when the input has zero fields
Compiler: gcc13.1, Linux
Boost 1.84
Godbolt: https://godbolt.org/z/xxT1Tsoe7
Description: when names_as_array is called on a struct with no fields, std::array<std::nullptr_t, N> is returned, rather than std::array<std::string_view, 0>. This makes generic code more difficult.
#include <boost/pfr.hpp>
namespace pfr = boost::pfr;
struct MyType {};
int main()
{
std::array<std::string_view, 0> names = pfr::names_as_array<MyType>();
}
Happens on clang-19 (on my machine) too.