Listing 3
template <typename C> class sequence_range { private: enum { C_HAS_MUTABLE_INTERFACE = has_iterator_type<C>::value && has_pointer_type<C>::value }; typedef typename typefixer_reference< C , C_HAS_MUTABLE_INTERFACE >::reference putative_reference; typedef typename typefixer_iterator< C , C_HAS_MUTABLE_INTERFACE >::iterator putative_iterator; public: typedef typename C::const_reference const_reference; typedef typename select_first_type< putative_reference , const_reference , C_HAS_MUTABLE_INTERFACE >::type reference; typedef typename C::const_iterator const_iterator; typedef typename select_first_type< putative_iterator , const_iterator , C_HAS_MUTABLE_INTERFACE >::type iterator; . . . reference current() { return *m_current; // This now works for mutable and immutable coll } const_reference current() const { return *m_current; } . . . // Remainder of class as shown before