diff options
Diffstat (limited to 'src/jit/jitstd/iterator.h')
-rw-r--r-- | src/jit/jitstd/iterator.h | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/src/jit/jitstd/iterator.h b/src/jit/jitstd/iterator.h new file mode 100644 index 0000000000..1f2823e52a --- /dev/null +++ b/src/jit/jitstd/iterator.h @@ -0,0 +1,145 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + + + +#pragma once + +namespace jitstd +{ + +template <class Category, class T, class Distance = ptrdiff_t, class Pointer = T*, class Reference = T&> +struct iterator +{ + typedef T value_type; + typedef Distance difference_type; + typedef Pointer pointer; + typedef Reference reference; + typedef Category iterator_category; +}; + +struct input_iterator_tag +{ +}; + +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 +{ +}; + +struct int_not_an_iterator_tag +{ +}; + +template <typename Iterator> +struct iterator_traits +{ + typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::value_type value_type; + typedef typename Iterator::pointer pointer; + typedef typename Iterator::reference reference; + typedef typename Iterator::iterator_category iterator_category; +}; + +template <typename T> +struct iterator_traits<T*> +{ + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef T* pointer; + typedef T& reference; + typedef random_access_iterator_tag iterator_category; +}; + +template <typename T> +struct iterator_traits<const T*> +{ + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef const T* pointer; + typedef const T& reference; + typedef random_access_iterator_tag iterator_category; +}; + +template<> +struct iterator_traits<bool> +{ + typedef int_not_an_iterator_tag iterator_category; +}; + +template<> +struct iterator_traits<char> +{ + typedef int_not_an_iterator_tag iterator_category; +}; + +template<> +struct iterator_traits<signed char> +{ + typedef int_not_an_iterator_tag iterator_category; +}; + +template<> +struct iterator_traits<unsigned char> +{ + typedef int_not_an_iterator_tag iterator_category; +}; + +template<> +struct iterator_traits<short> +{ + typedef int_not_an_iterator_tag iterator_category; +}; + +template<> +struct iterator_traits<unsigned short> +{ + typedef int_not_an_iterator_tag iterator_category; +}; + +template<> +struct iterator_traits<int> +{ + typedef int_not_an_iterator_tag iterator_category; +}; + +template<> +struct iterator_traits<unsigned int> +{ + typedef int_not_an_iterator_tag iterator_category; +}; + +template<> +struct iterator_traits<__int64> +{ + typedef int_not_an_iterator_tag iterator_category; +}; + +template<> +struct iterator_traits<unsigned __int64> +{ + typedef int_not_an_iterator_tag iterator_category; +}; + +namespace util +{ +template<class Iterator> +inline +typename iterator_traits<Iterator>::iterator_category + iterator_category(const Iterator&) +{ + typename iterator_traits<Iterator>::iterator_category categ; + return categ; +} +} // end of namespace util. + +} // end of namespace jitstd. |