Remove template helper constants
[folly.git] / folly / Range.h
index efe34908d17dfb1430eaa0fc31f57c374af8b538..b6e428ea32056ae7ff16042292bde961176f7915 100644 (file)
@@ -69,8 +69,9 @@ template <class Iter> class Range;
  * as Boyer-Moore. On the upside, it does not do any upfront
  * preprocessing and does not allocate memory.
  */
-template <class Iter,
-          class Comp = std::equal_to<typename Range<Iter>::value_type>>
+template <
+    class Iter,
+    class Comp = std::equal_to<typename Range<Iter>::value_type>>
 inline size_t qfind(const Range<Iter> & haystack,
                     const Range<Iter> & needle,
                     Comp eq = Comp());
@@ -163,7 +164,7 @@ struct IsCharPointer<const char*> {
  */
 template <class Iter>
 class Range : private boost::totally_ordered<Range<Iter> > {
-public:
+ public:
   typedef std::size_t size_type;
   typedef Iter iterator;
   typedef Iter const_iterator;
@@ -197,7 +198,7 @@ public:
   constexpr Range(const Range&) = default;
   constexpr Range(Range&&) = default;
 
-public:
+ public:
   // Works for all iterators
   constexpr Range(Iter start, Iter end) : b_(start), e_(end) {
   }
@@ -923,7 +924,7 @@ public:
     -> decltype(process(std::declval<Range>(), std::forward<Args>(args)...))
   { return process(split_step(delimiter), std::forward<Args>(args)...); }
 
-private:
+ private:
   Iter b_, e_;
 };
 
@@ -970,15 +971,19 @@ typedef Range<char*> MutableStringPiece;
 typedef Range<const unsigned char*> ByteRange;
 typedef Range<unsigned char*> MutableByteRange;
 
-inline std::ostream& operator<<(std::ostream& os,
-                                const StringPiece piece) {
-  os.write(piece.start(), std::streamsize(piece.size()));
+template <class C>
+std::basic_ostream<C>& operator<<(
+    std::basic_ostream<C>& os,
+    Range<C const*> piece) {
+  using StreamSize = decltype(os.width());
+  os.write(piece.start(), static_cast<StreamSize>(piece.size()));
   return os;
 }
 
-inline std::ostream& operator<<(std::ostream& os,
-                                const MutableStringPiece piece) {
-  os.write(piece.start(), std::streamsize(piece.size()));
+template <class C>
+std::basic_ostream<C>& operator<<(std::basic_ostream<C>& os, Range<C*> piece) {
+  using StreamSize = decltype(os.width());
+  os.write(piece.start(), static_cast<StreamSize>(piece.size()));
   return os;
 }
 
@@ -1255,7 +1260,7 @@ inline size_t qfind_first_of(const Range<const unsigned char*>& haystack,
                                      StringPiece(needles));
 }
 
-template<class Key, class Enable>
+template <class Key, class Enable>
 struct hasher;
 
 template <class T>