Index: include/string =================================================================== --- include/string +++ include/string @@ -22,7 +22,8 @@ private: stateT st; public: - fpos(streamoff = streamoff()); + fpos(); + fpos(streamoff); operator streamoff() const; @@ -33,12 +34,11 @@ fpos operator+ (streamoff) const; fpos& operator-=(streamoff); fpos operator- (streamoff) const; -}; - -template streamoff operator-(const fpos& x, const fpos& y); -template bool operator==(const fpos& x, const fpos& y); -template bool operator!=(const fpos& x, const fpos& y); + streamoff operator-(fpos) const; + fpos& operator=(fpos); + bool operator!=(fpos&); +}; template struct char_traits @@ -540,28 +540,29 @@ _StateT __st_; streamoff __off_; public: - _LIBCPP_INLINE_VISIBILITY fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {} + _LIBCPP_INLINE_VISIBILITY fpos() : __st_(), __off_(0 ) {} + _LIBCPP_INLINE_VISIBILITY fpos(streamoff __off) : __st_(), __off_(__off) {} _LIBCPP_INLINE_VISIBILITY operator streamoff() const {return __off_;} _LIBCPP_INLINE_VISIBILITY _StateT state() const {return __st_;} _LIBCPP_INLINE_VISIBILITY void state(_StateT __st) {__st_ = __st;} - _LIBCPP_INLINE_VISIBILITY fpos& operator+=(streamoff __off) {__off_ += __off; return *this;} - _LIBCPP_INLINE_VISIBILITY fpos operator+ (streamoff __off) const {fpos __t(*this); __t += __off; return __t;} - _LIBCPP_INLINE_VISIBILITY fpos& operator-=(streamoff __off) {__off_ -= __off; return *this;} - _LIBCPP_INLINE_VISIBILITY fpos operator- (streamoff __off) const {fpos __t(*this); __t -= __off; return __t;} -}; + _LIBCPP_INLINE_VISIBILITY fpos& operator+=(streamoff __off) + {__off_ += __off; return *this;} +// _LIBCPP_INLINE_VISIBILITY fpos operator+ (streamoff __off) const +// {return __off + __off_;} + _LIBCPP_INLINE_VISIBILITY fpos& operator-=(streamoff __off) + {__off_ -= __off; return *this;} +// _LIBCPP_INLINE_VISIBILITY fpos operator- (streamoff __off) const +// {return __off_ - __off;} -template -inline _LIBCPP_INLINE_VISIBILITY -streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) - {return streamoff(__x) - streamoff(__y);} +// _LIBCPP_INLINE_VISIBILITY streamoff operator-(fpos __rhs) const +// {return __off_ - __rhs.__off_;} -template -inline _LIBCPP_INLINE_VISIBILITY -bool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y) - {return streamoff(__x) == streamoff(__y);} + _LIBCPP_INLINE_VISIBILITY void operator= (streamoff __off) {_VSTD::swap(__off, __off_);} + _LIBCPP_INLINE_VISIBILITY bool operator!= (fpos& __rhs) {return __rhs.__off_ != __off_;} +}; template inline _LIBCPP_INLINE_VISIBILITY @@ -627,13 +628,13 @@ #else template ::value> struct __libcpp_string_gets_noexcept_iterator_impl : public _LIBCPP_BOOL_CONSTANT(( - noexcept(++(declval<_Iter&>())) && - is_nothrow_assignable<_Iter&, _Iter>::value && - noexcept(declval<_Iter>() == declval<_Iter>()) && + noexcept(++(declval<_Iter&>())) && + is_nothrow_assignable<_Iter&, _Iter>::value && + noexcept(declval<_Iter>() == declval<_Iter>()) && noexcept(*declval<_Iter>()) )) {}; -template +template struct __libcpp_string_gets_noexcept_iterator_impl<_Iter, false> : public false_type {}; #endif @@ -1420,7 +1421,7 @@ _LIBCPP_INLINE_VISIBILITY bool __invariants() const; _LIBCPP_INLINE_VISIBILITY void __clear_and_shrink() _NOEXCEPT; - + _LIBCPP_INLINE_VISIBILITY bool __is_long() const _NOEXCEPT {return bool(__r_.first().__s.__size_ & __short_mask);} @@ -1682,7 +1683,7 @@ -> basic_string<_CharT, _Traits, _Allocator>; #endif - + template inline void @@ -2525,7 +2526,7 @@ const basic_string __temp (__first, __last, __alloc()); append(__temp.data(), __temp.size()); } - else + else { if (__cap - __sz < __n) __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); @@ -3824,7 +3825,7 @@ template inline -void +void basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT { clear(); @@ -3834,7 +3835,7 @@ __set_long_cap(0); __set_short_size(0); } -} +} // operator== @@ -4331,7 +4332,7 @@ _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string) _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string) -#if _LIBCPP_STD_VER > 11 +#if _LIBCPP_STD_VER > 11 // Literal suffixes for basic_string [basic.string.literals] inline namespace literals { Index: test/std/strings/fpos/fpos.pass.cpp =================================================================== --- /dev/null +++ test/std/strings/fpos/fpos.pass.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "test_macros.h" + +#include +#include +#include + +// string +// template +// class fpos +// { +// fpos(); +// fpos(streamoff); +// +// operator streamoff() const; +// +// fpos& operator+=(streamoff); +// fpos operator+ (streamoff) const; +// fpos& operator-=(streamoff); +// fpos operator- (streamoff) const; +// +// streamoff operator-(fpos) const; +// fpos& operator=(fpos); +// bool operator!=(fpos&); +// }; + +int main(int, char**) +{ + ASSERT_SAME_TYPE(std::streampos, std::fpos::state_type>); + + static_assert(std::is_trivially_copy_constructible::value); + static_assert(std::is_trivially_copy_constructible::value); + static_assert(std::is_trivially_destructible ::value); + + std::streampos p0; + assert(std::streamoff(p0) == 0); + + std::streampos p1(1); + assert(std::streamoff(p1) == 1); + + std::streampos p2 = 2; + assert(std::streamoff(p2) == 2); + + assert(p2 != p1); + + assert(std::streamoff(p1 + p2) == 3); + assert(std::streamoff(p2 - p1) == 1); + + p0 += 5; + assert(std::streamoff(p0) == 5); + p0 -= 2; + assert(std::streamoff(p0) == 3); + + assert((p0 + 3) == 6); + assert((p0 - 3) == 0); + + return 0; +} Index: www/cxx2a_status.html =================================================================== --- www/cxx2a_status.html +++ www/cxx2a_status.html @@ -93,7 +93,7 @@ P0646R1LWGImproving the Return Value of Erase-Like AlgorithmsRapperswil P0722R3CWGEfficient sized delete for variable sized classesRapperswil P0758R1LWGImplicit conversion traits and utility functionsRapperswilComplete - P0759R1LWGfpos RequirementsRapperswil + P0759R1LWGfpos RequirementsRapperswilComplete P0769R2LWGAdd shift to <algorithm>Rapperswil P0788R3LWGStandard Library Specification in a Concepts and Contracts WorldRapperswil P0879R0LWGConstexpr for swap and swap related functions Also resolves LWG issue 2800.Rapperswil