s dereferenceable, and ` [ `
++  i  ` , ` \--  n  ` ) ` is a valid counted range.

Formally, if  it  and  count  are expressions, ` T ` is  [ std::  decay_t
](http://en.cppreference.com/w/cpp/types/decay) < decltype  (  (  it  )  )  >
, and ` D ` is  [ std::  iter_difference_t
](http://en.cppreference.com/w/cpp/iterator/iter_t) < T  > , then

     if ` T ` models [ ` input_or_output_iterator ` ](/w/cpp/iterator/input_or_output_iterator "cpp/iterator/input or output iterator") and  decltype  (  (  count  )  )  models  [ std::  convertible_to  ](http://en.cppreference.com/w/cpp/concepts/convertible_to) < D  > , 

  * if ` T ` models [ ` contiguous_iterator ` ](/w/cpp/iterator/contiguous_iterator "cpp/iterator/contiguous iterator") , then  [ views::  counted  ](http://en.cppreference.com/w/cpp/ranges/counted_view) (  it, count  )  is [ expression-equivalent ](/w/cpp/language/expressions#Expression-equivalence "cpp/language/expressions") to  [ std::  span  ](http://en.cppreference.com/w/cpp/container/span) (  [ std::  to_address  ](http://en.cppreference.com/w/cpp/memory/to_address) (  it  )  ,  static_cast  < [ std::  size_t  ](http://en.cppreference.com/w/cpp/types/size_t) > (  static_cast  < D  > (  count  )  )  )  , 
  * otherwise, if ` T ` models [ ` random_access_iterator ` ](/w/cpp/iterator/random_access_iterator "cpp/iterator/random access iterator") , then  [ views::  counted  ](http://en.cppreference.com/w/cpp/ranges/counted_view) (  it, count  )  is [ expression-equivalent ](/w/cpp/language/expressions#Expression-equivalence "cpp/language/expressions") to  [ ranges::  subrange  ](http://en.cppreference.com/w/cpp/ranges/subrange) (  it, it  \+  static_cast  < D  > (  count  )  )  , 
  * otherwise,  [ views::  counted  ](http://en.cppreference.com/w/cpp/ranges/counted_view) (  it, count  )  is [ expression-equivalent ](/w/cpp/language/expressions#Expression-equivalence "cpp/language/expressions") to  [ ranges::  subrange  ](http://en.cppreference.com/w/cpp/ranges/subrange) (  [ std::  counted_iterator  ](http://en.cppreference.com/w/cpp/iterator/counted_iterator) (  it, count  )  , [ std::  default_sentinel  ](http://en.cppreference.com/w/cpp/iterator/default_sentinel_t) )  . 

     Otherwise,  [ views::  counted  ](http://en.cppreference.com/w/cpp/ranges/counted_view) (  it, count  )  is ill-formed. 

##  Contents

  * 1  Customization point objects 
  * 2  Notes 
  * 3  Example 
  * 4  Defect reports 
  * 5  See also 

  
---  
  
###  Customization point objects

The name ` views::counted ` denotes a _customization point object_ , which is
a const [ function object ](/w/cpp/named_req/FunctionObject "cpp/named
req/FunctionObject") of a [ literal ](/w/cpp/named_req/LiteralType "cpp/named
req/LiteralType") [ ` semiregular ` ](/w/cpp/concepts/semiregular
"cpp/concepts/semiregular") class type. For exposition purposes, the cv-
unqualified version of its type is denoted as ` ___counted_fn_ ` .

All instances of ` ___counted_fn_ ` are equal. The effects of invoking
different instances of type ` ___counted_fn_ ` on the same arguments are
equivalent, regardless of whether the expression denoting the instance is an
lvalue or rvalue, and is const-qualified or not (however, a volatile-qualified
instance is not required to be invocable). Thus, ` views::counted ` can be
copied freely and its copies can be used interchangeably.

Given a set of types ` Args... ` , if  [ std::  declval
](http://en.cppreference.com/w/cpp/utility/declval) < Args  > (  )  ...  meet
the requirements for arguments to ` views::counted ` above, ` ___counted_fn_ `
models  

  * [ std::  invocable  ](http://en.cppreference.com/w/cpp/concepts/invocable) < __counted_fn, Args...  > , 
  * [ std::  invocable  ](http://en.cppreference.com/w/cpp/concepts/invocable) < const  __counted_fn, Args...  > , 
  * [ std::  invocable  ](http://en.cppreference.com/w/cpp/concepts/invocable) < __counted_fn  & , Args...  > , and 
  * [ std::  invocable  ](http://en.cppreference.co