anges/constant range") . 
  * Otherwise,  [ ranges::  begin  ](http://en.cppreference.com/w/cpp/ranges-ranges-placeholder/begin) (  [ std::  as_const  ](http://en.cppreference.com/w/cpp/utility/as_const) (  e  )  )  if  const  T  models [ ` constant_range ` ](/w/cpp/ranges/constant_range "cpp/ranges/constant range") . 
  * Otherwise,  [ std::  basic_const_iterator  ](http://en.cppreference.com/w/cpp/iterator/basic_const_iterator) (  [ ranges::  begin  ](http://en.cppreference.com/w/cpp/ranges-ranges-placeholder/begin) (  e  )  )  . 

|  (since C++23)  
  
###  [ [ edit ](/mwiki/index.php?title=cpp/ranges/cbegin&action=edit&section=2
"Edit section: Example") ]  Example

Run this code

    
    
    #include <cassert>
    #include <ranges>
    #include <vector>
     
    int main()
    {
        [std::vector](http://en.cppreference.com/w/cpp/container/vector) v{3, 1, 4};
        auto vi = std::[ranges::cbegin](http://en.cppreference.com/w/cpp/ranges-ranges-placeholder/cbegin)(v);
        [assert](http://en.cppreference.com/w/cpp/error/assert)(3 == *vi);
        ++vi; // OK, constant-iterator object is mutable
        [assert](http://en.cppreference.com/w/cpp/error/assert)(1 == *vi);
        // *vi = 13; // Error: constant-iterator points to an immutable element
     
        int a[]{3, 1, 4};
        auto ai = std::[ranges::cbegin](http://en.cppreference.com/w/cpp/ranges-ranges-placeholder/cbegin)(a); // cbegin works with C-arrays as well
        [assert](http://en.cppreference.com/w/cpp/error/assert)(3 == *ai and *(ai + 1) == 1);
        // *ai = 13; // Error: read-only variable is not assignable
    }

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

[ ranges::begin  ](/w/cpp/ranges/begin "cpp/ranges/begin") (C++20)  |  returns an iterator to the beginning of a range   
(customization point object)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/dsc_begin&action=edit)  
---|---  
[ begin  cbegin  ](/w/cpp/iterator/begin "cpp/iterator/begin") (C++11)  (C++14)  |  returns an iterator to the beginning of a container or array   
(function template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/iterator/dsc_begin&action=edit)  
  
Retrieved from " [
https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/cbegin&oldid=162281
](https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/cbegin&oldid=162281)
"

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

  * In other languages 

  * [ Deutsch ](http://de.cppreference.com/w/cpp/ranges/cbegin "cpp/ranges/cbegin")
  * [ Español ](http://es.cppreference.com/w/cpp/ranges/cbegin "cpp/ranges/cbegin")
  * [ 日本語 ](http://ja.cppreference.com/w/cpp/ranges/cbegin "cpp/ranges/cbegin")
  * [ Русский ](http://ru.cppreference.com/w/cpp/ranges/cbegin "cpp/ranges/cbegin")
  * [ 中文 ](http://zh.cppreference.com/w/cpp/ranges/cbegin "cpp/ranges/cbegin")

  * This page was last modified on 8 November 2023, at 00:14. 
  * Th