xtd 1.0.0
Loading...
Searching...
No Matches
generic_list_convert_all.cpp

Shows how to use xtd::collections::generic::list::convert_all method.

#include <xtd/xtd>
using namespace xtd::drawing;
class example {
public:
static auto main() {
auto lpf = list<point_f> {};
lpf.add(point_f {27.8f, 32.62f});
lpf.add(point_f {99.3f, 147.273f});
lpf.add(point_f {7.5f, 1412.2f});
for (const auto& p : lpf)
list<point> lp = lpf.convert_all<point>(converter<point, const point_f&> {point_f_to_point});
for (const auto& p : lp)
}
static point point_f_to_point(const point_f& pf) {
return {as<int>(pf.x), as<int>(pf.y)};
}
};
startup_(example::main);
// This code produces the following output :
//
//
// {x=27.8, y=32.62}
// {x=99.3, y=147.273}
// {x=7.5, y=1412.2}
//
// {x=28, y=33}
// {x=99, y=147}
// {x=8, y=1412}
static auto write_line() -> void
Writes the current line terminator to the standard output stream using the specified format informati...
xtd::delegate< output_t(input_t input)> converter
Represents a method that converts an object from one type to another type.
Definition converter.hpp:33
#define startup_(...)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:278
auto as(any_object &o) -> type_t
Casts a type into another type.
Definition __as_any_object.hpp:60
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition point_f.hpp:35
float x
Gets or sets the x-coordinate of this xtd::drawing::point_f.
Definition point_f.hpp:67
float y
Gets or sets the y-coordinate of this xtd::drawing::point_f.
Definition point_f.hpp:71
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.hpp:54