std::iterator_traits<T>::value_type
が有効で定義されているかどうかをコンパイル時に知るための解決策を探しています。これに関する問題は、std ライブラリが value_type の宣言を T の派生型に転送することです。
typedef T::value_type value_type;
value_type が存在しないことに関連するエラーを回避するために、コンパイル時に T::value_type が有効な型であるかどうかを知る必要があります。
次の例を検討してください。
std::iterator_traits<int *>::value_type; // OK - should return that value_type exists as it's defined in specialization of std::iterator_traits
std::iterator_traits<const int *>::value_type; // OK - should return that value_type exists as it's defined in specialization of std::iterator_traits
std::iterator_traits<std::vector<int>::const_iterator> >::value_type; // OK - the value_type exists defined within std::vector<int>::const_iterator
std::iterator_traits<int>::value_type; // ERROR - the value_type is not defined within int class - this is what I'm trying to avoid to resolve the value_type of.
C++ 標準および std ライブラリ標準に完全に準拠し、コンパイラに依存しないソリューションが必要です。