static const size_type npos;
// Works for all iterators
- Range() : b_(), e_() {
+ constexpr Range() : b_(), e_() {
}
public:
// Works for all iterators
- Range(Iter start, Iter end) : b_(start), e_(end) {
+ constexpr Range(Iter start, Iter end) : b_(start), e_(end) {
}
// Works only for random-access iterators
- Range(Iter start, size_t size)
+ constexpr Range(Iter start, size_t size)
: b_(start), e_(start + size) { }
#if FOLLY_HAVE_CONSTEXPR_STRLEN
// Works only for Range<const char*>
- /* implicit */ constexpr Range(Iter str)
+ constexpr /* implicit */ Range(Iter str)
: b_(str), e_(str + strlen(str)) {}
#else
// Works only for Range<const char*>
template <class OtherIter, typename std::enable_if<
(!std::is_same<Iter, OtherIter>::value &&
std::is_convertible<OtherIter, Iter>::value), int>::type = 0>
- /* implicit */ Range(const Range<OtherIter>& other)
+ constexpr /* implicit */ Range(const Range<OtherIter>& other)
: b_(other.begin()),
e_(other.end()) {
}
(!std::is_same<Iter, OtherIter>::value &&
!std::is_convertible<OtherIter, Iter>::value &&
std::is_constructible<Iter, const OtherIter&>::value), int>::type = 0>
- explicit Range(const Range<OtherIter>& other)
+ constexpr explicit Range(const Range<OtherIter>& other)
: b_(other.begin()),
e_(other.end()) {
}
typedef Range<const unsigned char*> ByteRange;
typedef Range<unsigned char*> MutableByteRange;
-std::ostream& operator<<(std::ostream& os, const StringPiece& piece);
+std::ostream& operator<<(std::ostream& os, const StringPiece piece);
+std::ostream& operator<<(std::ostream& os, const MutableStringPiece piece);
/**
* Templated comparison operators
}
struct StringPieceHash {
- std::size_t operator()(const StringPiece& str) const {
+ std::size_t operator()(const StringPiece str) const {
return static_cast<std::size_t>(str.hash());
}
};
namespace detail {
-size_t qfind_first_byte_of_nosse(const StringPiece& haystack,
- const StringPiece& needles);
+size_t qfind_first_byte_of_nosse(const StringPiece haystack,
+ const StringPiece needles);
#if FOLLY_HAVE_EMMINTRIN_H && __GNUC_PREREQ(4, 6)
-size_t qfind_first_byte_of_sse42(const StringPiece& haystack,
- const StringPiece& needles);
+size_t qfind_first_byte_of_sse42(const StringPiece haystack,
+ const StringPiece needles);
-inline size_t qfind_first_byte_of(const StringPiece& haystack,
- const StringPiece& needles) {
+inline size_t qfind_first_byte_of(const StringPiece haystack,
+ const StringPiece needles) {
static auto const qfind_first_byte_of_fn =
folly::CpuId().sse42() ? qfind_first_byte_of_sse42
: qfind_first_byte_of_nosse;
}
#else
-inline size_t qfind_first_byte_of(const StringPiece& haystack,
- const StringPiece& needles) {
+inline size_t qfind_first_byte_of(const StringPiece haystack,
+ const StringPiece needles) {
return qfind_first_byte_of_nosse(haystack, needles);
}
#endif // FOLLY_HAVE_EMMINTRIN_H