fpos.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifndef _LIBCPP___IOS_FPOS_H
  10. #define _LIBCPP___IOS_FPOS_H
  11. #include <__config>
  12. #include <__fwd/ios.h>
  13. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  14. # pragma GCC system_header
  15. #endif
  16. _LIBCPP_BEGIN_NAMESPACE_STD
  17. template <class _StateT>
  18. class _LIBCPP_TEMPLATE_VIS fpos {
  19. private:
  20. _StateT __st_;
  21. streamoff __off_;
  22. public:
  23. _LIBCPP_HIDE_FROM_ABI fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {}
  24. _LIBCPP_HIDE_FROM_ABI operator streamoff() const { return __off_; }
  25. _LIBCPP_HIDE_FROM_ABI _StateT state() const { return __st_; }
  26. _LIBCPP_HIDE_FROM_ABI void state(_StateT __st) { __st_ = __st; }
  27. _LIBCPP_HIDE_FROM_ABI fpos& operator+=(streamoff __off) {
  28. __off_ += __off;
  29. return *this;
  30. }
  31. _LIBCPP_HIDE_FROM_ABI fpos operator+(streamoff __off) const {
  32. fpos __t(*this);
  33. __t += __off;
  34. return __t;
  35. }
  36. _LIBCPP_HIDE_FROM_ABI fpos& operator-=(streamoff __off) {
  37. __off_ -= __off;
  38. return *this;
  39. }
  40. _LIBCPP_HIDE_FROM_ABI fpos operator-(streamoff __off) const {
  41. fpos __t(*this);
  42. __t -= __off;
  43. return __t;
  44. }
  45. };
  46. template <class _StateT>
  47. inline _LIBCPP_HIDE_FROM_ABI streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {
  48. return streamoff(__x) - streamoff(__y);
  49. }
  50. template <class _StateT>
  51. inline _LIBCPP_HIDE_FROM_ABI bool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {
  52. return streamoff(__x) == streamoff(__y);
  53. }
  54. template <class _StateT>
  55. inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {
  56. return streamoff(__x) != streamoff(__y);
  57. }
  58. _LIBCPP_END_NAMESPACE_STD
  59. #endif // _LIBCPP___IOS_FPOS_H