Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

names_as_array returns an incorrect type when the input has zero fields #165

Open
anarthal opened this issue Mar 21, 2024 · 1 comment
Open

Comments

@anarthal
Copy link

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>(); 
}
@anarthal
Copy link
Author

Happens on clang-19 (on my machine) too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant