Generic Programming
템플릿 예제
hellobird
2019. 3. 23. 11:27
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | using namespace std; template <typename I, typename J> auto add(I i, J j) -> decltype (i + j){ return i + j; } template <typename T> auto co_T(T t_) -> decltype (t_){ cout << typeid (t_).name() << " : " << t_ << endl; return t_; } int main(int argc, char *argv[]) { auto d = add<int , double>(2, 2.5); co_T(d); return 0; } | cs |