- Range(const Range& other,
- size_type first,
- size_type length = npos)
- : Range(other.subpiece(first, length))
- { }
-
- template <class T = Iter, typename detail::IsCharPointer<T>::const_type = 0>
- /* implicit */ Range(const fbstring& str)
- : b_(str.data()), e_(b_ + str.size()) { }
-
- template <class T = Iter, typename detail::IsCharPointer<T>::const_type = 0>
- Range(const fbstring& str, fbstring::size_type startFrom) {
- if (UNLIKELY(startFrom > str.size())) {
- throw std::out_of_range("index out of range");
+ Range(const Range& other, size_type first, size_type length = npos)
+ : Range(other.subpiece(first, length)) {}
+
+ template <
+ class Container,
+ class = typename std::enable_if<
+ std::is_same<Iter, typename Container::const_pointer>::value>::type,
+ class = decltype(
+ Iter(std::declval<Container const&>().data()),
+ Iter(
+ std::declval<Container const&>().data() +
+ std::declval<Container const&>().size()))>
+ /* implicit */ constexpr Range(Container const& container)
+ : b_(container.data()), e_(b_ + container.size()) {}
+
+ template <
+ class Container,
+ class = typename std::enable_if<
+ std::is_same<Iter, typename Container::const_pointer>::value>::type,
+ class = decltype(
+ Iter(std::declval<Container const&>().data()),
+ Iter(
+ std::declval<Container const&>().data() +
+ std::declval<Container const&>().size()))>
+ Range(Container const& container, typename Container::size_type startFrom) {
+ auto const cdata = container.data();
+ auto const csize = container.size();
+ if (UNLIKELY(startFrom > csize)) {
+ std::__throw_out_of_range("index out of range");