PrevUpHomeNext

utx::print_all


utx::print_all is a very simple and convenient c++ function to print all elements of a container or several containers, such as std::vector, std::list.

template <utx::kspt::rangable ... R>
void print_all(const R & ... r);

Include

#include <utxcpp/core.hpp>

Notice

[Note] Note
  • It prints a newline character after printing every container elements.
  • It separates each value by a space.
  • concept requirements:
    • Every container must satisfy utx::kspt::rangable, otherwise the container can not be printed by utx::print_all. For example, std::vector satisfies utx::kspt::rangable, but std::stack does not satisfy utx::kspt::rangable.
    • Every element of every container must satisfy utx::kspt::printable.
    • Basic printable types satisfy utx::kspt::printable.
    • Non-basic types must implement operator<< to satisfy utx::kspt::printable.

Example

#include <utxcpp/core.hpp>
#include <vector>
#include <array>
#include <list>

int main()
{
	auto vector = std::vector{2,3,5,7,11};
	utx::print_all(vector);

	std::array<char, 8> array{"helpful"};
	std::array<int, 5> array2{1, 2, 3, 4, 5};
	std::list<int> list{2,4,6};

	utx::print_all(vector, array, array2, list);
}
Output:
2 3 5 7 11
2 3 5 7 11
h e l p f u l
1 2 3 4 5
2 4 6

Last revised: November 24, 2022 at 11:26:05 GMT


PrevUpHomeNext