這是我在SFINAE第一次嘗試: #include <type_traits>
#include <iostream>
struct C1 {
using T = int;
};
struct C2 {
using T = void;
};
// For classes that declare T = int
template <class C>
voi
此問題符合我之前的問題:Generic operator<< ostream C++ for stringifiable class其中我想實現一個通用的<<ostream運算符,該運算符適用於任何擁有to_str()方法的類。 我已成功檢查一個類是否實現to_str()方法,並使用std::cout << stringify(a)感謝此answer。但是,我有困難編寫模板ostream<<運營商