onst  requires [ ranges::  range  ](http://en.cppreference.com/w/cpp/ranges/range) < const  R  > ;  |  (2)  |  (since C++20)   
|  |   
  
Equivalent to  return  [ ranges::  end
](http://en.cppreference.com/w/cpp/ranges-ranges-placeholder/end) (  r_  )  ;
.

##  std::ranges::owning_view::  empty

constexpr  bool  empty  (  )  requires requires  {  [ ranges::  empty  ](http://en.cppreference.com/w/cpp/ranges/empty) (  r_  )  ;  }  ;  |  (1)  |  (since C++20)   
---|---|---  
constexpr  bool  empty  (  )  const  requires requires  {  [ ranges::  empty  ](http://en.cppreference.com/w/cpp/ranges/empty) (  r_  )  ;  }  ;  |  (2)  |  (since C++20)   
|  |   
  
Equivalent to  return  [ ranges::  empty
](http://en.cppreference.com/w/cpp/ranges/empty) (  r_  )  ;  .

##  std::ranges::owning_view::  size

constexpr  auto  size  (  )  requires [ ranges::  sized_range  ](http://en.cppreference.com/w/cpp/ranges/sized_range) < R  > ;  |  (1)  |  (since C++20)   
---|---|---  
constexpr  auto  size  (  )  const  requires [ ranges::  sized_range  ](http://en.cppreference.com/w/cpp/ranges/sized_range) < const  R  > ;  |  (2)  |  (since C++20)   
|  |   
  
Equivalent to  return  [ ranges::  size
](http://en.cppreference.com/w/cpp/ranges/size) (  r_  )  ;  .

##  std::ranges::owning_view::  data

constexpr  auto  data  (  )  requires [ ranges::  contiguous_range  ](http://en.cppreference.com/w/cpp/ranges/contiguous_range) < R  > ;  |  (1)  |  (since C++20)   
---|---|---  
constexpr  auto  data  (  )  const  requires [ ranges::  contiguous_range  ](http://en.cppreference.com/w/cpp/ranges/contiguous_range) < const  R  > ;  |  (2)  |  (since C++20)   
|  |   
  
Equivalent to  return  [ ranges::  data
](http://en.cppreference.com/w/cpp/ranges-ranges-placeholder/data) (  r_  )  ;
.

###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/owning_view&action=edit&section=6 "Edit
section: Helper templates") ]  Helper templates

template  < class  T  >  
inline  constexpr  bool  enable_borrowed_range  < std  ::  ranges  ::
owning_view  < T  >> =  
std  ::  [ ranges::  enable_borrowed_range  ](http://en.cppreference.com/w/cpp/ranges/borrowed_range) < T  > ;  |  |  (since C++20)   
---|---|---  
|  |   
  
This specialization of [ ` std::ranges::enable_borrowed_range `
](/w/cpp/ranges/borrowed_range "cpp/ranges/borrowed range") makes  `
owning_view ` satisfy [ ` borrowed_range ` ](/w/cpp/ranges/borrowed_range
"cpp/ranges/borrowed range") when the underlying range satisfies it.

###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/owning_view&action=edit&section=7 "Edit
section: Example") ]  Example

Run this code

    
    
    #include <cassert>
    #include <iostream>
    #include <ranges>
    #include <string>
     
    int main()
    {
        using namespace std::literals;
        std::ranges::owning_view ov{"cosmos"s}; // the deduced type of R is std::string;
                                                // `ov` is the only owner of this string
        [assert](http://en.cppreference.com/w/cpp/error/assert)(
            ov.empty() == false &&
            ov.size() == 6 &&
            ov.size() == ov.base().size() &&
            ov.front() == 'c' &&
            ov.front() == *ov.begin() &&
            ov.back() == 's' &&
            ov.back() == *(ov.end() - 1) &&
            ov.data() == ov.base()
        );
     
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << "sizeof(ov): " << sizeof ov << '\n' // typically equal to sizeof(R)
                  << "range-for: ";
        for (const char ch : ov)
            [std::cout](http://en.cppreference.com/w/cpp/io/cout) << ch;
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << '\n';
     
        std::ranges::owning_view<[std::string](http://en.cppreference.com/w/cpp/string/basic_string)> ov2;
        [assert](http://en.cppreference.com/w/cpp/error/assert)(ov2.empty());
    //  ov2 = ov; // compile-time error: copy assignment operator is deleted
        ov2 = std::move(ov); // OK