
Dean Michael Berris wrote:
Another is the issue of conversion, and enforcement of concepts on the type T. When you want to ensure that T is default constructable and assignable, and you want to force conversions of objects passed to your function to T, you'd have code that looks like:
template <typename TReal> struct polymorphic_conversion_forcer {
template <typename TDeduced> void function(TDeduced const & t) { TReal r = t; // TReal should be default constructable and assignable, and TDeduced should be convertible to TReal };
};
Apart from the historical reason, ostream_iterator seems to fall into anti-pattern: one name, two functionality. The enforcement part could be delegated to another output iterator adaptor. My current solution is something like this: copy(stream_read<char>(std::in), converter<std::string>() |= stream_writer(std::cout)); Regards, -- Shunsuke Sogame