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

constexpr boost::static_strings::basic_static_string s( "name" ); fails #55

Open
pdimov opened this issue Jan 1, 2024 · 4 comments
Open

Comments

@pdimov
Copy link
Member

pdimov commented Jan 1, 2024

constexpr boost::static_strings::basic_static_string s( "name" ); fails to compile (under C++20): https://godbolt.org/z/fvPs3rxa7

Background: in order to write functions that take strings as template arguments, as in function<"string">(), one needs to declare the template parameter a static string, because neither char const* nor std::string_view work.

To avoid needless reinvention of static strings, ours should (probably) be useful in this role. But it isn't, for at least the reason above.

@sdkrystian
Copy link
Member

@pdimov This is because of a shortsighted design choice I made to optimize zero size strings, accomplished via a virtual base class. Removing this and making the non-static data members public would allow for it to be used as a NTTP.

@pdimov
Copy link
Member Author

pdimov commented Jan 2, 2024

I think this specific problem isn't caused by the class not being structural, though. The error comes from std::char_traits.

@pdimov
Copy link
Member Author

pdimov commented Jan 2, 2024

Looks like an issue with libstdc++.

@pdimov
Copy link
Member Author

pdimov commented Jan 2, 2024

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

2 participants