以下の記事を読みました。
https://cpplover.blogspot.com/2011/04/c0xenableif.html
cpp
1template < typename T, 2 typename Reserved = typename std::enable_if< std::is_arithmetic<T>::value >::type > 3void f( T ) { } 4 5template < typename T, 6 typename Reserved = typename std::enable_if< std::is_pointer<T>::value >::type > 7void f( T ) { } // エラー、再定義
だとオーバーロードできない、と書かれていますが、
cpp
1template <typename T> 2typename std::enable_if<std::is_pointer<T>::value>::type f(T) { 3 std::cout << "pointer" << std::endl; 4} 5 6template <typename T> 7typename std::enable_if<std::is_arithmetic<T>::value>::type f(T) { 8 std::cout << "arithmethic" << std::endl; 9} 10
だけで今はできますよね。
以前はこう書くことはできなかったのでしょうか…?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/03/11 08:14