value_type
OutputIterator から値を抽出する方法がないため、なぜ OutputIteratorが必要なのかわかりません。ただし、3 つの挿入イテレータ アダプタはすべてvalue_type
であると定義し、型メンバーvoid
を提供するため、 ofが であることが判明した場合、of にcontainer_type
フォールバックできます。value_type
T::container_type
value_type
T
void
(「value_type
の」とは、本当に「と」を意味std::iterator_traits<T::container_type>::value_type
しstd::iterator_traits<T>::value_type
ます。)
または、値があるかのように出力イテレータを使用しようとすることはできません:)
編集: SFINAE は必要ありません: (C++11 の良さがなくても)
template<typename U, typename T> struct helper {typedef U type;};
// ostream*_iterator handling courtesy Drew Dormann
template <typename T, typename charT, typename traits>
struct helper<void, std::ostream_iterator<T, charT, traits> > {typedef T type;};
template <typename charT, typename traits>
struct helper<void, std::ostreambuf_iterator<charT, traits> > {typedef charT type;};
// std::raw_storage_iterator still needs an override
// as well as any non-standard output iterators which don't define a container_type.
template<typename T> struct helper<void, T>
{typedef typename std::iterator_traits<typename T::container_type>::value_type type;};
typedef<typename It> struct my_value_type
: public helper<typename std::iterator_traits<It>::value_type, It> {};