xtd 0.2.0
Loading...
Searching...
No Matches
xtd::box_integer< type_t > Class Template Reference
Inheritance diagram for xtd::box_integer< type_t >:
xtd::box< type_t > xtd::object xtd::icomparable< box< type_t > > xtd::iequatable< box< type_t > > xtd::iformatable xtd::interface xtd::extensions::comparison_operators< type_t, icomparable< type_t > > xtd::interface xtd::extensions::equality_operators< type_t, iequatable< type_t > > xtd::interface xtd::box_char< char16 > xtd::box_char< char32 > xtd::box_char< char8 > xtd::box_char< char > xtd::box_char< wchar > xtd::box_floating_point< decimal > xtd::box_floating_point< double > xtd::box_floating_point< float > xtd::box_char< type_t > xtd::box_floating_point< type_t >

Definition

template<class type_t>
class xtd::box_integer< type_t >

Represents a boxed integer object.

class box_integer : public xtd::box<type_t>
Represents a boxed integer object.
Definition box_integer.hpp:54
Represents a boxed object.
Definition box.hpp:56
Inheritance
xtd::objectxtd::box <type_t> → xtd::box_integer <type_t> ///
Namespace
Header
#include <xtd/box_integer>
Namespace
xtd
Library
xtd.core
Remarks
You can use xtd::box to represent a class or structure that does not inherit from xtd::object. Typically used for integral types.
Use xtd::boxing to box an object.
Use xtd::unboxing to unbox an object.
For more information about types, see Native types, boxing and unboxing.
Examples
The following example shows how to create and use xtd::box_integer<int32>.
auto stringer = [](const object& value) {return value.to_string();};
int32 unboxed_object = 42;
box_integer<int32> boxed_object = unboxed_object;
auto result = stringer(boxed_object);
console::write_line("result = {}", result); // Display: result = 42;
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
value_type value
Gets or sets the underlying value.
Definition box.hpp:106

Public Fields

static constexpr type_t max_value
 Represents the largest possible value of type_t. This field is constant.
static constexpr type_t min_value
 Represents the smallest possible value of type_t. This field is constant.

Public Static Methods

static bool is_valid (std::signed_integral auto value) noexcept
 Determines whether the specified signed integral value is within the range of type_t.
static bool is_valid (std::unsigned_integral auto value) noexcept
 Determines whether the specified unsigned integral value is within the range of type_t.
static type_t parse (const xtd::string &value, xtd::number_styles styles)
 Converts the string to its type_t equivalent.
static bool try_parse (const xtd::string &value, type_t &result, xtd::number_styles styles)
 Converts the string to its type_t equivalent.

Additional Inherited Members

using value_type
 Represents the value type.
using reference
 Represents the reference type.
using const_reference
 Represents the cont reference type.
using pointer
 Represents the reference type.
using const_pointer
 Represents the cont reference type.
value_type value
 Gets or sets the underlying value.
 box ()=default
 Initialize a new xtd::box object.
 box (const_reference value)
 Initialize a new xtd::box object with specified value.
template<class ... args_t>
 box (args_t &&...args)
 Initialize a new xtd::box object with specified value.
 operator value_type () const noexcept
 Cast operator to the value 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 globalization::culture_info &culture) 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::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.
static value_type parse (const xtd::string &value)
 Converts the string to its value_type equivalent.
static bool try_parse (const xtd::string &value, reference result) noexcept
 Converts the string to its value_type equivalent. A return value indicates whether the conversion succeeded or failed.
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.

Member Function Documentation

◆ is_valid() [1/2]

template<class type_t>
bool xtd::box_integer< type_t >::is_valid ( std::signed_integral auto value)
inlinestaticnoexcept

Determines whether the specified signed integral value is within the range of type_t.

Parameters
valueThe signed integral value to validate.
Returns
true if value is greater than or equal to min_value and less than or equal to max_value; otherwise, false.
Remarks
This method checks whether a signed integral value can be safely represented by type_t without overflow.
If the value is outside the valid range defined by min_value and max_value, the method returns false.

◆ is_valid() [2/2]

template<class type_t>
bool xtd::box_integer< type_t >::is_valid ( std::unsigned_integral auto value)
inlinestaticnoexcept

Determines whether the specified unsigned integral value is within the range of type_t.

Parameters
valueThe unsigned integral value to validate.
Returns
true if value is less than or equal to max_value; otherwise, false.
Remarks
This method checks whether an unsigned integral value can be safely represented by type_t without overflow.
Since unsigned values are always greater than or equal to zero, only the upper bound (max_value) is validated.

◆ parse()

template<class type_t>
type_t xtd::box_integer< type_t >::parse ( const xtd::string & value,
xtd::number_styles styles )
inlinestatic

Converts the string to its type_t equivalent.

Parameters
valueA string containing a type_t to convert.
Returns
A type_t equivalent to the number contained in value.

◆ try_parse()

template<class type_t>
bool xtd::box_integer< type_t >::try_parse ( const xtd::string & value,
type_t & result,
xtd::number_styles styles )
inlinestatic

Converts the string to its type_t equivalent.

Parameters
valueA string containing a type_t to convert.
Returns
A type_t equivalent to the number contained in value.

Member Data Documentation

◆ max_value

template<class type_t>
type_t xtd::box_integer< type_t >::max_value
staticconstexpr

Represents the largest possible value of type_t. This field is constant.

Remarks
The value of this field is std::numeric_limits<type_t>::max().
Examples
format_floating_point.cpp.

◆ min_value

template<class type_t>
type_t xtd::box_integer< type_t >::min_value
staticconstexpr

Represents the smallest possible value of type_t. This field is constant.

Remarks
The value of this field is std::numeric_limits<type_t>::lowest().
Examples
format_floating_point.cpp.

The documentation for this class was generated from the following file: