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-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___IOS_FPOS_H
11#define _LIBCPP___IOS_FPOS_H
12
13#include <__config>
14#include <iosfwd>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17#  pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class _StateT>
23class _LIBCPP_TEMPLATE_VIS fpos {
24private:
25  _StateT __st_;
26  streamoff __off_;
27
28public:
29  _LIBCPP_HIDE_FROM_ABI fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {}
30
31  _LIBCPP_HIDE_FROM_ABI operator streamoff() const { return __off_; }
32
33  _LIBCPP_HIDE_FROM_ABI _StateT state() const { return __st_; }
34  _LIBCPP_HIDE_FROM_ABI void state(_StateT __st) { __st_ = __st; }
35
36  _LIBCPP_HIDE_FROM_ABI fpos& operator+=(streamoff __off) {
37    __off_ += __off;
38    return *this;
39  }
40
41  _LIBCPP_HIDE_FROM_ABI fpos operator+(streamoff __off) const {
42    fpos __t(*this);
43    __t += __off;
44    return __t;
45  }
46
47  _LIBCPP_HIDE_FROM_ABI fpos& operator-=(streamoff __off) {
48    __off_ -= __off;
49    return *this;
50  }
51
52  _LIBCPP_HIDE_FROM_ABI fpos operator-(streamoff __off) const {
53    fpos __t(*this);
54    __t -= __off;
55    return __t;
56  }
57};
58
59template <class _StateT>
60inline _LIBCPP_HIDE_FROM_ABI
61streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {
62  return streamoff(__x) - streamoff(__y);
63}
64
65template <class _StateT>
66inline _LIBCPP_HIDE_FROM_ABI
67bool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {
68  return streamoff(__x) == streamoff(__y);
69}
70
71template <class _StateT>
72inline _LIBCPP_HIDE_FROM_ABI
73bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {
74  return streamoff(__x) != streamoff(__y);
75}
76
77_LIBCPP_END_NAMESPACE_STD
78
79#endif // _LIBCPP___IOS_FPOS_H
80