rface/operator at")  
  
[ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/view_interface/navbar_content&action=edit)

Defined in header ` [ <ranges> ](/w/cpp/header/ranges "cpp/header/ranges") ` |  |   
---|---|---  
template  < class  D  >  
requires [ std::  is_class_v
](http://en.cppreference.com/w/cpp/types/is_class) < D  > && [ std::  same_as
](http://en.cppreference.com/w/cpp/concepts/same_as) < D, [ std::  remove_cv_t
](http://en.cppreference.com/w/cpp/types/remove_cv) < D  >>  
class  view_interface  ;  |  |  (since C++20)   
|  |   
  
` std::ranges::view_interface ` is a helper class template for defining a view
interface.

` view_interface ` is typically used with [ CRTP ](/w/cpp/language/crtp
"cpp/language/crtp") :

    
    
    class my_view : public std::ranges::view_interface<my_view>
    {
    public:
        auto begin() const { /*...*/ }
        auto end() const { /*...*/ }
        // empty() is provided if begin() returns a forward iterator
        // and end() returns a sentinel for it.
    };

##  Contents

  * 1  Member functions 
  * 2  Example 
  * 3  Defect reports 
  * 4  See also 

  
---  
  
###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/view_interface&action=edit&section=1 "Edit
section: Member functions") ]  Member functions

[ empty  ](/w/cpp/ranges/view_interface/empty "cpp/ranges/view interface/empty") (C++20)  |  returns whether the derived view is empty. Provided if it satisfies [ ` sized_range ` ](/w/cpp/ranges/sized_range "cpp/ranges/sized range") or [ ` forward_range ` ](/w/cpp/ranges/forward_range "cpp/ranges/forward range") .   
(public member function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/view_interface/dsc_empty&action=edit)  
---|---  
[ cbegin  ](/w/cpp/ranges/view_interface/cbegin "cpp/ranges/view interface/cbegin") (C++23)  |  returns a constant iterator to the beginning of the range.   
(public member function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/view_interface/dsc_cbegin&action=edit)  
[ cend  ](/w/cpp/ranges/view_interface/cend "cpp/ranges/view interface/cend") (C++23)  |  returns a sentinel for the constant iterator of the range.   
(public member function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/view_interface/dsc_cend&action=edit)  
[ operator bool  ](/w/cpp/ranges/view_interface/operator_bool "cpp/ranges/view interface/operator bool") (C++20)  |  returns whether the derived view is not empty. Provided if  [ ranges::empty ](/w/cpp/ranges/empty "cpp/ranges/empty") is applicable to it.   
(public member function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/view_interface/dsc_operator_bool&action=edit)  
[ data  ](/w/cpp/ranges/view_interface/data "cpp/ranges/view interface/data") (C++20)  |  gets the address of derived view's data. Provided if its iterator type satisfies [ ` contiguous_iterator ` ](/w/cpp/iterator/contiguous_iterator "cpp/iterator/contiguous iterator") .   
(public member function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/view_interface/dsc_data&action=edit)  
[ size  ](/w/cpp/ranges/view_interface/size "cpp/ranges/view interface/size") (C++20)  |  returns the number of elements in the derived view. Provided if it satisfies [ ` forward_range ` ](/w/cpp/ranges/forward_range "cpp/ranges/forward range") and its sentinel and iterator type satisfy [ ` sized_sentinel_for ` ](/w/cpp/iterator/sized_sentinel_for "cpp/iterator/sized sentinel for") .   
(public member function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/view_interface/dsc_size&action=edit)  
[ front  ](/w/cpp/ranges/view_interface/front "cpp/ranges/view interface/front") (C++20)  |  returns the first element in the derived view. Provided if it satisfies [ ` forward_range ` ](/w/cpp/ranges/forward_range "cpp/ranges/forward