]  Example

Run this code

    
    
    #include <array>
    #include <deque>
    #include <list>
    #include <ranges>
    #include <set>
    #include <valarray>
    #include <vector>
     
    template<typename T> concept RAR = std::ranges::random_access_range<T>;
     
    int main()
    {
        int a[4];
        static_assert(
                RAR<[std::vector](http://en.cppreference.com/w/cpp/container/vector)<int>> and
                RAR<[std::vector](http://en.cppreference.com/w/cpp/container/vector)<bool>> and
                RAR<[std::deque](http://en.cppreference.com/w/cpp/container/deque)<int>> and
                RAR<[std::valarray](http://en.cppreference.com/w/cpp/numeric/valarray)<int>> and
                RAR<decltype(a)> and
            not RAR<[std::list](http://en.cppreference.com/w/cpp/container/list)<int>> and
            not RAR<[std::set](http://en.cppreference.com/w/cpp/container/set)<int>> and
                RAR<[std::array](http://en.cppreference.com/w/cpp/container/array)<[std::list](http://en.cppreference.com/w/cpp/container/list)<int>,42>>
        );
    }

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

[ ranges::sized_range  ](/w/cpp/ranges/sized_range "cpp/ranges/sized range") (C++20)  |  specifies that a range knows its size in constant time   
(concept)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/dsc_sized_range&action=edit)  
---|---  
[ ranges::contiguous_range  ](/w/cpp/ranges/contiguous_range "cpp/ranges/contiguous range") (C++20)  |  specifies a range whose iterator type satisfies [ ` contiguous_iterator ` ](/w/cpp/iterator/contiguous_iterator "cpp/iterator/contiguous iterator")   
(concept)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/dsc_contiguous_range&action=edit)  
  
Retrieved from " [
https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/random_access_range&oldid=151099
](https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/random_access_range&oldid=151099)
"

#####  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/random_access_range "A list of all wiki pages that link here \[j\]")
  * [ Related changes ](/w/Special:RecentChangesLinked/cpp/ranges/random_access_range "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/random_access_range&printable=yes "Printable version of this page \[p\]")
  * [ Permanent link ](/mwiki/index.php?title=cpp/ranges/random_access_range&oldid=151099 "Permanent link to this revision of the page")
  * [ Page information ](/mwiki/index.php?title=cpp/ranges/random_access_range&action=info)

  * In other languages 

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

  * This page was last modified on 27 April 2023, at 14:54. 
  * This page has been accessed 23,727 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.media