summaryrefslogtreecommitdiffstats
path: root/libcxx/include/iterator
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2017-05-17 18:51:36 +0000
committerMarshall Clow <mclow.lists@gmail.com>2017-05-17 18:51:36 +0000
commitf51ee632475654a396f93da9d36841989e1c7742 (patch)
tree72532fa17dc2a96b7493fcfce9d0ea4d94779dfe /libcxx/include/iterator
parentd38107b5668ed918d6ad0154e3d63df2c3cf154d (diff)
downloadbcm5719-llvm-f51ee632475654a396f93da9d36841989e1c7742.tar.gz
bcm5719-llvm-f51ee632475654a396f93da9d36841989e1c7742.zip
Make next/prev/advance/distance operations on iterators be constexpr. I missed this when I implemented the rest of P0031R0
llvm-svn: 303281
Diffstat (limited to 'libcxx/include/iterator')
-rw-r--r--libcxx/include/iterator37
1 files changed, 23 insertions, 14 deletions
diff --git a/libcxx/include/iterator b/libcxx/include/iterator
index 47a7811a300..4aa44746dc9 100644
--- a/libcxx/include/iterator
+++ b/libcxx/include/iterator
@@ -64,14 +64,23 @@ struct forward_iterator_tag : public input_iterator_tag {};
struct bidirectional_iterator_tag : public forward_iterator_tag {};
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
+// 27.4.3, iterator operations
// extension: second argument not conforming to C++03
-template <class InputIterator>
-void advance(InputIterator& i,
+template <class InputIterator> // constexpr in C++17
+ constexpr void advance(InputIterator& i,
typename iterator_traits<InputIterator>::difference_type n);
-template <class InputIterator>
-typename iterator_traits<InputIterator>::difference_type
-distance(InputIterator first, InputIterator last);
+template <class InputIterator> // constexpr in C++17
+ constexpr typename iterator_traits<InputIterator>::difference_type
+ distance(InputIterator first, InputIterator last);
+
+template <class InputIterator> // constexpr in C++17
+ constexpr InputIterator next(InputIterator x,
+typename iterator_traits<InputIterator>::difference_type n = 1);
+
+template <class BidirectionalIterator> // constexpr in C++17
+ constexpr BidirectionalIterator prev(BidirectionalIterator x,
+ typename iterator_traits<BidirectionalIterator>::difference_type n = 1);
template <class Iterator>
class reverse_iterator
@@ -529,7 +538,7 @@ struct _LIBCPP_TEMPLATE_VIS iterator
};
template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
void __advance(_InputIter& __i,
typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag)
{
@@ -538,7 +547,7 @@ void __advance(_InputIter& __i,
}
template <class _BiDirIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
void __advance(_BiDirIter& __i,
typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag)
{
@@ -551,7 +560,7 @@ void __advance(_BiDirIter& __i,
}
template <class _RandIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
void __advance(_RandIter& __i,
typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag)
{
@@ -559,7 +568,7 @@ void __advance(_RandIter& __i,
}
template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
void advance(_InputIter& __i,
typename iterator_traits<_InputIter>::difference_type __n)
{
@@ -567,7 +576,7 @@ void advance(_InputIter& __i,
}
template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename iterator_traits<_InputIter>::difference_type
__distance(_InputIter __first, _InputIter __last, input_iterator_tag)
{
@@ -578,7 +587,7 @@ __distance(_InputIter __first, _InputIter __last, input_iterator_tag)
}
template <class _RandIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename iterator_traits<_RandIter>::difference_type
__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
{
@@ -586,7 +595,7 @@ __distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
}
template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename iterator_traits<_InputIter>::difference_type
distance(_InputIter __first, _InputIter __last)
{
@@ -594,7 +603,7 @@ distance(_InputIter __first, _InputIter __last)
}
template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
_InputIter
next(_InputIter __x,
typename iterator_traits<_InputIter>::difference_type __n = 1,
@@ -605,7 +614,7 @@ next(_InputIter __x,
}
template <class _BidiretionalIter>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
_BidiretionalIter
prev(_BidiretionalIter __x,
typename iterator_traits<_BidiretionalIter>::difference_type __n = 1,
OpenPOWER on IntegriCloud