xtd 0.2.0
format_sequence_containers.cpp

Show how to use format xtd::format class with sequence containers.

#include <xtd/collections/array_list>
#include <xtd/console>
#include <xtd/environment>
#include <xtd/fixed_array>
#include <xtd/string>
using namespace xtd;
using namespace xtd::collections;
using namespace xtd::collections::generic;
auto main() -> int {
console::out << string::format("{}", array<int> {1, 2, 3, 4}) << environment::new_line;
console::out << string::format("{}", fixed_array<int, 4> {1, 2, 3, 4}) << environment::new_line;
console::out << string::format("{}", list<int> {1, 2, 3, 4}) << environment::new_line;
console::out << string::format("{}", array_list {1, 2, 3, 4}) << environment::new_line;
console::out << string::format("{}", std::initializer_list<int> {1, 2, 3, 4}) << environment::new_line;
console::out << string::format("{}", std::array<int, 4> {1, 2, 3, 4}) << environment::new_line;
console::out << string::format("{}", std::forward_list<int> {1, 2, 3, 4}) << environment::new_line;
console::out << string::format("{}", std::list<int> {1, 2, 3, 4}) << environment::new_line;
console::out << string::format("{}", std::deque<int> {1, 2, 3, 4}) << environment::new_line;
console::out << string::format("{}", std::vector<int> {1, 2, 3, 4}) << environment::new_line;
}
// This code produces the following output :
//
// [1, 2, 3, 4]
// [1, 2, 3, 4]
// [1, 2, 3, 4]
// [1, 2, 3, 4]
//
// [1, 2, 3, 4]
// [1, 2, 3, 4]
// [1, 2, 3, 4]
// [1, 2, 3, 4]
// [1, 2, 3, 4]
// [1, 2, 3, 4]
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:79
static std::ostream out
Gets the standard output stream. A std::basic_ostream<char_t> that represents the standard output str...
Definition console.hpp:52
static xtd::string new_line() noexcept
Gets the newline string defined for this environment.
Represents a fixed array class.
Definition fixed_array.hpp:23
generic::list< xtd::any_object > array_list
Represents a collection of xtd::any_object.
Definition array_list.hpp:31
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8