Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::ranges...iguous_range(3) C++ Standard Libarystd::ranges...iguous_range(3)

NAME
       std::ranges::contiguous_range - std::ranges::contiguous_range

Synopsis
	  Defined in header <ranges>
	  template< class T >

	    concept contiguous_range =
	      ranges::random_access_range<T> &&
	      std::contiguous_iterator<ranges::iterator_t<T>>		    &&
       (since
	      requires(T&			  t)			     {
       C++20)
		{ ranges::data(t) } ->
		  std::same_as<std::add_pointer_t<ranges::range_refer-
       ence_t<T>>>;

	      };

	  The  contiguous_range	 concept  is  a	 refinement of range for which
       ranges::begin
	  returns a model of contiguous_iterator and the  customization	 point
       ranges::data is
	  usable.

	  Semantic requirements

	  T  models  contiguous_range  only if given an	expression e such that
       decltype((e)) is
	  T&, std::to_address(ranges::begin(e))	== ranges::data(e).

Example
       // Run this code

	#include <array>
	#include <deque>
	#include <list>
	#include <ranges>
	#include <set>
	#include <valarray>
	#include <vector>

	template<typename T> concept CR	= std::ranges::contiguous_range<T>;

	int main()
	{
	    int	a[4];
	    static_assert(
		    CR<std::vector<int>> and
		not CR<std::vector<bool>> and
		not CR<std::deque<int>>	and
		    CR<std::valarray<int>> and
		    CR<decltype(a)> and
		not CR<std::list<int>> and
		not CR<std::set<int>> and
		    CR<std::array<std::list<int>,42>>
	    );
	}

See also
	  ranges::sized_range	      specifies	that a range knows its size in
       constant	time
	  (C++20)		      (concept)
	  ranges::random_access_range specifies	a range	 whose	iterator  type
       satisfies
	  (C++20)		      random_access_iterator
				      (concept)

http://cppreference.com		  2024.06.10	 std::ranges...iguous_range(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::ranges::contiguous_range&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help