パラメータ。のstd :: enable_if_tは、私は二重引用符なしの文字列をダブルクォーテーション内のデータ、および他のすべての種類を印刷する必要が
これは、引数が文字列であるかどうかを確認するために私の関数です。
template<class T>
struct is_str : std::integral_constant<bool, false> {};
template<> struct is_str<char*> : std::integral_constant<bool, true> {};
template<> struct is_str<wchar_t*> : std::integral_constant<bool, true> {};
template<> struct is_str<const char*> : std::integral_constant<bool, true> {};
template<> struct is_str<const wchar_t*> : std::integral_constant<bool, true> {};
template<> struct is_str<std::string> : std::integral_constant<bool, true> {};
template<> struct is_str<const std::string> : std::integral_constant<bool, true> {};
template<> struct is_str<std::wstring> : std::integral_constant<bool, true> {};
template<> struct is_str<const std::wstring> : std::integral_constant<bool, true> {};
プリンタ機能で、私はそれがエラー
でコンパイルされません。この認識できないテンプレート宣言/定義
template<typename T>
std::enable_if_t<is_str<T>::value>, std::ostream&>
operator<<(std::ostream& xx, const T& ar)
{
xx << "\"" << ar << "\"";
return xx;
}
template<typename T>
std::enable_if_t<!is_str<T>::value>, std::ostream&>
operator<<(std::ostream& xx, const T& ar)
{
xx << ar;
return xx;
}
のような上記の機能を使用します
誰かがこの問題を解決する方法やより良い方法を教えてもらえますか?彼の状況?
を追加する必要があります@のmax66の美しい答えをお読みください。彼はあなたのコードでより多くの問題に深く入りました:) –