fixed_string
fixed_string copied to clipboard
Implement strings for specific TChar types without inheritance
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