Skip to content

Implement strings for specific TChar types without inheritance  #32

@DymOK93

Description

@DymOK93

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions