---|---  
|  |   
  
` empty_view ` does not reference any element.

##  std::ranges::empty_view::  size

static  constexpr  [ std::  size_t  ](http://en.cppreference.com/w/cpp/types/size_t) size  (  )  noexcept  {  return  0  ;  }  |  |  (since C++20)   
---|---|---  
|  |   
  
` empty_view ` is always empty.

##  std::ranges::empty_view::  empty

static  constexpr  bool  empty  (  )  noexcept  {  return  true  ;  }  |  |  (since C++20)   
---|---|---  
|  |   
  
` empty_view ` is always empty.

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

template  < class  T  >  
inline  constexpr  bool  enable_borrowed_range  < ranges  ::  empty_view  < T  >> =  true  ;  |  |  (since C++20)   
---|---|---  
|  |   
  
This specialization of [ ` std::ranges::enable_borrowed_range `
](/w/cpp/ranges/borrowed_range "cpp/ranges/borrowed range") makes ` empty_view
` satisfy [ ` borrowed_range ` ](/w/cpp/ranges/borrowed_range
"cpp/ranges/borrowed range") .

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

Although ` empty_view ` obtains ` front ` , ` back ` , and  operator  [  ]
member functions from ` view_interface ` , calls to them always result in
undefined behavior since an ` empty_view ` is always empty.

The inherited  operator  bool  conversion function always returns  false  .

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

Run this code

    
    
    #include <ranges>
     
    int main()
    {
        std::ranges::empty_view<long> e;
        static_assert(std::[ranges::empty](http://en.cppreference.com/w/cpp/ranges/empty)(e));
        static_assert(0 == e.size());
        static_assert(nullptr == e.data());
        static_assert(nullptr == e.begin());
        static_assert(nullptr == e.end());
    }

###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/empty_view&action=edit&section=5 "Edit
section: See also") ]  See also

[ ranges::single_view  views::single  ](/w/cpp/ranges/single_view "cpp/ranges/single view") (C++20)  |  a [ ` view ` ](/w/cpp/ranges/view "cpp/ranges/view") that contains a single element of a specified value   
(class template)  (customization point object)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/dsc_single_view&action=edit)  
---|---  
[ views::all_t  views::all  ](/w/cpp/ranges/all_view "cpp/ranges/all view") (C++20)  |  a [ ` view ` ](/w/cpp/ranges/view "cpp/ranges/view") that includes all elements of a [ ` range ` ](/w/cpp/ranges/range "cpp/ranges/range")   
(alias template)  (range adaptor object)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/dsc_all_view&action=edit)  
[ ranges::ref_view  ](/w/cpp/ranges/ref_view "cpp/ranges/ref view") (C++20)  |  a [ ` view ` ](/w/cpp/ranges/view "cpp/ranges/view") of the elements of some other [ ` range ` ](/w/cpp/ranges/range "cpp/ranges/range")   
(class template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/dsc_ref_view&action=edit)  
  
Retrieved from " [
https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/empty_view&oldid=131600
](https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/empty_view&oldid=131600)
"

#####  Navigation

  * [ Support us ](http://www.cppreference.com/support)
  * [ Recent changes ](/w/Special:RecentChanges "A list of recent changes in the wiki \[r\]")
  * [ FAQ ](/w/Cppreference:FAQ)
  * [ Offline version ](/w/Cppreference:Archives)

#####  Toolbox

  * [ What links here ](/w/Special:WhatLinksHere/cpp/ranges/empty_view "A list of all wiki pages that link here \[j\]")
  * [ Related changes ](/w/Special:RecentChangesLinked/cpp/ranges/empty_view "Recent changes in pages linked from this page \[k\]")
  * [ Upload file ](http://upload.cppreference.com/w/Special:Upload "Upload files \[u\]")