私は現在、次のようなものを持っています:
template<typename T>
typename std::enable_if<!std::is_pointer<T>::value,void>::type
f( T const &t ) {
// ...
}
つまり、 がポインター型であるf
と見なされたくありません。T
これはそのままで問題なく動作します。f
ただし、引数が値によって返される値であるか、参照によって返される値であるかに基づいて、2つの異なるバージョンが必要です。
std::string const& ret_by_ref();
std::string ret_by_val();
f( ret_by_ref() ); // I want the existing function to be called here
f( ret_by_val() ); // I want a new template specialization of f() called here
上記のように呼び出されるように、既存の宣言を拡張して新しい宣言をf
作成するにはどうすればよいですか?f
C++-11より前の回答をいただければ幸いです。