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

FreeBSD Manual Pages

  
 
  

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

NAME
       std::ranges::in_in_out_result - std::ranges::in_in_out_result

Synopsis
	  Defined in header <algorithm>
	  template< class I1, class I2,	class O	>  (since C++20)
	  struct in_in_out_result;

	  ranges::in_in_out_result  is a class template	that provides a	way to
       store three
	  iterators as a single	unit.

	  This class template has no base classes or  declared	members	 other
       than those shown
	  below. Thus it is suitable for use with structured bindings.

	  All  special	member functions of this class template	are implicitly
       declared, which
	  makes	specializations	be aggregate classes, and  propagate  trivial-
       ity,
	  potentially-throwing-ness, and constexpr-ness	of corresponding oper-
       ations on data
	  members.

Template parameters
	  I1,	 I2,   O   -   the   types   of	  the	iterators   that   the
       ranges::in_in_out_result	stores.

	  Data members

	  Member name Definition
	  in1	      a	value (that is supposed	to be an iterator) of type I1.
		      (public member object)
	  in2	      a	value (that is supposed	to be an iterator) of type I2.
		      (public member object)
	  out	      a	value (that is supposed	to be an iterator) of type O.
		      (public member object)

	  All these members are	declared with [[no_unique_address]] attribute.

Member functions
       std::ranges::in_in_out_result::operator in_in_out_result<II1, II2, OO>

	  template<class II1, class II2, class OO>

	  requires std::convertible_to<const I1&, II1> &&
		   std::convertible_to<const I2&, II2> &&	       (1)
		   std::convertible_to<const O&, OO>

	  constexpr operator in_in_out_result<II1, II2,	OO>() const &;
	  template<class II1, class II2, class OO>

	  requires std::convertible_to<I1, II1>	&&
		   std::convertible_to<I2, II2>	&&		       (2)
		   std::convertible_to<O, OO>

	  constexpr operator in_in_out_result<II1, II2,	OO>() &&;

	  Converts *this to the	result by constructing every  data  member  of
       the result from
	  the corresponding member of *this.

	  1) Equivalent	to return {in1,	in2, out};.
	  2)	Equivalent    to   return   {std::move(in1),   std::move(in2),
       std::move(out)};.

Standard library
	  The following	standard library functions  use	 ranges::in_in_out_re-
       sult as the return
	  type:

		Algorithm functions
	  ranges::transform		    applies  a	function to a range of
       elements
	  (C++20)			   (niebloid)
	  ranges::merge			   merges two sorted ranges
	  (C++20)			   (niebloid)
	  ranges::set_union		   computes the	union of two sets
	  (C++20)			   (niebloid)
	  ranges::set_intersection	   computes the	 intersection  of  two
       sets
	  (C++20)			   (niebloid)
	  ranges::set_symmetric_difference  computes  the symmetric difference
       between two sets
	  (C++20)			   (niebloid)

Synopsis
	namespace std::ranges
	{
	    template<class I1, class I2, class O>
	    struct in_in_out_result
	    {
		[[no_unique_address]] I1 in1;
		[[no_unique_address]] I2 in2;
		[[no_unique_address]] O	 out;

		template<class II1, class II2, class OO>
		requires std::convertible_to<const I1&,	II1> &&
			 std::convertible_to<const I2&,	II2> &&
			 std::convertible_to<const O&, OO>
		constexpr operator in_in_out_result<II1, II2, OO>() const &
		{
		    return {in1, in2, out};
		}

		template<class II1, class II2, class OO>
		requires std::convertible_to<I1, II1> &&
			 std::convertible_to<I2, II2> &&
			 std::convertible_to<O,	OO>
		constexpr operator in_in_out_result<II1, II2, OO>() &&
		{
		    return {std::move(in1), std::move(in2), std::move(out)};
		}
	    };
	}

Notes
	  Each standard	library	algorithm that	uses  this  family  of	return
       types declares a	new
	  alias	type, e.g. using merge_result =	in_in_out_result<I1, I2, O>;.

	  The names for	such aliases are formed	by adding the suffix "_result"
       to the
	  algorithm's  name.  So, the return type of std::ranges::merge	can be
       named as
	  std::ranges::merge_result.

	  Unlike std::pair and std::tuple, this	class template has  data  mem-
       bers of meaningful
	  names.

Example
       // Run this code

	#include <algorithm>
	#include <array>
	#include <iostream>
	#include <iterator>
	#include <ranges>

	void print(auto	rem, auto first, auto last)
	{
	    for	(std::cout << rem << ":	"; first != last; ++first)
		std::cout << *first << ' ';
	    std::cout << '\n';
	}

	int main()
	{
	    constexpr static auto in1 =	{1, 2, 3, 4, 5,	5};
	    constexpr static auto in2 =	{3, 4, 5, 6, 7};
	    std::array<int, std::size(in1) + std::size(in2)> out;

	    const auto result =	std::ranges::merge(in1,	in2, out.begin());
	    print("in1", in1.begin(), result.in1);
	    print("in2", in2.begin(), result.in2);
	    print("out", out.begin(), result.out);
	}

Output:
	in1: 1 2 3 4 5 5
	in2: 3 4 5 6 7
	out: 1 2 3 3 4 4 5 5 5 6 7

See also
	  pair	  implements binary tuple, i.e.	a pair of values
		  (class template)
	  tuple	   implements  fixed  size  container, which holds elements of
       possibly	different
	  (C++11) types
		  (class template)

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

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

home | help