Index: include/bits/stl_iterator.h =================================================================== --- include/bits/stl_iterator.h (revision 167390) +++ include/bits/stl_iterator.h (working copy) @@ -1009,42 +1009,81 @@ { return std::move(_M_current[__n]); } }; + // Note: See __normal_iterator operators note from Gaby to understand + // why there are always 2 versions for most of the move_iterator + // operators. template inline bool operator==(const move_iterator<_IteratorL>& __x, const move_iterator<_IteratorR>& __y) { return __x.base() == __y.base(); } + template + inline bool + operator==(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return __x.base() == __y.base(); } + template inline bool operator!=(const move_iterator<_IteratorL>& __x, const move_iterator<_IteratorR>& __y) { return !(__x == __y); } + template + inline bool + operator!=(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return !(__x == __y); } + template inline bool operator<(const move_iterator<_IteratorL>& __x, const move_iterator<_IteratorR>& __y) { return __x.base() < __y.base(); } + template + inline bool + operator<(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return __x.base() < __y.base(); } + template inline bool operator<=(const move_iterator<_IteratorL>& __x, const move_iterator<_IteratorR>& __y) { return !(__y < __x); } + template + inline bool + operator<=(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return !(__y < __x); } + template inline bool operator>(const move_iterator<_IteratorL>& __x, const move_iterator<_IteratorR>& __y) { return __y < __x; } + template + inline bool + operator>(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return __y < __x; } + template inline bool operator>=(const move_iterator<_IteratorL>& __x, const move_iterator<_IteratorR>& __y) { return !(__x < __y); } + template + inline bool + operator>=(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return !(__x < __y); } + // DR 685. template inline auto @@ -1054,6 +1093,13 @@ { return __x.base() - __y.base(); } template + inline auto + operator-(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + -> decltype(__x.base() - __y.base()) + { return __x.base() - __y.base(); } + + template inline move_iterator<_Iterator> operator+(typename move_iterator<_Iterator>::difference_type __n, const move_iterator<_Iterator>& __x) Index: testsuite/24_iterators/move_iterator/greedy_ops.cc =================================================================== --- testsuite/24_iterators/move_iterator/greedy_ops.cc (revision 0) +++ testsuite/24_iterators/move_iterator/greedy_ops.cc (revision 0) @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void test01() +{ + typedef std::move_iterator iterator_type; + + iterator_type it(nullptr); + + it == it; + it != it; + it < it; + it <= it; + it > it; + it >= it; + it - it; + 1 + it; + it + 1; +} + +int main() +{ + test01(); + return 0; +} Index: testsuite/24_iterators/normal_iterator/greedy_ops.cc =================================================================== --- testsuite/24_iterators/normal_iterator/greedy_ops.cc (revision 0) +++ testsuite/24_iterators/normal_iterator/greedy_ops.cc (revision 0) @@ -0,0 +1,52 @@ +// { dg-do compile } +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +namespace greedy_ops +{ + struct C + { + typedef X* pointer; + }; +} + +void test01() +{ + typedef __gnu_cxx::__normal_iterator iterator_type; + + iterator_type it(0); + + it == it; + it != it; + it < it; + it <= it; + it > it; + it >= it; + it - it; + it + 1; + 1 + it; +} + +int main() +{ + test01(); + return 0; +} Index: testsuite/24_iterators/reverse_iterator/greedy_ops.cc =================================================================== --- testsuite/24_iterators/reverse_iterator/greedy_ops.cc (revision 0) +++ testsuite/24_iterators/reverse_iterator/greedy_ops.cc (revision 0) @@ -0,0 +1,43 @@ +// { dg-do compile } +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void test01() +{ + typedef std::reverse_iterator iterator_type; + + iterator_type it; + + it == it; + it != it; + it < it; + it <= it; + it > it; + it >= it; + it - it; + 1 + it; + it + 1; +} + +int main() +{ + test01(); + return 0; +} Index: testsuite/23_containers/vector/types/1.cc =================================================================== --- testsuite/23_containers/vector/types/1.cc (revision 167390) +++ testsuite/23_containers/vector/types/1.cc (working copy) @@ -1,6 +1,6 @@ // 2005-12-01 Paolo Carlini -// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2009, 2010 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -20,24 +20,12 @@ // { dg-do compile } #include +#include -namespace N -{ - struct X { }; - - template - X operator+(T, std::size_t) - { return X(); } - - template - X operator-(T, T) - { return X(); } -} - int main() { - std::vector v(5); - const std::vector w(1); + std::vector v(5); + const std::vector w(1); v[0]; w[0]; Index: testsuite/23_containers/deque/types/1.cc =================================================================== --- testsuite/23_containers/deque/types/1.cc (revision 167390) +++ testsuite/23_containers/deque/types/1.cc (working copy) @@ -20,35 +20,33 @@ // { dg-do compile } #include +#include -namespace N -{ - struct X { }; - - template - X operator+(T, std::size_t) - { return X(); } - - template - X operator-(T, T) - { return X(); } -} - int main() { - std::deque d(5); - const std::deque e(1); + std::deque d(5); + const std::deque e(1); d[0]; e[0]; d.size(); d.erase(d.begin()); d.resize(1); - d.assign(1, N::X()); - d.insert(d.begin(), N::X()); - d.insert(d.begin(), 1, N::X()); + d.assign(1, greedy_ops::X()); + d.insert(d.begin(), greedy_ops::X()); + d.insert(d.begin(), 1, greedy_ops::X()); d.insert(d.begin(), e.begin(), e.end()); d = e; + std::deque::iterator it; + it == it; + it != it; + it < it; + it <= it; + it > it; + it >= it; + it - it; + it + 1; + return 0; } Index: testsuite/util/testsuite_greedy_ops.h =================================================================== --- testsuite/util/testsuite_greedy_ops.h (revision 0) +++ testsuite/util/testsuite_greedy_ops.h (revision 0) @@ -0,0 +1,58 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +namespace greedy_ops +{ + struct X + {}; + + template + X operator == (T, T) + { return X(); } + + template + X operator != (T, T) + { return X(); } + + template + X operator < (T, T) + { return X(); } + + template + X operator <= (T, T) + { return X(); } + + template + X operator > (T, T) + { return X(); } + + template + X operator >= (T, T) + { return X(); } + + template + X operator - (T, T) + { return X(); } + + template + T operator+ (std::size_t, T) + { return T(); } + + template + T operator+ (T, std::size_t) + { return T(); } +} Property changes on: testsuite/util/testsuite_greedy_ops.h ___________________________________________________________________ Added: svn:eol-style + native