as a known bound
            print('a', array);
        }
        {
            struct Scanty : private [std::vector](http://en.cppreference.com/w/cpp/container/vector)<int>
            {
                using [std::vector](http://en.cppreference.com/w/cpp/container/vector)<int>::begin;
                using [std::vector](http://en.cppreference.com/w/cpp/container/vector)<int>::end;
                using [std::vector](http://en.cppreference.com/w/cpp/container/vector)<int>::push_back;
                // Note: both empty() and size() are hidden
            };
     
            [std::cout](http://en.cppreference.com/w/cpp/io/cout) << "(3) calling ranges::empty on an object w/o empty() or size():\n";
            Scanty y;
            print('a', y);
            y.push_back(42);
            print('b', y);
        }
    }

Output:

    
    
    (1) ranges::empty uses std::vector::empty:
            a) Elements: 1 2 3
            b) Empty
    (2) ranges::empty uses ranges::size(initializer_list):
            a) Elements: 7 8 9
            b) Empty
    (2) ranges::empty on a raw array uses ranges::size:
            a) Elements: 4 5 6
    (3) calling ranges::empty on an object w/o empty() or size():
            a) Empty
            b) Elements: 42

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

[ empty  ](/w/cpp/iterator/empty "cpp/iterator/empty") (C++17)  |  checks whether the container is empty   
(function template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/iterator/dsc_empty&action=edit)  
---|---  
  
Retrieved from " [
https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/empty&oldid=160900
](https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/empty&oldid=160900)
"

#####  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 "A list of all wiki pages that link here \[j\]")
  * [ Related changes ](/w/Special:RecentChangesLinked/cpp/ranges/empty "Recent changes in pages linked from this page \[k\]")
  * [ Upload file ](http://upload.cppreference.com/w/Special:Upload "Upload files \[u\]")
  * [ Special pages ](/w/Special:SpecialPages "A list of all special pages \[q\]")
  * [ Printable version ](/mwiki/index.php?title=cpp/ranges/empty&printable=yes "Printable version of this page \[p\]")
  * [ Permanent link ](/mwiki/index.php?title=cpp/ranges/empty&oldid=160900 "Permanent link to this revision of the page")
  * [ Page information ](/mwiki/index.php?title=cpp/ranges/empty&action=info)

  * In other languages 

  * [ Español ](http://es.cppreference.com/w/cpp/ranges/empty "cpp/ranges/empty")
  * [ 日本語 ](http://ja.cppreference.com/w/cpp/ranges/empty "cpp/ranges/empty")
  * [ 中文 ](http://zh.cppreference.com/w/cpp/ranges/empty "cpp/ranges/empty")

  * This page was last modified on 18 October 2023, at 11:26. 
  * This page has been accessed 17,044 times. 

  * [ Privacy policy ](/w/Cppreference:Privacy_policy "Cppreference:Privacy policy")
  * [ About cppreference.com ](/w/Cppreference:About "Cppreference:About")
  * [ Disclaimers ](/w/Cppreference:General_disclaimer "Cppreference:General disclaimer")

  * [ ![Powered by MediaWiki](/mwiki/skins/common/images/poweredby_mediawiki_88x31.png) ](//www.mediawiki.org/) [ ![Powered by GeSHi](//upload.cppreference.com/mwiki/images/2/2b/powered_by_geshi_88x31.png) ](http://qbnz.com/highlighter/) [ ![Hosted by Tiger Technologies](//upload.cppreference.com/mwiki/images/9/94/powered_by_tigertech_88x31.png) ](http://www.tigertech.net/referral/cppreference.com)