Преглед на файлове

refactor: add missing SFINAE functions

Sam Jaffe преди 2 години
родител
ревизия
b6cb3cf689
променени са 2 файла, в които са добавени 8 реда и са изтрити 3 реда
  1. 5 3
      include/stream/view/iota.h
  2. 3 0
      include/stream/view/join.h

+ 5 - 3
include/stream/view/iota.h

@@ -11,6 +11,8 @@
 
 #include <stream/iterator/iota_iterator.h>
 
+#include <stream/detail/macro.h>
+
 namespace stream::ranges {
 template <typename T, typename Bound> struct iota_view {
 public:
@@ -33,9 +35,7 @@ public:
   }
 
   bool empty() const { return begin().at_end(); }
-  auto size() const -> std::enable_if_t<has_size_v, size_t> {
-    return begin().distance_to(end());
-  }
+  SFINAE(has_size_v, size_t) size() const { return begin().distance_to(end()); }
 };
 }
 
@@ -46,3 +46,5 @@ template <typename T, typename Bound> auto iota(T value, Bound bound) {
 }
 
 MAKE_ITERATOR_FACADE_TYPEDEFS_T(stream::ranges::iota_iterator);
+
+#include <stream/detail/undef.h>

+ 3 - 0
include/stream/view/join.h

@@ -4,6 +4,8 @@
 
 #include <stream/forward.h>
 
+#include <stream/detail/traits.h>
+
 #include <stream/detail/macro.h>
 
 namespace stream::ranges {
@@ -16,6 +18,7 @@ public:
 
   auto begin() const { return iterator::joining_iterator(stream_); }
   auto end() const { return iterator::sentinel; }
+  SFINAE(detail::has_empty_v<S>, bool) empty() const { return stream_.empty(); }
 };
 
 template <typename S> join_view(S &&) -> join_view<S>;