template<typename type_t>
class xtd::box< type_t >
Represents a boxed object.
Represents a boxed object.
Definition box.hpp:53
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
- 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);
const type_t & value() const noexcept
Gets the underlying value.
Definition box.hpp:85
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
- Examples
- generic_icollection.cpp, generic_ienumerable2.cpp, generic_ienumerator.cpp, and generic_ilist.cpp.
|
using | underlying_type = type_t |
|
|
| box ()=default |
| Initialize a new xtd::box object.
|
|
| box (const type_t &value) |
| Initialize a new xtd::box object with specified value.
|
|
template<typename ... args_t> |
| box (args_t &&...args) |
| Initialize a new xtd::box object with specified value.
|
|
|
const type_t & | value () const noexcept |
| Gets the underlying value.
|
|
type_t & | value () noexcept |
| Gets the underlying value.
|
|
box & | value (const type_t &value) |
| Sets de underlying value.
|
|
|
| operator type_t () const noexcept |
|
|
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::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.
|
|
|
static type_t | parse (const xtd::string &value) |
| Converts the string to its type_t equivalent.
|
|
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 succeeded or failed.
|
|
|
| object ()=default |
| Create a new instance of the ultimate base class object.
|
|
virtual size_t | get_hash_code () const noexcept |
| Serves as a hash function for a particular type.
|
|
virtual type_object | get_type () const noexcept |
| Gets the type of the current instance.
|
|
template<typename object_t > |
xtd::uptr< object_t > | memberwise_clone () const |
| Creates a shallow copy of the current object.
|
|
template<typename object_a_t , typename 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<typename object_a_t , typename 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.
|
|
◆ box() [1/3]
template<typename type_t >
◆ box() [2/3]
template<typename type_t >
xtd::box< type_t >::box |
( |
const type_t & |
value | ) |
|
|
inline |
Initialize a new xtd::box object with specified value.
- Parameters
-
value | Value used to initialize object. |
◆ box() [3/3]
template<typename type_t >
template<typename ... 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. |
◆ value() [1/3]
template<typename type_t >
const type_t & xtd::box< type_t >::value |
( |
| ) |
const |
|
inlinenoexcept |
Gets the underlying value.
- Returns
- Return the underlying value.
◆ value() [2/3]
template<typename type_t >
Gets the underlying value.
- Returns
- Return the underlying value.
◆ value() [3/3]
template<typename type_t >
box & xtd::box< type_t >::value |
( |
const type_t & |
value | ) |
|
|
inline |
Sets de underlying value.
- Parameters
-
value | The value to set to the underlying value. |
◆ compare_to()
template<typename type_t >
|
inlineoverridevirtualnoexcept |
Compares the current instance with another object of the same type.
- Parameters
-
obj | 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<typename 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.
- Examples
- The following code example compares the current instance with another object.
#include <xtd/console>
auto main() -> int {
auto object1 = new_ptr<object>();
auto object2 = new_ptr<object>();
auto object3 = object2;
object3 = object1;
}
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Reimplemented from xtd::object.
◆ equals() [2/2]
template<typename type_t >
bool xtd::box< type_t >::equals |
( |
const box< type_t > & |
| ) |
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 > >.
◆ to_string() [1/3]
template<typename type_t >
|
inlineoverridevirtualnoexcept |
Returns a xtd::string that represents the current object.
- Returns
- A string that represents the current object.
- Examples
- The following code example demonstrates what to_string returns.
#include <xtd/xtd>
namespace examples {
namespace object_test {
class object1 :
public object {
};
}
}
auto main() -> int {
ptr<object> obj1 = new_ptr<examples::object_test::object1>();
ptr<object> obj2 = new_ptr<date_time>(1971, 1, 5, 23, 5, 0);
}
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
Reimplemented from xtd::object.
- Examples
- application_restart.cpp, console_out.cpp, and generic_ienumerable2.cpp.
◆ to_string() [2/3]
template<typename type_t >
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]
template<typename type_t >
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()
template<typename type_t >
Converts the string to its type_t equivalent.
- Parameters
-
value | A string containing a type_t to convert. |
- Returns
- A type_t equivalent to the number contained in value.
◆ try_parse()
template<typename type_t >
Converts the string to its type_t equivalent. A return value indicates whether the conversion succeeded or failed.
- Parameters
-
value | A string containing a type_t to convert. |
result | A type_t equivalent to the number contained in value. |
- Returns
- true if s was converted successfully; otherwise, false.
The documentation for this class was generated from the following file: