FreeBSD Manual Pages
std::ranges::in_out_result(3) C++ Standard Libarystd::ranges::in_out_result(3) NAME std::ranges::in_out_result - std::ranges::in_out_result Synopsis Defined in header <algorithm> template< class I, class O > (since C++20) struct in_out_result; ranges::in_out_result is a class template that provides a way to store two 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 I, O - the types of the objects that the ranges::in_out_result stores. Data members Member name Definition in a value (that is supposed to be an iterator) of type I. (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_out_result::operator in_out_result<I2, O2> template<class I2, class O2> requires std::convertible_to<const I&, I2> && std::convert- ible_to<const O&, O2> (1) constexpr operator in_out_result<I2, O2>() const &; template<class I2, class O2> requires std::convertible_to<I, I2> && std::convertible_to<O, O2> (2) constexpr operator in_out_result<I2, O2>() &&; Converts *this to the result by constructing every data member of the result from the corresponding member of *this. 1) Equivalent to return {in, out};. 2) Equivalent to return {std::move(in), std::move(out)};. Standard library The following standard library functions use ranges::in_out_result as the return type: Algorithm functions ranges::copy ranges::copy_if copies a range of elements to a new lo- cation (C++20) (niebloid) (C++20) ranges::copy_n copies a number of elements to a new location (C++20) (niebloid) ranges::copy_backward copies a range of elements in backwards order (C++20) (niebloid) ranges::move moves a range of elements to a new lo- cation (C++20) (niebloid) ranges::move_backward moves a range of elements to a new lo- cation in (C++20) backwards order (niebloid) ranges::transform applies a function to a range of ele- ments (C++20) (niebloid) ranges::replace_copy copies a range, replacing elements sat- isfying specific ranges::replace_copy_if criteria with another value (C++20) (niebloid) (C++20) ranges::remove_copy copies a range of elements omitting those that satisfy ranges::remove_copy_if specific criteria (C++20) (niebloid) (C++20) ranges::unique_copy creates a copy of some range of ele- ments that contains (C++20) no consecutive duplicates (niebloid) ranges::reverse_copy creates a copy of a range that is re- versed (C++20) (niebloid) ranges::rotate_copy copies and rotate a range of elements (C++20) (niebloid) ranges::partial_sort_copy copies and partially sorts a range of elements (C++20) (niebloid) ranges::set_difference computes the difference between two sets (C++20) (niebloid) Memory functions ranges::uninitialized_copy copies a range of objects to an unini- tialized area of (C++20) memory (niebloid) ranges::uninitialized_copy_n copies a number of objects to an unini- tialized area of (C++20) memory (niebloid) ranges::uninitialized_move moves a range of objects to an unini- tialized area of (C++20) memory (niebloid) ranges::uninitialized_move_n moves a number of objects to an unini- tialized area of (C++20) memory (niebloid) Synopsis namespace std::ranges { template<class I, class O> struct in_out_result { [[no_unique_address]] I in; [[no_unique_address]] O out; template<class I2, class O2> requires std::convertible_to<const I&, I2> && std::convert- ible_to<const O&, O2> constexpr operator in_out_result<I2, O2>() const & { return {in, out}; } template<class I2, class O2> requires std::convertible_to<I, I2> && std::convertible_to<O, O2> constexpr operator in_out_result<I2, O2>() && { return {std::move(in), 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 <cctype> #include <iostream> #include <ranges> int main() { constexpr char in[] = "transform" "\n"; std::array<char, sizeof(in)> out; const auto result = std::ranges::transform(in, out.begin(), [](char c) { return std::toupper(c); }); auto print = [](char c) { std::cout << c; }; std::ranges::for_each(std::cbegin(in), result.in, print); std::ranges::for_each(out.cbegin(), result.out, print); } Output: transform TRANSFORM 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::in_out_result(3)
NAME | Synopsis | Template parameters | Member functions | Standard library | Synopsis | Notes | Example | Output: | See also
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::ranges::in_out_result&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>
