r/iterator_t) < R  >> if ` R ` models [ ` borrowed_range `
](/w/cpp/ranges/borrowed_range "cpp/ranges/borrowed range") ,  [
std::ranges::dangling ](/w/cpp/ranges/dangling "cpp/ranges/dangling")
otherwise.

These two alias templates are used by some [ constrained algorithms
](/w/cpp/algorithm/ranges "cpp/algorithm/ranges") to avoid returning
potentially dangling iterators or views.

###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/borrowed_iterator_t&action=edit&section=1
"Edit section: Possible implementation") ]  Possible implementation

First version  
---  
      
    
    template< std::[ranges::range](http://en.cppreference.com/w/cpp/ranges/range) R >
    using borrowed_iterator_t = [std::conditional_t](http://en.cppreference.com/w/cpp/types/conditional)<std::[ranges::borrowed_range](http://en.cppreference.com/w/cpp/ranges/borrowed_range)<R>,
        std::[ranges::iterator_t](http://en.cppreference.com/w/cpp/ranges-ranges-placeholder/iterator_t)<R>, std::[ranges::dangling](http://en.cppreference.com/w/cpp/ranges-dangling-placeholder/dangling)>;  
  
Second version  
      
    
    template< std::[ranges::range](http://en.cppreference.com/w/cpp/ranges/range) R >
    using borrowed_subrange_t = [std::conditional_t](http://en.cppreference.com/w/cpp/types/conditional)<std::[ranges::borrowed_range](http://en.cppreference.com/w/cpp/ranges/borrowed_range)<R>,
        std::[ranges::subrange](http://en.cppreference.com/w/cpp/ranges/subrange)<std::[ranges::iterator_t](http://en.cppreference.com/w/cpp/ranges-ranges-placeholder/iterator_t)<R>>, std::[ranges::dangling](http://en.cppreference.com/w/cpp/ranges-dangling-placeholder/dangling)>;  
  
###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/borrowed_iterator_t&action=edit&section=2
"Edit section: See also") ]  See also

[ ranges::dangling  ](/w/cpp/ranges/dangling "cpp/ranges/dangling") (C++20)  |  a placeholder type indicating that an iterator or a ` subrange ` should not be returned since it would be dangling   
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/ranges/dsc_dangling&action=edit)  
---|---  
  
Retrieved from " [
https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/borrowed_iterator_t&oldid=129980
](https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/borrowed_iterator_t&oldid=129980)
"

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

  * In other languages 

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

  * This page was last modified on 13 June 2021, at 01:16. 
  * This page has been accessed 21,488 times. 

  * [ Privacy poli