52 template<
typename type_t>
55 using underlying_type = type_t;
66 template<
typename ...args_t>
67 box(args_t&& ...args) : value_(args...) {}
73 box& operator =(
const box&) =
default;
74 box& operator =(
const type_t&
value) {
85 const type_t&
value() const noexcept {
return value_;}
88 type_t&
value() noexcept {
return value_;}
100 operator type_t() const noexcept {
return value_;}
107 bool equals(
const object& obj)
const noexcept override {
return is<box<type_t>>(obj) &&
equals(
static_cast<const box<type_t>&
>(obj));}
109 xtd::string to_string() const noexcept
override {
return std::is_integral<type_t>::value || std::is_floating_point<type_t>::value || std::is_enum<type>::value || std::is_pointer<type>::value || std::is_base_of<xtd::object, type_t>::value ?
xtd::string::format(
"{}", value_) : typeof_<type_t>().full_name();}
Represents text as a sequence of character units.
Definition basic_string.hpp:79
Represents a boxed object.
Definition box.hpp:53
box & value(const type_t &value)
Sets de underlying value.
Definition box.hpp:91
type_t & value() noexcept
Gets the underlying value.
Definition box.hpp:88
bool equals(const object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
Definition box.hpp:107
box(args_t &&...args)
Initialize a new xtd::box object with specified value.
Definition box.hpp:67
bool equals(const box &value) const noexcept override
Indicates whether the current object is equal to another object of the same type.
Definition box.hpp:108
static bool try_parse(const xtd::string &value, type_t &result) noexcept
Converts the string to its type_t equivalent. A return value indicates whether the conversion succeed...
Definition box.hpp:133
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
Definition box.hpp:109
box(const type_t &value)
Initialize a new xtd::box object with specified value.
Definition box.hpp:63
box()=default
Initialize a new xtd::box object.
int32 compare_to(const box &value) const noexcept override
Compares the current instance with another object of the same type.
Definition box.hpp:106
const type_t & value() const noexcept
Gets the underlying value.
Definition box.hpp:85
static type_t parse(const xtd::string &value)
Converts the string to its type_t equivalent.
Definition box.hpp:127
xtd::string to_string(const xtd::string &format, const std::locale &loc) const override
Converts the value of this instance to its equivalent string representation, using the specified form...
Definition box.hpp:118
xtd::string to_string(const xtd::string &format) const
Converts the value of this instance to its equivalent string representation, using the specified form...
Definition box.hpp:113
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:42
Contains xtd::convert_string class.
Contains enum_ and enum_ut_ keywords.
Contains xtd::collections::generic::helpers::equator struct.
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
Contains xtd::collections::generic::helpers::comparer struct.
Contains xtd::icomparable interface.
Contains xtd::iequatable interface.
Contains xtd::invalid_cast_exception exception.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Contains xtd::object class.
Contains xtd::string alias.
Implements a function object for compare data.
Definition comparer.hpp:36
Implements a function object for performing comparisons. Unless specialised, invokes operator== on ty...
Definition equator.hpp:37
Contains xtd fundamental types.