X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FRange.h;h=228a8d5535c213194b579ccda1e1144b16e7e45b;hb=153c4233eff35be3bd9728c969bd22f59ac6051b;hp=6a8161d251fd27eed2f9bb62079428fb920a4588;hpb=f2925b23df8d85ebca72d62a69f1282528c086de;p=folly.git diff --git a/folly/Range.h b/folly/Range.h index 6a8161d2..228a8d55 100644 --- a/folly/Range.h +++ b/folly/Range.h @@ -1012,22 +1012,43 @@ constexpr Range range(Iter first, Iter last) { * Creates a range to reference the contents of a contiguous-storage container. */ // Use pointers for types with '.data()' member -template < - class Collection, - class T = typename std::remove_pointer< - decltype(std::declval().data())>::type> -constexpr Range range(Collection&& v) { - return Range(v.data(), v.data() + v.size()); +template +constexpr auto range(Collection& v) -> Range { + return Range(v.data(), v.data() + v.size()); +} +template +constexpr auto range(Collection const& v) -> Range { + return Range(v.data(), v.data() + v.size()); +} +template +constexpr auto crange(Collection const& v) -> Range { + return Range(v.data(), v.data() + v.size()); } template constexpr Range range(T (&array)[n]) { return Range(array, array + n); } +template +constexpr Range range(T const (&array)[n]) { + return Range(array, array + n); +} +template +constexpr Range crange(T const (&array)[n]) { + return Range(array, array + n); +} template -constexpr Range range(const std::array& array) { - return Range{array}; +constexpr Range range(std::array& array) { + return Range{array}; +} +template +constexpr Range range(std::array const& array) { + return Range{array}; +} +template +constexpr Range crange(std::array const& array) { + return Range{array}; } typedef Range StringPiece;