    namespace ThirdPartyLib
    {
        template <typename T>
        class SomeContainerFromAThirdPartyLib
        {
            public:
                typedef T ValueType;    //  not value_type! 
                //  no difference_type
            
                class iterator
                {
                    public:
                        typedef T ValueType;    //  not value_type! 
                        //  no difference_type
 
                        // obviously this is not how these would actually be implemented
                        int operator != (const iterator& rhs) { return 0; }
                        iterator& operator ++ () { return *this; }
                        T operator * () { return T(); }
                };
 
                // obviously this is not how these would actually be implemented      
                iterator begin() { return iterator(); }
                iterator end() { return iterator(); }
        }; 
    }
 
    #include <cstddef>
    #include <iterator>
 
    namespace MyLib
    {
        template <typename T>
        class iterator_adapter : public T
        {
            public:
                // replace the following with the appropriate types for the third party iterator
                typedef typename T::ValueType value_type;
                typedef std::ptrdiff_t difference_type;
                typedef typename T::ValueType* pointer;
                typedef typename T::ValueType& reference;
                typedef std::input_iterator_tag iterator_category;
        
                explicit iterator_adapter(T t) : T(t) {}
        };
        
        template <typename T>
        class iterator_adapter<T*>
        {
        };
    }
 
    #include <iostream>
    #include <algorithm>

    using std::cout;
    using std::endl;    
 
    template <typename iter>
    typename MyLib::iterator_adapter<iter>::difference_type
    count(iter begin, iter end, const typename iter::ValueType& val)
    {
        cout << "[in adapter version of count]";
        return std::count(MyLib::iterator_adapter<iter>(begin), MyLib::iterator_adapter<iter>(end), val);
    }

    using std::count;

    int main()
    {
        char a[] = "Hello, world";
    
        cout << "a=" << a << std::endl;
        cout << "count(a, a + sizeof(a), 'l')=" << count(a, a + sizeof(a), 'l') << endl; 
    
        ThirdPartyLib::SomeContainerFromAThirdPartyLib<int> container;
        cout << "count(container.begin(), container.end(), 0)=";
        cout << count(container.begin(), container.end(), 0) << endl;
    
        return 0;
    }