xtd 0.2.0
array_list2.cpp

Shows how to use xtd::collections::array_list alias.

#include <xtd/collections/array_list>
#include <xtd/console>
#include <xtd/platform_id>
#include <xtd/time_span>
using namespace xtd;
using namespace xtd::collections;
auto main() -> int {
auto items = array_list {true, 42, "This is a string", platform_id::win32s, u8"Another string", 4.2f, 2_h + 25_min + 43_s};
console::write_line("items = [{}]", string::join(", ", items));
console::write_line("items = {}", items);
for (auto item : items) {
if (is<string>(item)) console::write_line("{}", as<string>(item).to_upper().quoted());
else if (is<platform_id>(item)) console::write_line("{}::{}", typeof_(as<platform_id>(item)).name(), item);
else console::write_line("{}", item);
}
}
// This code produces the following output :
//
// items = [true, 42, This is a string, win32s, Another string, 4.2, 02:25:43]
// items = [true, 42, This is a string, win32s, Another string, 4.2, 02:25:43]
//
// true
// 42
// "THIS IS A STRING"
// platform_id::win32s
// "ANOTHER STRING"
// 4.2
// 02:25:43
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
generic::list< xtd::any_object > array_list
Represents a collection of xtd::any_object.
Definition array_list.hpp:31
#define typeof_
Used to obtain the type object of a specified type or object.
Definition typeof.hpp:45
type_t as(any_object &o)
Casts a type into another type.
Definition __as_any_object.hpp:59
bool is(xtd::any value)
Checks if the result of an expression is compatible with a given type.
Definition is.hpp:485
@ win32s
The operating system is Win32s. Win32s is a layer that runs on 16-bit versions of Windows to provide ...
Definition platform_id.hpp:22
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