about summary refs log tree commit diff
path: root/absl/strings/internal
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2018-06-26T17·45-0700
committerAlex Strelnikov <strel@google.com>2018-06-26T17·49-0400
commit7efd8dc0f1075356e9c7caa950afd1ecf854e8b9 (patch)
tree71d6d8052d98170726835a682463876bcb33f51a /absl/strings/internal
parent87a4c07856e7dc69958019d47b2f02ae47746ec0 (diff)
Export of internal Abseil changes.
--
6bab63b2bcdbd768743c2ebcc4a8e19af20c5406 by Abseil Team <absl-team@google.com>:

Reformats inlined_vector.h to match the current Google lint rules

PiperOrigin-RevId: 202154101

--
00cdeda6ea24591a9cb8ac8b3c2e2a042e1b15b1 by Gennadiy Rozental <rogeeff@google.com>:

Improve SplitterIsConvertibleTo implementation.

PiperOrigin-RevId: 202095009

--
7c24071afac45a17c47e819896f844a36e239bda by Greg Falcon <gfalcon@google.com>:

Internal change

PiperOrigin-RevId: 201991288
GitOrigin-RevId: 6bab63b2bcdbd768743c2ebcc4a8e19af20c5406
Change-Id: Ic5a988ab39e78247285411f36287cd34d6f5afd3
Diffstat (limited to 'absl/strings/internal')
-rw-r--r--absl/strings/internal/str_split_internal.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/absl/strings/internal/str_split_internal.h b/absl/strings/internal/str_split_internal.h
index a1b10f3addcf..9cf0833f4902 100644
--- a/absl/strings/internal/str_split_internal.h
+++ b/absl/strings/internal/str_split_internal.h
@@ -228,14 +228,31 @@ struct IsInitializerList
 // compiled in C++11 will get an error due to ambiguous conversion paths (in
 // C++11 std::vector<T>::operator= is overloaded to take either a std::vector<T>
 // or an std::initializer_list<T>).
+
+template <typename C, bool has_value_type, bool has_mapped_type>
+struct SplitterIsConvertibleToImpl : std::false_type {};
+
+template <typename C>
+struct SplitterIsConvertibleToImpl<C, true, false>
+    : std::is_constructible<typename C::value_type, absl::string_view> {};
+
+template <typename C>
+struct SplitterIsConvertibleToImpl<C, true, true>
+    : absl::conjunction<
+          std::is_constructible<typename C::key_type, absl::string_view>,
+          std::is_constructible<typename C::mapped_type, absl::string_view>> {};
+
 template <typename C>
 struct SplitterIsConvertibleTo
-    : std::enable_if<
+    : SplitterIsConvertibleToImpl<
+          C,
 #ifdef _GLIBCXX_DEBUG
           !IsStrictlyBaseOfAndConvertibleToSTLContainer<C>::value &&
 #endif  // _GLIBCXX_DEBUG
-          !IsInitializerList<C>::value && HasValueType<C>::value &&
-          HasConstIterator<C>::value> {
+              !IsInitializerList<
+                  typename std::remove_reference<C>::type>::value &&
+              HasValueType<C>::value && HasConstIterator<C>::value,
+          HasMappedType<C>::value> {
 };
 
 // This class implements the range that is returned by absl::StrSplit(). This
@@ -281,7 +298,8 @@ class Splitter {
   // An implicit conversion operator that is restricted to only those containers
   // that the splitter is convertible to.
   template <typename Container,
-            typename OnlyIf = typename SplitterIsConvertibleTo<Container>::type>
+            typename = typename std::enable_if<
+                SplitterIsConvertibleTo<Container>::value>::type>
   operator Container() const {  // NOLINT(runtime/explicit)
     return ConvertToContainer<Container, typename Container::value_type,
                               HasMappedType<Container>::value>()(*this);