From owner-svn-src-vendor@freebsd.org Sun Dec 24 01:00:47 2017 Return-Path: Delivered-To: svn-src-vendor@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F2963E88329; Sun, 24 Dec 2017 01:00:46 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5985E7ECB3; Sun, 24 Dec 2017 01:00:44 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBO10hKF074918; Sun, 24 Dec 2017 01:00:43 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBO10hL2074913; Sun, 24 Dec 2017 01:00:43 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201712240100.vBO10hL2074913@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 24 Dec 2017 01:00:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r327128 - in vendor/libc++/dist: include test/std/input.output/string.streams/stringbuf/stringbuf.virtuals test/std/strings/string.view X-SVN-Group: vendor X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in vendor/libc++/dist: include test/std/input.output/string.streams/stringbuf/stringbuf.virtuals test/std/strings/string.view X-SVN-Commit-Revision: 327128 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Dec 2017 01:00:47 -0000 Author: dim Date: Sun Dec 24 01:00:43 2017 New Revision: 327128 URL: https://svnweb.freebsd.org/changeset/base/327128 Log: Vendor import of libc++ trunk r321414: https://llvm.org/svn/llvm-project/libcxx/trunk@321414 Added: vendor/libc++/dist/test/std/strings/string.view/types.pass.cpp (contents, props changed) Modified: vendor/libc++/dist/include/sstream vendor/libc++/dist/include/string_view vendor/libc++/dist/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp Modified: vendor/libc++/dist/include/sstream ============================================================================== --- vendor/libc++/dist/include/sstream Sun Dec 24 01:00:40 2017 (r327127) +++ vendor/libc++/dist/include/sstream Sun Dec 24 01:00:43 2017 (r327128) @@ -577,6 +577,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff( if ((__wch & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out) && __way == ios_base::cur) return pos_type(-1); + const ptrdiff_t __hm = __hm_ == nullptr ? 0 : __hm_ - __str_.data(); off_type __noff; switch (__way) { @@ -590,13 +591,13 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff( __noff = this->pptr() - this->pbase(); break; case ios_base::end: - __noff = __hm_ - __str_.data(); + __noff = __hm; break; default: return pos_type(-1); } __noff += __off; - if (__noff < 0 || __hm_ - __str_.data() < __noff) + if (__noff < 0 || __hm < __noff) return pos_type(-1); if (__noff != 0) { Modified: vendor/libc++/dist/include/string_view ============================================================================== --- vendor/libc++/dist/include/string_view Sun Dec 24 01:00:40 2017 (r327127) +++ vendor/libc++/dist/include/string_view Sun Dec 24 01:00:43 2017 (r327128) @@ -196,9 +196,9 @@ class _LIBCPP_TEMPLATE_VIS basic_string_view { (public // types typedef _Traits traits_type; typedef _CharT value_type; - typedef const _CharT* pointer; + typedef _CharT* pointer; typedef const _CharT* const_pointer; - typedef const _CharT& reference; + typedef _CharT& reference; typedef const _CharT& const_reference; typedef const_pointer const_iterator; // See [string.view.iterators] typedef const_iterator iterator; Modified: vendor/libc++/dist/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp ============================================================================== --- vendor/libc++/dist/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp Sun Dec 24 01:00:40 2017 (r327127) +++ vendor/libc++/dist/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp Sun Dec 24 01:00:43 2017 (r327128) @@ -21,6 +21,30 @@ int main() { { + std::stringbuf sb(std::ios_base::in); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekoff(0, std::ios_base::beg, std::ios_base::in) == 0); + assert(sb.pubseekoff(0, std::ios_base::cur, std::ios_base::in) == 0); + assert(sb.pubseekoff(0, std::ios_base::end, std::ios_base::in) == 0); + } + { + std::stringbuf sb(std::ios_base::out); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1); + assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1); + assert(sb.pubseekoff(0, std::ios_base::beg, std::ios_base::out) == 0); + assert(sb.pubseekoff(0, std::ios_base::cur, std::ios_base::out) == 0); + assert(sb.pubseekoff(0, std::ios_base::end, std::ios_base::out) == 0); + } + { std::stringbuf sb("0123456789", std::ios_base::in); assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1); assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1); Added: vendor/libc++/dist/test/std/strings/string.view/types.pass.cpp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/libc++/dist/test/std/strings/string.view/types.pass.cpp Sun Dec 24 01:00:43 2017 (r327128) @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// Test nested types and default template args: + +// template> +// { +// public: +// // types: +// using traits_type = traits; +// using value_type = charT; +// using pointer = value_type*; +// using const_pointer = const value_type*; +// using reference = value_type&; +// using const_reference = const value_type&; +// using const_iterator = implementation-defined ; // see 24.4.2.2 +// using iterator = const_iterator; +// using const_reverse_iterator = reverse_iterator; +// using iterator = const_reverse_iterator; +// using size_type = size_t; +// using difference_type = ptrdiff_t; +// static constexpr size_type npos = size_type(-1); +// +// }; + +#include +#include +#include + +#include "test_macros.h" + +template +void +test() +{ + typedef std::basic_string_view S; + + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same< + typename std::iterator_traits::iterator_category, + std::random_access_iterator_tag>::value), ""); + static_assert((std::is_same< + typename std::iterator_traits::iterator_category, + std::random_access_iterator_tag>::value), ""); + static_assert((std::is_same< + typename S::reverse_iterator, + std::reverse_iterator >::value), ""); + static_assert((std::is_same< + typename S::const_reverse_iterator, + std::reverse_iterator >::value), ""); + static_assert(S::npos == -1, ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +} + +int main() +{ + test >(); + test >(); + static_assert((std::is_same::traits_type, + std::char_traits >::value), ""); +}