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()) {
}
#include <folly/Range.h>
+#include <sys/mman.h>
#include <array>
-#include <boost/range/concepts.hpp>
#include <cstdlib>
-#include <gtest/gtest.h>
#include <iterator>
#include <limits>
#include <random>
#include <string>
-#include <sys/mman.h>
+#include <type_traits>
#include <vector>
+#include <boost/range/concepts.hpp>
+#include <gtest/gtest.h>
namespace folly { namespace detail {
using namespace folly;
using namespace std;
+static_assert(std::is_literal_type<StringPiece>::value, "");
+
BOOST_CONCEPT_ASSERT((boost::RandomAccessRangeConcept<StringPiece>));
TEST(StringPiece, All) {