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

Implement strings for specific TChar types without inheritance #32

Open
DymOK93 opened this issue Aug 20, 2021 · 0 comments
Open

Implement strings for specific TChar types without inheritance #32

DymOK93 opened this issue Aug 20, 2021 · 0 comments

Comments

@DymOK93
Copy link
Contributor

DymOK93 commented Aug 20, 2021

Using type aliases instead of inheritance makes it possible to generalize the algorithm templates for all specializations of fixstr::basic_fixed_string.

For example (see also p1406r1):

namespace std
{
template <typename TChar,
          std::size_t N,
          typename TTraits>
struct hash<fixstr::basic_fixed_string<TChar, N, TTraits>>
{
    using argument_type = fixstr::basic_fixed_string<TChar, N, TTraits>;
    size_t operator()(const argument_type& str) const
    {
        using sv_t = typename argument_type::string_view_type;
        return std::hash<sv_t>()(static_cast<sv_t>(str));
    }
};
} // namespace std
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