1 // { dg-do compile }
2 template <typename _InputIterator> void __distance (_InputIterator);
3 template <typename _InputIterator>
distance(_InputIterator,_InputIterator p2)4 void distance (_InputIterator, _InputIterator p2)
5 {
6   __distance (p2);
7 }
8 
9 namespace boost
10 {
11 template <class Iterator> struct A
12 {
13   typedef typename Iterator::difference_type type;
14 };
15 template <class T> typename T::const_iterator end (T &);
16 template <class T> typename T::const_iterator begin (T &);
17 template <class T> struct D : A<typename T::const_iterator>
18 {
19 };
distance(const T & p1)20 template <class T> typename D<T>::type distance (const T &p1)
21 {
22   distance (boost::begin (p1), boost::end (p1));
23   return 0;
24 }
25 template <class IteratorT> class B
26 {
27 public:
28   typedef B type;
29   typedef IteratorT const_iterator;
30 };
31 }
32 
33 typedef int storage_t[];
34 struct F;
35 template <template <typename> class> struct G
36 {
GG37   G (const G &p1) { p1.m_fn1 ().m_fn1 (0); }
m_fn1G38   const F &m_fn1 () const
39   {
40     const void *a;
41     a = &data_m;
42     return *static_cast<const F *>(a);
43   }
44   storage_t *data_m;
45 };
46 
47 struct F
48 {
49   virtual F *m_fn1 (void *) const;
50 };
51 template <typename> struct H;
52 struct C : G<H>
53 {
54   typedef int difference_type;
55 };
56 boost::B<C> AllTransVideos ();
57 int b = boost::distance (AllTransVideos ());
58 
59