You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by uw...@apache.org on 2019/04/22 20:20:27 UTC

[arrow] branch master updated: ARROW-5167: [C++] Upgrade string-view-light to latest

This is an automated email from the ASF dual-hosted git repository.

uwe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 85db347  ARROW-5167: [C++] Upgrade string-view-light to latest
85db347 is described below

commit 85db347db08a851a6fe482ef277c969531da58e3
Author: Antoine Pitrou <an...@python.org>
AuthorDate: Mon Apr 22 22:20:05 2019 +0200

    ARROW-5167: [C++] Upgrade string-view-light to latest
    
    Author: Antoine Pitrou <an...@python.org>
    
    Closes #4182 from pitrou/ARROW-5167-string-view-latest and squashes the following commits:
    
    1e59cb82 <Antoine Pitrou> ARROW-5167:  Upgrade string-view-light to latest
---
 cpp/src/arrow/vendored/string_view.hpp | 76 +++++++++++++++++++++++++---------
 1 file changed, 57 insertions(+), 19 deletions(-)

diff --git a/cpp/src/arrow/vendored/string_view.hpp b/cpp/src/arrow/vendored/string_view.hpp
index 1647c93..d912ee8 100644
--- a/cpp/src/arrow/vendored/string_view.hpp
+++ b/cpp/src/arrow/vendored/string_view.hpp
@@ -1,11 +1,11 @@
-// Vendored from git tag 54a90f61ccb08dbd9870d24f735ded0daa659341
+// Vendored from git tag 062acda5e35c8922dbbccf81300a58edea521b45
 
-// Copyright 2017-2018 by Martin Moene
+// Copyright 2017-2019 by Martin Moene
 //
 // string-view lite, a C++17-like string_view for C++98 and later.
 // For more information see https://github.com/martinmoene/string-view-lite
 //
-// Distributed under the Boost Software License, Version 1.0. 
+// Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 #pragma once
@@ -57,6 +57,16 @@
 # define nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS  1
 #endif
 
+// Control presence of exception handling (try and auto discover):
+
+#ifndef nssv_CONFIG_NO_EXCEPTIONS
+# if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)
+#  define nssv_CONFIG_NO_EXCEPTIONS  0
+# else
+#  define nssv_CONFIG_NO_EXCEPTIONS  1
+# endif
+#endif
+
 // C++ language version detection (C++20 is speculative):
 // Note: VC14.0/1900 (VS2015) lacks too much from C++14.
 
@@ -210,7 +220,7 @@ using std::operator<<;
 # define nssv_COMPILER_MSVC_VERSION  0
 #endif
 
-#define nssv_COMPILER_VERSION( major, minor, patch )  (10 * ( 10 * major + minor) + patch)
+#define nssv_COMPILER_VERSION( major, minor, patch )  ( 10 * ( 10 * (major) + (minor) ) + (patch) )
 
 #if defined(__clang__)
 # define nssv_COMPILER_CLANG_VERSION  nssv_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
@@ -265,8 +275,10 @@ using std::operator<<;
 #define nssv_HAVE_WCHAR16_T             nssv_CPP11_100
 #define nssv_HAVE_WCHAR32_T             nssv_CPP11_100
 
-#if ! ( ( nssv_CPP11 && nssv_COMPILER_CLANG_VERSION ) || nssv_BETWEEN( nssv_COMPILER_CLANG_VERSION, 300, 400 ) )
+#if ! ( ( nssv_CPP11_OR_GREATER && nssv_COMPILER_CLANG_VERSION ) || nssv_BETWEEN( nssv_COMPILER_CLANG_VERSION, 300, 400 ) )
 # define nssv_HAVE_STD_DEFINED_LITERALS  nssv_CPP11_140
+#else
+# define nssv_HAVE_STD_DEFINED_LITERALS  0
 #endif
 
 // Presence of C++14 language features:
@@ -340,9 +352,12 @@ using std::operator<<;
 #include <iterator>
 #include <limits>
 #include <ostream>
-#include <stdexcept>
 #include <string>   // std::char_traits<>
 
+#if ! nssv_CONFIG_NO_EXCEPTIONS
+# include <stdexcept>
+#endif
+
 #if nssv_CPP11_OR_GREATER
 # include <type_traits>
 #endif
@@ -444,12 +459,12 @@ public:
     {}
 #endif
 
-    nssv_constexpr basic_string_view( CharT const * s, size_type count )
+    nssv_constexpr basic_string_view( CharT const * s, size_type count ) nssv_noexcept // non-standard noexcept
         : data_( s )
         , size_( count )
     {}
 
-    nssv_constexpr basic_string_view( CharT const * s)
+    nssv_constexpr basic_string_view( CharT const * s) nssv_noexcept // non-standard noexcept
         : data_( s )
         , size_( Traits::length(s) )
     {}
