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:44
box()=default
Initialize a new xtd::box object.
- 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...
Represents a boxed object.
Definition box.hpp:56
value_type value
Gets or sets the underlying value.
Definition box.hpp:106
|
| | 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::unique_ptr_object< object_t > | memberwise_clone () const |
| | Creates a shallow copy of the current object.
|
| |
| virtual int32 | compare_to (const type_t &obj) const noexcept=0 |
| | Compares the current instance with another object of the same type.
|
| |
| virtual bool | equals (const type_t &) const noexcept=0 |
| | Indicates whether the current object is equal to another object of the same type.
|
| |
| 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
Represents the value type.
◆ reference
Represents the reference type.
◆ const_reference
template<class type_t>
| using xtd::box< type_t >::const_reference |
Represents the cont reference type.
◆ pointer
Represents the reference type.
◆ const_pointer
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()
◆ compare_to()
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. |
◆ 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 |
|
inlineoverridenoexcept |
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.
◆ get_hash_code()
template<class type_t>
|
|
inlineoverridevirtualnoexcept |
Serves as a hash function for a particular type.
- Returns
- size_t A hash code for the current object.
Reimplemented from xtd::object.
◆ 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
-
- 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
-
- 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: