Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
move_iterator.h162 linesDownload Raw Back to __iterator
1// -*- C++ -*-2//===----------------------------------------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.8// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.9//10//===----------------------------------------------------------------------===//11 12#ifndef _LIBCUDACXX___ITERATOR_MOVE_ITERATOR_H13#define _LIBCUDACXX___ITERATOR_MOVE_ITERATOR_H14 15#ifndef __cuda_std__16#include <__config>17#endif // __cuda_std__18 19#include "../__iterator/iterator_traits.h"20#include "../__type_traits/conditional.h"21#include "../__type_traits/is_reference.h"22#include "../__type_traits/remove_reference.h"23#include "../__utility/move.h"24 25#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)26#  pragma GCC system_header27#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)28#  pragma clang system_header29#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)30#  pragma system_header31#endif // no system header32 33_LIBCUDACXX_BEGIN_NAMESPACE_STD34 35 36template <class _Iter>37class _LIBCUDACXX_TEMPLATE_VIS move_iterator38{39private:40    _Iter __i;41public:42    typedef _Iter                                            iterator_type;43    typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;44    typedef typename iterator_traits<iterator_type>::value_type value_type;45    typedef typename iterator_traits<iterator_type>::difference_type difference_type;46    typedef iterator_type pointer;47    typedef typename iterator_traits<iterator_type>::reference __reference;48    typedef __conditional_t<49            is_reference<__reference>::value,50            __libcpp_remove_reference_t<__reference>&&,51            __reference52        > reference;53 54    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1455    move_iterator() : __i() {}56    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1457    explicit move_iterator(_Iter __x) : __i(__x) {}58    template <class _Up>59      _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1460      move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {}61    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 _Iter base() const {return __i;}62    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1463    reference operator*() const { return static_cast<reference>(*__i); }64    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1465    pointer  operator->() const { return __i;}66    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1467    move_iterator& operator++() {++__i; return *this;}68    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1469    move_iterator  operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;}70    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1471    move_iterator& operator--() {--__i; return *this;}72    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1473    move_iterator  operator--(int) {move_iterator __tmp(*this); --__i; return __tmp;}74    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1475    move_iterator  operator+ (difference_type __n) const {return move_iterator(__i + __n);}76    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1477    move_iterator& operator+=(difference_type __n) {__i += __n; return *this;}78    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1479    move_iterator  operator- (difference_type __n) const {return move_iterator(__i - __n);}80    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1481    move_iterator& operator-=(difference_type __n) {__i -= __n; return *this;}82    _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1483    reference operator[](difference_type __n) const { return _CUDA_VSTD::move(__i[__n]); }84};85 86template <class _Iter1, class _Iter2>87inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1488bool89operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)90{91    return __x.base() == __y.base();92}93 94template <class _Iter1, class _Iter2>95inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX1496bool97operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)98{99    return __x.base() < __y.base();100}101 102template <class _Iter1, class _Iter2>103inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14104bool105operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)106{107    return __x.base() != __y.base();108}109 110template <class _Iter1, class _Iter2>111inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14112bool113operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)114{115    return __x.base() > __y.base();116}117 118template <class _Iter1, class _Iter2>119inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14120bool121operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)122{123    return __x.base() >= __y.base();124}125 126template <class _Iter1, class _Iter2>127inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14128bool129operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)130{131    return __x.base() <= __y.base();132}133 134template <class _Iter1, class _Iter2>135inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14136auto137operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)138-> decltype(__x.base() - __y.base())139{140    return __x.base() - __y.base();141}142 143template <class _Iter>144inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14145move_iterator<_Iter>146operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x)147{148    return move_iterator<_Iter>(__x.base() + __n);149}150 151template <class _Iter>152inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14153move_iterator<_Iter>154make_move_iterator(_Iter __i)155{156    return move_iterator<_Iter>(__i);157}158 159_LIBCUDACXX_END_NAMESPACE_STD160 161#endif // _LIBCUDACXX___ITERATOR_MOVE_ITERATOR_H162 
codekingpro/portable-devtools · Team Ai