Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
istreambuf_iterator.h109 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//9//===----------------------------------------------------------------------===//10 11#ifndef _LIBCUDACXX___ITERATOR_ISTREAMBUF_ITERATOR_H12#define _LIBCUDACXX___ITERATOR_ISTREAMBUF_ITERATOR_H13 14#ifndef __cuda_std__15#include <__config>16#endif //__cuda_std__17 18#include "../__iterator/iterator.h"19#include "../__iterator/iterator_traits.h"20#include "../iosfwd"21 22#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)23#  pragma GCC system_header24#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)25#  pragma clang system_header26#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)27#  pragma system_header28#endif // no system header29 30_LIBCUDACXX_BEGIN_NAMESPACE_STD31 32_LIBCUDACXX_SUPPRESS_DEPRECATED_PUSH33template<class _CharT, class _Traits>34class _LIBCUDACXX_TEMPLATE_VIS istreambuf_iterator35#if _LIBCUDACXX_STD_VER <= 14 || !defined(_LIBCUDACXX_ABI_NO_ITERATOR_BASES)36    : public iterator<input_iterator_tag, _CharT,37                      typename _Traits::off_type, _CharT*,38                      _CharT>39#endif40{41_LIBCUDACXX_SUPPRESS_DEPRECATED_POP42public:43    typedef _CharT                          char_type;44    typedef _Traits                         traits_type;45    typedef typename _Traits::int_type      int_type;46    typedef basic_streambuf<_CharT,_Traits> streambuf_type;47    typedef basic_istream<_CharT,_Traits>   istream_type;48private:49    mutable streambuf_type* __sbuf_;50 51    class __proxy52    {53        char_type __keep_;54        streambuf_type* __sbuf_;55        _LIBCUDACXX_INLINE_VISIBILITY __proxy(char_type __c, streambuf_type* __s)56            : __keep_(__c), __sbuf_(__s) {}57        friend class istreambuf_iterator;58    public:59        _LIBCUDACXX_INLINE_VISIBILITY char_type operator*() const {return __keep_;}60    };61 62    _LIBCUDACXX_INLINE_VISIBILITY63    bool __test_for_eof() const64    {65        if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof()))66            __sbuf_ = 0;67        return __sbuf_ == 0;68    }69public:70    _LIBCUDACXX_INLINE_VISIBILITY constexpr istreambuf_iterator() noexcept : __sbuf_(0) {}71    _LIBCUDACXX_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) noexcept72        : __sbuf_(__s.rdbuf()) {}73    _LIBCUDACXX_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) noexcept74        : __sbuf_(__s) {}75    _LIBCUDACXX_INLINE_VISIBILITY istreambuf_iterator(const __proxy& __p) noexcept76        : __sbuf_(__p.__sbuf_) {}77 78    _LIBCUDACXX_INLINE_VISIBILITY char_type  operator*() const79        {return static_cast<char_type>(__sbuf_->sgetc());}80    _LIBCUDACXX_INLINE_VISIBILITY istreambuf_iterator& operator++()81        {82            __sbuf_->sbumpc();83            return *this;84        }85    _LIBCUDACXX_INLINE_VISIBILITY __proxy              operator++(int)86        {87            return __proxy(__sbuf_->sbumpc(), __sbuf_);88        }89 90    _LIBCUDACXX_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const91        {return __test_for_eof() == __b.__test_for_eof();}92};93 94template <class _CharT, class _Traits>95inline _LIBCUDACXX_INLINE_VISIBILITY96bool operator==(const istreambuf_iterator<_CharT,_Traits>& __a,97                const istreambuf_iterator<_CharT,_Traits>& __b)98                {return __a.equal(__b);}99 100template <class _CharT, class _Traits>101inline _LIBCUDACXX_INLINE_VISIBILITY102bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a,103                const istreambuf_iterator<_CharT,_Traits>& __b)104                {return !__a.equal(__b);}105 106_LIBCUDACXX_END_NAMESPACE_STD107 108#endif // _LIBCUDACXX___ITERATOR_ISTREAMBUF_ITERATOR_H109 
codekingpro/portable-devtools · Team Ai