[英]Custom specialization of `std::basic_string<>`
Let us assume I have a special character type, myChar
, which is distinct from the existing standard character classes ( char
, wchar_t
, char16_t
, char32_t
) used as specializations of std::basic_string<>
.让我们假设我有一个特殊的字符类型
myChar
,它不同于用作std::basic_string<>
的现有标准字符类( char
、 wchar_t
、 char16_t
、 char32_t
)。
Let us also assume that the features provided by std::basic_string< myChar >
are almost all that I need.我们还假设
std::basic_string< myChar >
提供的功能几乎是我所需要的。 I just want two, three functions in addition to what that template already provides.除了模板已经提供的功能之外,我只想要两三个功能。
Let us also assume I have somewhat limited experience with programming templates (as opposed to using them, which I do all day).我们还假设我对编程模板的经验有限(而不是使用它们,我整天都在使用它们)。
How would I go about spezializing a standard template, expanding it with additional functions?我将如何对标准模板进行特殊化,并使用附加功能对其进行扩展?
I have a feeling it should be a matter of just a few lines, but I cannot figure it out.我有一种感觉应该只是几行的问题,但我无法弄清楚。
正如 Bo Persson 指出的那样,如果不重新实现所有模板,就无法以这种方式部分扩展模板。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.