Shows how to use format xtd::parse method with numeric values (int8, int16, int32, int64, uint8, uint16, uint32 and uint64).
#include <xtd/console>
#include <xtd/parse>
auto main() -> int {
std::locale::global(std::locale {"en_US.UTF-8"});
console::write_line(i1);
console::write_line(i2);
console::write_line(i3);
console::write_line(i4);
console::write_line(i5);
console::write_line(i6);
console::write_line(i7);
auto i8 =
xtd::parse<int>(
"(42)", number_styles::number | number_styles::allow_parentheses);
console::write_line(i8);
try {
console::write_line(i9);
console::write_line("Exception : {}", e.message());
}
}
The exception that is thrown when a method call is invalid for the object's current state.
Definition system_exception.h:18
int parse< int >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.h:137
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10