1 /* { dg-do compile } */
2
3 struct input_iterator_tag { };
4 template<typename _Category, typename _Tp, typename _Distance = long, typename _Pointer = _Tp*, typename _Reference = _Tp&>
5 struct iterator {
6 typedef _Category iterator_category;
7 };
8 template<typename _Iterator> struct iterator_traits {
9 typedef typename _Iterator::iterator_category iterator_category;
10 };
11 template<typename, typename> struct __lc_rai {
12 template<typename _II1, typename _II2>
__newlast1__lc_rai13 static _II1 __newlast1(_II1, _II1 __last1, _II2, _II2) {
14 return __last1;
15 }
16 template<typename _II>
__cnd2__lc_rai17 static bool __cnd2(_II __first, _II __last) {
18 return __first != __last;
19 }
20 };
21 template<typename _II1, typename _II2, typename _Compare>
lexicographical_compare(_II1 __first1,_II1 __last1,_II2 __first2,_II2 __last2,_Compare __comp)22 bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2,
23 _II2 __last2, _Compare __comp) {
24 typedef typename iterator_traits<_II1>::iterator_category _Category1;
25 typedef typename iterator_traits<_II2>::iterator_category _Category2;
26 typedef __lc_rai<_Category1, _Category2> __rai_type;
27 __last1 = __rai_type::__newlast1(__first1, __last1, __first2, __last2);
28 for (;
29 __first1 != __last1 && __rai_type::__cnd2(__first2, __last2);
30 ++__first1, ++__first2) {
31 if (__comp(*__first1, *__first2)) return true;
32 }
33 }
34 void __assert_fail () throw () __attribute__ ((__noreturn__));
35 template<typename T> struct BoundsContainer { };
36 template<class T> class input_iterator_wrapper : public iterator<input_iterator_tag, T, long, T*, T&> {
37 public:
38 typedef BoundsContainer<T> ContainerType;
39 T* ptr;
40 ContainerType* SharedInfo;
input_iterator_wrapper(const input_iterator_wrapper & in)41 input_iterator_wrapper(const input_iterator_wrapper& in) : ptr(in.ptr), SharedInfo(in.SharedInfo) { }
42 bool operator==(const input_iterator_wrapper& in) const {
43 (static_cast<void> ((SharedInfo != __null
44 && SharedInfo == in.SharedInfo)
45 ? 0 : (__assert_fail (), 0)));
46 }
47 bool operator!=(const input_iterator_wrapper& in) const {
48 return !(*this == in);
49 }
50 T& operator*() const { }
51 input_iterator_wrapper& operator++() { }
52 };
53 struct X { };
predicate(const X &,const X &)54 bool predicate(const X&, const X&) {
55 return true;
56 }
test2(input_iterator_wrapper<X> & x)57 bool test2(input_iterator_wrapper<X>& x) {
58 return lexicographical_compare(x, x, x, x, predicate);
59 }
60