range") .   
(public member function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/view_interface/dsc_front&action=edit)  
[ back  ](/w/cpp/ranges/view_interface/back "cpp/ranges/view interface/back") (C++20)  |  returns the last element in the derived view. Provided if it satisfies [ ` bidirectional_range ` ](/w/cpp/ranges/bidirectional_range "cpp/ranges/bidirectional range") and [ ` common_range ` ](/w/cpp/ranges/common_range "cpp/ranges/common range") .   
(public member function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/view_interface/dsc_back&action=edit)  
[ operator[]  ](/w/cpp/ranges/view_interface/operator_at "cpp/ranges/view interface/operator at") (C++20)  |  returns the n  th  element in the derived view. Provided if it satisfies [ ` random_access_range ` ](/w/cpp/ranges/random_access_range "cpp/ranges/random access range") .   
(public member function)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/view_interface/dsc_operator_at&action=edit)  
  
###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/view_interface&action=edit&section=2 "Edit
section: Example") ]  Example

Run this code

    
    
    #include <iostream>
    #include <ranges>
    #include <vector>
     
    template<class T, class A>
    class VectorView : public std::ranges::view_interface<VectorView<T, A>>
    {
    public:
        VectorView() = default;
     
        VectorView(const [std::vector](http://en.cppreference.com/w/cpp/container/vector)<T, A>& vec) :
            m_begin(vec.cbegin()), m_end(vec.cend())
        {}
     
        auto begin() const { return m_begin; }
     
        auto end() const { return m_end; }
     
    private:
        typename [std::vector](http://en.cppreference.com/w/cpp/container/vector)<T, A>::const_iterator m_begin{}, m_end{};
    };
     
    int main()
    {
        [std::vector](http://en.cppreference.com/w/cpp/container/vector)<int> v = {1, 4, 9, 16};
     
        VectorView view_over_v{v};
     
        // We can iterate with begin() and end().
        for (int n : view_over_v)
            [std::cout](http://en.cppreference.com/w/cpp/io/cout) << n << ' ';
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << '\n';
     
        // We get operator[] for free when inheriting from view_interface
        // since we satisfy the random_access_range concept.
        for ([std::ptrdiff_t](http://en.cppreference.com/w/cpp/types/ptrdiff_t) i = 0; i != view_over_v.size(); ++i)
            [std::cout](http://en.cppreference.com/w/cpp/io/cout) << "v[" << i << "] = " << view_over_v[i] << '\n';
    }

Output:

    
    
    1 4 9 16
    v[0] = 1
    v[1] = 4
    v[2] = 9
    v[3] = 16

###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/view_interface&action=edit&section=3 "Edit
section: Defect reports") ]  Defect reports

The following behavior-changing defect reports were applied retroactively to
previously published C++ standards.

DR  |  Applied to  |  Behavior as published  |  Correct behavior   
---|---|---|---  
[ LWG 3549 ](https://cplusplus.github.io/LWG/issue3549) |  C++20  |  ` view_interface ` was required to be derived from ` view_base ` ,   
which sometimes required multiple ` view_base ` subobjects in a view  |  inheritance removed   
  
###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/view_interface&action=edit&section=4 "Edit
section: See also") ]  See also

[ ranges::subrange  ](/w/cpp/ranges/subrange "cpp/ranges/subrange") (C++20)  |  combines an iterator-sentinel pair into a [ ` view ` ](/w/cpp/ranges/view "cpp/ranges/view")   
(class template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/dsc_subrange&action=edit)  
---|---  
  
Retrieved from " [
https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/view_interface&oldid=160961
](https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/view_interface&oldid=160961)
"

#####  Navigat