@@ -502,12 +517,15 @@ public:
 
     nssv_constexpr14 const_reference at( size_type pos ) const
     {
-        if ( pos < size() )
+#if nssv_CONFIG_NO_EXCEPTIONS
+        assert( pos < size() );
+#else
+        if ( pos >= size() )
         {
-            return data_at( pos );
+            throw std::out_of_range("nonst::string_view::at()");
         }
-
-        throw std::out_of_range("nonst::string_view::at()");
+#endif
+        return data_at( pos );
     }
 
     nssv_constexpr const_reference front() const { return data_at( 0 );          }
@@ -541,9 +559,14 @@ public:
 
     size_type copy( CharT * dest, size_type n, size_type pos = 0 ) const
     {
+#if nssv_CONFIG_NO_EXCEPTIONS
+        assert( pos <= size() );
+#else
         if ( pos > size() )
+        {
             throw std::out_of_range("nonst::string_view::copy()");
-
+        }
+#endif
         const size_type rlen = (std::min)( n, size() - pos );
 
         (void) Traits::copy( dest, data() + pos, rlen );
@@ -553,9 +576,14 @@ public:
 
     nssv_constexpr14 basic_string_view substr( size_type pos = 0, size_type n = npos ) const
     {
+#if nssv_CONFIG_NO_EXCEPTIONS
+        assert( pos <= size() );
+#else
         if ( pos > size() )
+        {
             throw std::out_of_range("nonst::string_view::substr()");
-
+        }
+#endif
         return basic_string_view( data() + pos, (std::min)( n, size() - pos ) );
     }
 
@@ -564,7 +592,9 @@ public:
     nssv_constexpr14 int compare( basic_string_view other ) const nssv_noexcept // (1)
     {
         if ( const int result = Traits::compare( data(), other.data(), (std::min)( size(), other.size() ) ) )
+        {
             return result;
+        }
 
         return size() == other.size() ? 0 : size() < other.size() ? -1 : 1;
     }
@@ -660,10 +690,14 @@ public:
     nssv_constexpr14 size_type rfind( basic_string_view v, size_type pos = npos ) const nssv_noexcept  // (1)
     {
         if ( size() < v.size() )
+        {
             return npos;
+        }
 
         if ( v.empty() )
+        {
             return (std::min)( size(), pos );
+        }
 
         const_iterator last   = cbegin() + (std::min)( size() - v.size(), pos ) + v.size();
         const_iterator result = std::find_end( cbegin(), last, v.cbegin(), v.cend(), Traits::eq );
@@ -714,7 +748,9 @@ public:
 
     nssv_constexpr size_type find_last_of( basic_string_view v, size_type pos = npos ) const nssv_noexcept  // (1)
     {
-        return pos >= size()
+        return empty()
+            ? npos
+            : pos >= size()
             ? find_last_of( v, size() - 1 )
             : to_pos( std::find_first_of( const_reverse_iterator( cbegin() + pos + 1 ), crend(), v.cbegin(), v.cend(), Traits::eq ) );
     }
@@ -762,7 +798,9 @@ public:
 
     nssv_constexpr size_type find_last_not_of( basic_string_view v, size_type pos = npos ) const nssv_noexcept  // (1)
     {
-        return pos >= size()
+        return empty()
+            ? npos
+            : pos >= size()
             ? find_last_not_of( v, size() - 1 )
             : to_pos( std::find_if( const_reverse_iterator( cbegin() + pos + 1 ), crend(), not_in_view( v ) ) );
     }
@@ -797,7 +835,7 @@ private:
     {
         const basic_string_view v;
 
-        nssv_constexpr not_in_view( basic_string_view v ) : v( v ) {}
+        nssv_constexpr explicit not_in_view( basic_string_view v ) : v( v ) {}
 
         nssv_constexpr bool operator()( CharT c ) const
         {
@@ -946,7 +984,7 @@ template< class CharT, class Traits  nssv_MSVC_ORDER(2) >
 nssv_constexpr bool operator==(
     nssv_BASIC_STRING_VIEW_I(CharT, Traits) lhs,
          basic_string_view  <CharT, Traits> rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) == 0; }
+{ return lhs.size() == rhs.size() && lhs.compare( rhs ) == 0; }
 
 // !=
 
@@ -954,7 +992,7 @@ template< class CharT, class Traits  nssv_MSVC_ORDER(1) >
 nssv_constexpr bool operator!= (
          basic_string_view  < CharT, Traits > lhs,
     nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) != 0 ; }
+{ return lhs.size() != rhs.size() || lhs.compare( rhs ) != 0 ; }
 
 template< class CharT, class Traits  nssv_MSVC_ORDER(2) >
 nssv_constexpr bool operator!= (