* 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());
*/
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;
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) {
}
-> decltype(process(std::declval<Range>(), std::forward<Args>(args)...))
{ return process(split_step(delimiter), std::forward<Args>(args)...); }
-private:
+ private:
Iter b_, e_;
};
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;
}
StringPiece(needles));
}
-template<class Key, class Enable>
+template <class Key, class Enable>
struct hasher;
template <class T>