template<class type_t>
struct xtd::box< type_t >
Represents a boxed object.
template<class type_t>
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:43
Represents a boxed object.
Definition box.hpp:57
- Inheritance
- xtd::object → xtd::box <type_t>
- Implements
- xtd::icomparable <>, xtd::iequatable <>
- Header
-
- Namespace
- xtd
- Library
- xtd.core
- Examples
- The following example shows how to create and use xtd::box<bool>.
auto stringer = [](
const object&
value) {
return value.to_string();};
bool unboxed_object = true;
auto result = stringer(boxed_object);
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
value_type value
Gets or sets the underlying value.
Definition box.hpp:107
- Examples
- generic_icollection.cpp, generic_ienumerable2.cpp, generic_ienumerator.cpp, and generic_ilist.cpp.
|
using | value_type = type_t |
|
using | reference = type_t & |
| Represents the reference type.
|
|
using | const_reference = const type_t & |
| Represents the cont reference type.
|
|
using | pointer = type_t * |
| Represents the reference type.
|
|
using | const_pointer = const type_t * |
| Represents the cont reference type.
|
|
|
int32 | compare_to (const box &value) const noexcept override |
| Compares the current instance with another object of the same type.
|
|
bool | equals (const object &obj) const noexcept override |
| Determines whether the specified object is equal to the current object.
|
|
bool | equals (const box &value) const noexcept override |
| Indicates whether the current object is equal to another object of the same type.
|
|
xtd::size | get_hash_code () const noexcept override |
| Serves as a hash function for a particular type.
|
|
xtd::string | to_string () const noexcept override |
| Returns a xtd::string that represents the current object.
|
|
xtd::string | to_string (const xtd::string &format) const |
| Converts the value of this instance to its equivalent string representation, using the specified format.
|
|
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 format, and locale.
|
|
|
| object ()=default |
| Create a new instance of the ultimate base class object.
|
|
virtual type_object | get_type () const noexcept |
| Gets the type of the current instance.
|
|
template<class object_t > |
xtd::uptr< object_t > | memberwise_clone () const |
| Creates a shallow copy of the current object.
|
|
template<class object_a_t , class object_b_t > |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are considered equal.
|
|
template<class object_a_t , class object_b_t > |
static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are the same instance.
|
|
◆ value_type
template<class type_t >
using xtd::box< type_t >::value_type = type_t |
Represents the value type.
◆ reference
template<class type_t >
using xtd::box< type_t >::reference = type_t& |
Represents the reference type.
◆ const_reference
template<class type_t >
using xtd::box< type_t >::const_reference = const type_t& |
Represents the cont reference type.
◆ pointer
template<class type_t >
using xtd::box< type_t >::pointer = type_t* |
Represents the reference type.
◆ const_pointer
template<class type_t >
using xtd::box< type_t >::const_pointer = const type_t* |
Represents the cont reference type.
◆ box() [1/3]
◆ box() [2/3]
Initialize a new xtd::box object with specified value.
- Parameters
-
value | Value used to initialize object. |
◆ box() [3/3]
template<class type_t >
template<class ... args_t>
xtd::box< type_t >::box |
( |
args_t &&... |
args | ) |
|
|
inline |
Initialize a new xtd::box object with specified value.
- Parameters
-
...args_t | Params used to initialize object. |
◆ operator value_type()
Cast operator to the value type.
- Returns
- The xtd::box current instnce to
value_type
.
◆ compare_to()
template<class type_t >
|
inlineoverridevirtualnoexcept |
Compares the current instance with another object of the same type.
- Parameters
-
value | An object to compare with this instance. |
- Returns
- A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has these meanings:
Value | Condition |
Less than zero | This instance is less than obj. |
Zero | This instance is equal to obj. |
Greater than zero | This instance is greater than obj. |
Implements xtd::icomparable< box< type_t > >.
◆ equals() [1/2]
template<class type_t >
|
inlineoverridevirtualnoexcept |
Determines whether the specified object is equal to the current object.
- Parameters
-
obj | The object to compare with the current object. |
- Returns
true
if the specified object is equal to the current object. otherwise, false
.
Reimplemented from xtd::object.
◆ equals() [2/2]
template<class type_t >
bool xtd::box< type_t >::equals |
( |
const box< type_t > & |
value | ) |
const |
|
inlineoverridevirtualnoexcept |
Indicates whether the current object is equal to another object of the same type.
- Parameters
-
obj | An object to compare with this object. |
- Returns
true
if the current object is equal to the other parameter; otherwise, false
.
Implements xtd::iequatable< box< type_t > >.
◆ get_hash_code()
template<class type_t >
|
inlineoverridevirtualnoexcept |
◆ to_string() [1/3]
template<class type_t >
|
inlineoverridevirtualnoexcept |
◆ to_string() [2/3]
Converts the value of this instance to its equivalent string representation, using the specified format.
- Parameters
-
format | A value type format string. |
- Returns
- The string representation of the value of this instance as specified by format.
◆ to_string() [3/3]
Converts the value of this instance to its equivalent string representation, using the specified format, and locale.
- Parameters
-
format | A value type format string. |
loc | An std::locale object that contains locale information (see std::locale). |
- Returns
- The string representation of the value of this instance as specified by format.
Implements xtd::iformatable.
◆ parse()
Converts the string to its value_type
equivalent.
- Parameters
-
value | A string containing a value_type to convert. |
- Returns
- A
value_type
equivalent to the native value contained in value.
◆ try_parse()
Converts the string to its value_type
equivalent. A return value indicates whether the conversion succeeded or failed.
- Parameters
-
value | A string containing a value_type to convert. |
result | A value_type equivalent to the native value contained in value. |
- Returns
true
if s was converted successfully; otherwise, false
.
◆ value
Gets or sets the underlying value.
- Parameters
-
value | The value to set to the underlying value. |
The documentation for this struct was generated from the following file: