2
私はこの記事に出くわした: Convert a number to a string literal with constexprVariadicテンプレートの継承を解釈する方法は?
そして、答えは非常に興味深いです:
namespace detail
{
template<unsigned... digits>
struct to_chars { static const char value[]; };
template<unsigned... digits>
const char to_chars<digits...>::value[] = {('0' + digits)..., 0};
template<unsigned rem, unsigned... digits>
struct explode : explode<rem/10, rem % 10, digits...> {};
template<unsigned... digits>
struct explode<0, digits...> : to_chars<digits...> {};
}
template<unsigned num>
struct num_to_string : detail::explode<num> {};
私の質問は以下のとおりです。
"構造体の爆発:爆発" 爆発から継承を爆発宣言します;どのように "構造体の分解< 0、数字...>:to_chars"?
最初のテンプレートパラメータとして '0'の機能は何ですか?
ありがとう!
バリディアックテンプレートの拡張によって派生することを継承し、最後に別の構造体(継承)を継承することは非常に面白いです。ありがとう! – Hei