fixed_string icon indicating copy to clipboard operation
fixed_string copied to clipboard

Implement strings for specific TChar types without inheritance

Open DymOK93 opened this issue 4 years ago • 0 comments

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

DymOK93 avatar Aug 20 '21 19:08 DymOK93