xtd 0.2.0
xtd::reference_wrapper_object< type_t > Class Template Reference
Inheritance diagram for xtd::reference_wrapper_object< type_t >:
xtd::object xtd::icomparable< reference_wrapper_object< type_t > > xtd::iequatable< reference_wrapper_object< type_t > > xtd::interface xtd::extensions::comparison_operators< type_t, icomparable< type_t > > xtd::interface xtd::extensions::equality_operators< type_t, iequatable< type_t > >

Definition

template<class type_t>
class xtd::reference_wrapper_object< type_t >

The xtd::reference_wrapper_object is a reference wrapper as std::reference_wrapper.

Library
xtd.core
Examples
This example shows to use xtd::reference_wrapper_object with xtd::version class
version ver = version {1, 2, 3};
console::write_line("version = {}", ver_ref.to_string());
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
The xtd::reference_wrapper_object is a reference wrapper as std::reference_wrapper.
Definition reference_wrapper_object.hpp:38
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
Represents the version number of an assembly, operating system, or the xtd. This class cannot be inhe...
Definition version.hpp:114
reference_wrapper_object< type_t > create_reference_wrapper_object(type_t &arg) noexcept
xtd::create_reference_wrapper_object operator. This operator creates a xtd::reference_wrapper_object ...
Definition create_reference_wrapper_object.hpp:24

Public Aliases

using base_type
 Represents the base type (std::reference_wrapper<type_t>)
 
using type
 Represent the referenced type.
 
using reference_type
 Represent the referenced type.
 

Public Static Fields

static const reference_wrapper_object empty
 Represents the empty xtd::reference_wrapper_object. This field is constant.
 

Public Operators

reference_wrapper_objectoperator= (const reference_wrapper_object &value) noexcept
 Assignment operator with specified xtd::reference_wrapper_object value.
 
reference_wrapper_objectoperator= (reference_wrapper_object &value) noexcept
 Assignment operator with specified xtd::reference_wrapper_object value.
 
reference_wrapper_objectoperator= (reference_wrapper_object &&value) noexcept
 Assignment operator with specified xtd::reference_wrapper_object value.
 
template<class value_t>
reference_wrapper_objectoperator= (const reference_wrapper_object< value_t > &value) noexcept
 Assignment operator with specified xtd::reference_wrapper_object value.
 
template<class value_t>
reference_wrapper_objectoperator= (reference_wrapper_object< value_t > &value) noexcept
 Assignment operator with specified xtd::reference_wrapper_object value.
 
template<class value_t>
reference_wrapper_objectoperator= (reference_wrapper_object< value_t > &&value) noexcept
 Assignment operator with specified xtd::reference_wrapper_object value.
 
template<class value_t>
reference_wrapper_objectoperator= (const std::reference_wrapper< value_t > &value) noexcept
 Assignment operator with specified xtd::reference_wrapper_object::base_type value.
 
template<class value_t>
reference_wrapper_objectoperator= (std::reference_wrapper< value_t > &value) noexcept
 Assignment operator with specified xtd::reference_wrapper_object::base_type value.
 
reference_wrapper_objectoperator= (const base_type &value) noexcept
 Assignment operator with specified xtd::reference_wrapper_object::base_type value.
 
reference_wrapper_objectoperator= (base_type &value) noexcept
 Assignment operator with specified xtd::reference_wrapper_object::base_type value.
 
template<class value_t>
reference_wrapper_objectoperator= (value_t &&value) noexcept
 Assignment operator with specified xtd::reference_wrapper_object::base_type value.
 
 operator type & () const
 Gets the stored object.
 
 operator bool () const noexcept
 Checks if the stored reference is not empty.
 

Public Constructors

 reference_wrapper_object () noexcept=default
 Initializes a new instance of the xtd::reference_wrapper_object class.
 
 reference_wrapper_object (xtd::null_ptr null) noexcept
 Initializes a new instance of the xtd::reference_wrapper_object class with specified null pointer.
 
template<class value_t>
 reference_wrapper_object (value_t &&value) noexcept
 Initializes a new instance of the xtd::reference_wrapper_object class with specified reference.
 
 reference_wrapper_object (reference_wrapper_object &value) noexcept
 Initializes a new instance of the xtd::reference_wrapper_object class with specified reference object.
 
 reference_wrapper_object (const reference_wrapper_object &value) noexcept
 Initializes a new instance of the xtd::reference_wrapper_object class with specified reference object.
 
 reference_wrapper_object (reference_wrapper_object &&value) noexcept
 Initializes a new instance of the xtd::reference_wrapper_object class with specified reference object.
 
template<class value_t>
 reference_wrapper_object (reference_wrapper_object< value_t > &value) noexcept
 Initializes a new instance of the xtd::reference_wrapper_object class with specified reference object.
 
template<class value_t>
 reference_wrapper_object (const reference_wrapper_object< value_t > &value) noexcept
 Initializes a new instance of the xtd::reference_wrapper_object class with specified reference object.
 
template<class value_t>
 reference_wrapper_object (reference_wrapper_object< value_t > &&value) noexcept
 Initializes a new instance of the xtd::reference_wrapper_object class with specified reference object.
 
 reference_wrapper_object (base_type &value) noexcept
 Initializes a new instance of the xtd::reference_wrapper_object::base_type class with specified reference object.
 
 reference_wrapper_object (const base_type &value) noexcept
 Initializes a new instance of the xtd::reference_wrapper_object::base_type class with specified reference object.
 
 reference_wrapper_object (base_type &&value) noexcept
 Initializes a new instance of the xtd::reference_wrapper_object::base_type class with specified reference object.
 
template<class value_t>
 reference_wrapper_object (std::reference_wrapper< value_t > &value) noexcept
 Initializes a new instance of the xtd::reference_wrapper_object::base_type class with specified reference object.
 
template<class value_t>
 reference_wrapper_object (const std::reference_wrapper< value_t > &value) noexcept
 Initializes a new instance of the xtd::reference_wrapper_object::base_type class with specified reference object.
 
template<class value_t>
 reference_wrapper_object (std::reference_wrapper< value_t > &&value) noexcept
 Initializes a new instance of the xtd::reference_wrapper_object::base_type class with specified reference object.
 

Public Properties

bool is_empty () const noexcept
 Checks if the stored reference is empty.
 
const base_typereference () const
 Returns the underlying base type reference.
 
base_typereference ()
 Returns the underlying base type reference.
 

Public Methods

int32 compare_to (const reference_wrapper_object &obj) const noexcept override
 Compares the current instance with another object of the same type.
 
bool equals (const xtd::object &value) const noexcept override
 Determines whether the specified object is equal to the current object.
 
bool equals (const reference_wrapper_object &value) const noexcept override
 Indicates whether the current object is equal to another object of the same type.
 
typeget () const
 Gets the stored reference.
 
xtd::size get_hash_code () const noexcept override
 Serves as a hash function for a particular type.
 
void reset () noexcept
 Resets the current object. Set the current object to null.
 
template<class value_t>
void reset (value_t &&value) noexcept
 Resets the current object. Set the current object with specified reference.
 
void reset (xtd::null_ptr null) noexcept
 Resets the current object. Set the current object with specified null value.
 
void swap (reference_wrapper_object &value) noexcept
 Swaps this current instance with specified reference object.
 
type_t & to_object () const
 Gets the stored object.
 
template<typename target_t>
target_t to_object () const
 Gets the stored object with specified target_t type.
 
typeto_reference () const
 Gets the stored reference.
 
template<typename target_t>
target_t to_reference () const
 Gets the stored reference with specified target_t type.
 
xtd::string to_string () const noexcept override
 Returns a xtd::string that represents the current object.
 

Additional Inherited Members

 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.
 

Member Typedef Documentation

◆ base_type

template<class type_t>
using xtd::reference_wrapper_object< type_t >::base_type

Represents the base type (std::reference_wrapper<type_t>)

◆ type

template<class type_t>
using xtd::reference_wrapper_object< type_t >::type

Represent the referenced type.

◆ reference_type

template<class type_t>
using xtd::reference_wrapper_object< type_t >::reference_type

Represent the referenced type.

Constructor & Destructor Documentation

◆ reference_wrapper_object() [1/15]

template<class type_t>
xtd::reference_wrapper_object< type_t >::reference_wrapper_object ( )
defaultnoexcept

Initializes a new instance of the xtd::reference_wrapper_object class.

◆ reference_wrapper_object() [2/15]

template<class type_t>
xtd::reference_wrapper_object< type_t >::reference_wrapper_object ( xtd::null_ptr null)
inlinenoexcept

Initializes a new instance of the xtd::reference_wrapper_object class with specified null pointer.

Parameters
nullThe null pointer.

◆ reference_wrapper_object() [3/15]

template<class type_t>
template<class value_t>
xtd::reference_wrapper_object< type_t >::reference_wrapper_object ( value_t && value)
inlinenoexcept

Initializes a new instance of the xtd::reference_wrapper_object class with specified reference.

Parameters
valueThe reference.

◆ reference_wrapper_object() [4/15]

template<class type_t>
xtd::reference_wrapper_object< type_t >::reference_wrapper_object ( reference_wrapper_object< type_t > & value)
inlinenoexcept

Initializes a new instance of the xtd::reference_wrapper_object class with specified reference object.

Parameters
valueThe reference object.

◆ reference_wrapper_object() [5/15]

template<class type_t>
xtd::reference_wrapper_object< type_t >::reference_wrapper_object ( const reference_wrapper_object< type_t > & value)
inlinenoexcept

Initializes a new instance of the xtd::reference_wrapper_object class with specified reference object.

Parameters
valueThe reference object.

◆ reference_wrapper_object() [6/15]

template<class type_t>
xtd::reference_wrapper_object< type_t >::reference_wrapper_object ( reference_wrapper_object< type_t > && value)
inlinenoexcept

Initializes a new instance of the xtd::reference_wrapper_object class with specified reference object.

Parameters
valueThe reference object.

◆ reference_wrapper_object() [7/15]

template<class type_t>
template<class value_t>
xtd::reference_wrapper_object< type_t >::reference_wrapper_object ( reference_wrapper_object< value_t > & value)
inlinenoexcept

Initializes a new instance of the xtd::reference_wrapper_object class with specified reference object.

Parameters
valueThe reference object.

◆ reference_wrapper_object() [8/15]

template<class type_t>
template<class value_t>
xtd::reference_wrapper_object< type_t >::reference_wrapper_object ( const reference_wrapper_object< value_t > & value)
inlinenoexcept

Initializes a new instance of the xtd::reference_wrapper_object class with specified reference object.

Parameters
valueThe reference object.

◆ reference_wrapper_object() [9/15]

template<class type_t>
template<class value_t>
xtd::reference_wrapper_object< type_t >::reference_wrapper_object ( reference_wrapper_object< value_t > && value)
inlinenoexcept

Initializes a new instance of the xtd::reference_wrapper_object class with specified reference object.

Parameters
valueThe reference object.

◆ reference_wrapper_object() [10/15]

template<class type_t>
xtd::reference_wrapper_object< type_t >::reference_wrapper_object ( base_type & value)
inlinenoexcept

Initializes a new instance of the xtd::reference_wrapper_object::base_type class with specified reference object.

Parameters
valueThe reference object.

◆ reference_wrapper_object() [11/15]

template<class type_t>
xtd::reference_wrapper_object< type_t >::reference_wrapper_object ( const base_type & value)
inlinenoexcept

Initializes a new instance of the xtd::reference_wrapper_object::base_type class with specified reference object.

Parameters
valueThe reference object.

◆ reference_wrapper_object() [12/15]

template<class type_t>
xtd::reference_wrapper_object< type_t >::reference_wrapper_object ( base_type && value)
inlinenoexcept

Initializes a new instance of the xtd::reference_wrapper_object::base_type class with specified reference object.

Parameters
valueThe reference object.

◆ reference_wrapper_object() [13/15]

template<class type_t>
template<class value_t>
xtd::reference_wrapper_object< type_t >::reference_wrapper_object ( std::reference_wrapper< value_t > & value)
inlinenoexcept

Initializes a new instance of the xtd::reference_wrapper_object::base_type class with specified reference object.

Parameters
valueThe reference object.

◆ reference_wrapper_object() [14/15]

template<class type_t>
template<class value_t>
xtd::reference_wrapper_object< type_t >::reference_wrapper_object ( const std::reference_wrapper< value_t > & value)
inlinenoexcept

Initializes a new instance of the xtd::reference_wrapper_object::base_type class with specified reference object.

Parameters
valueThe reference object.

◆ reference_wrapper_object() [15/15]

template<class type_t>
template<class value_t>
xtd::reference_wrapper_object< type_t >::reference_wrapper_object ( std::reference_wrapper< value_t > && value)
inlinenoexcept

Initializes a new instance of the xtd::reference_wrapper_object::base_type class with specified reference object.

Parameters
valueThe reference object.

Member Function Documentation

◆ is_empty()

template<class type_t>
bool xtd::reference_wrapper_object< type_t >::is_empty ( ) const
inlinenoexcept

Checks if the stored reference is empty.

Returns
trueif stored reference is empty; otherwise false.
Examples
The following code shows how to use xtd::reference_wrapper_object::get and xtd::reference_wrapper_object::is_empty
template<class value_t>
void print_value(const reference_wrapper_object<value_t>& value) {
if (value.is_empty()) println("value is empty");
else println("value = {}", value.get());
}
type & get() const
Gets the stored reference.
Definition reference_wrapper_object.hpp:190
bool is_empty() const noexcept
Checks if the stored reference is empty.
Definition reference_wrapper_object.hpp:128
void println()
Writes the current line terminator to the standard output stream using the specified format informati...
Definition println.hpp:167

◆ reference() [1/2]

template<class type_t>
const base_type & xtd::reference_wrapper_object< type_t >::reference ( ) const
inline

Returns the underlying base type reference.

Returns
The underlying base type reference.

◆ reference() [2/2]

template<class type_t>
base_type & xtd::reference_wrapper_object< type_t >::reference ( )
inline

Returns the underlying base type reference.

Returns
The underlying base type reference.

◆ compare_to()

template<class type_t>
int32 xtd::reference_wrapper_object< type_t >::compare_to ( const reference_wrapper_object< type_t > & obj) const
inlineoverridenoexcept

Compares the current instance with another object of the same type.

Parameters
objAn 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>
bool xtd::reference_wrapper_object< type_t >::equals ( const xtd::object & value) const
inlineoverridevirtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
objThe 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::reference_wrapper_object< type_t >::equals ( const reference_wrapper_object< type_t > & value) const
inlineoverridenoexcept

Indicates whether the current object is equal to another object of the same type.

Parameters
objAn object to compare with this object.
Returns
true if the current object is equal to the other parameter; otherwise, false.

◆ get()

template<class type_t>
type & xtd::reference_wrapper_object< type_t >::get ( ) const
inline

Gets the stored reference.

Returns
The stored reference.
Exceptions
xtd::null_pointer_exceptionIf xtd::reference_wrapper_object is empty.
Examples
The following code shows how to use xtd::reference_wrapper_object::get and xtd::reference_wrapper_object::is_empty
template<class value_t>
void print_value(const reference_wrapper_object<value_t>& value) {
if (value.is_empty()) println("value is empty");
else println("value = {}", value.get());
}

◆ get_hash_code()

template<class type_t>
xtd::size xtd::reference_wrapper_object< type_t >::get_hash_code ( ) const
inlineoverridevirtualnoexcept

Serves as a hash function for a particular type.

Returns
size_t A hash code for the current object.

Reimplemented from xtd::object.

◆ reset() [1/3]

template<class type_t>
void xtd::reference_wrapper_object< type_t >::reset ( )
inlinenoexcept

Resets the current object. Set the current object to null.

Remarks
xtd::reference_wrapper_object::usecount property is decremented. If alias count equal 0 the object T is deleted.

◆ reset() [2/3]

template<class type_t>
template<class value_t>
void xtd::reference_wrapper_object< type_t >::reset ( value_t && value)
inlinenoexcept

Resets the current object. Set the current object with specified reference.

Parameters
valueThe reference to assign the current object. It can be null.
Remarks
xtd::reference_wrapper_object::usecount property is decremented. If alias count equal 0 the object T is deleted.

◆ reset() [3/3]

template<class type_t>
void xtd::reference_wrapper_object< type_t >::reset ( xtd::null_ptr null)
inlinenoexcept

Resets the current object. Set the current object with specified null value.

Parameters
nullThe null value.

◆ swap()

template<class type_t>
void xtd::reference_wrapper_object< type_t >::swap ( reference_wrapper_object< type_t > & value)
inlinenoexcept

Swaps this current instance with specified reference object.

Parameters
valueThe reference object to swap with this current instance.

◆ to_object() [1/2]

template<class type_t>
type_t & xtd::reference_wrapper_object< type_t >::to_object ( ) const
inline

Gets the stored object.

Returns
The stored object.
Exceptions
xtd::null_pointer_exceptionIf xtd::reference_wrapper_object is empty.
Examples
The following code shows how to use xtd::reference_wrapper_object::to_object and xtd::reference_wrapper_object::is_empty
template<class value_t>
void print_value(const reference_wrapper_object<value_t>& value) {
if (value.is_empty()) println("value is empty");
else println("value = {}", value.get());
}

◆ to_object() [2/2]

template<class type_t>
template<typename target_t>
target_t xtd::reference_wrapper_object< type_t >::to_object ( ) const

Gets the stored object with specified target_t type.

Returns
The stored object.
Exceptions
xtd::cast_exceptionIf the current object can't be casted in target_t.

◆ to_reference() [1/2]

template<class type_t>
type & xtd::reference_wrapper_object< type_t >::to_reference ( ) const
inline

Gets the stored reference.

Returns
The stored reference.

◆ to_reference() [2/2]

template<class type_t>
template<typename target_t>
target_t xtd::reference_wrapper_object< type_t >::to_reference ( ) const

Gets the stored reference with specified target_t type.

Returns
The stored reference.
Exceptions
xtd::cast_exceptionIf the current object can't be casted in target_t.

◆ to_string()

template<class type_t>
xtd::string xtd::reference_wrapper_object< type_t >::to_string ( ) const
overridevirtualnoexcept

Returns a xtd::string that represents the current object.

Returns
A string that represents the current object.

Reimplemented from xtd::object.

◆ operator=() [1/11]

template<class type_t>
reference_wrapper_object & xtd::reference_wrapper_object< type_t >::operator= ( const reference_wrapper_object< type_t > & value)
inlinenoexcept

Assignment operator with specified xtd::reference_wrapper_object value.

Parameters
valueThe value to assign.

◆ operator=() [2/11]

template<class type_t>
reference_wrapper_object & xtd::reference_wrapper_object< type_t >::operator= ( reference_wrapper_object< type_t > & value)
inlinenoexcept

Assignment operator with specified xtd::reference_wrapper_object value.

Parameters
valueThe value to assign.

◆ operator=() [3/11]

template<class type_t>
reference_wrapper_object & xtd::reference_wrapper_object< type_t >::operator= ( reference_wrapper_object< type_t > && value)
inlinenoexcept

Assignment operator with specified xtd::reference_wrapper_object value.

Parameters
valueThe value to assign.

◆ operator=() [4/11]

template<class type_t>
template<class value_t>
reference_wrapper_object & xtd::reference_wrapper_object< type_t >::operator= ( const reference_wrapper_object< value_t > & value)
inlinenoexcept

Assignment operator with specified xtd::reference_wrapper_object value.

Parameters
valueThe value to assign.

◆ operator=() [5/11]

template<class type_t>
template<class value_t>
reference_wrapper_object & xtd::reference_wrapper_object< type_t >::operator= ( reference_wrapper_object< value_t > & value)
inlinenoexcept

Assignment operator with specified xtd::reference_wrapper_object value.

Parameters
valueThe value to assign.

◆ operator=() [6/11]

template<class type_t>
template<class value_t>
reference_wrapper_object & xtd::reference_wrapper_object< type_t >::operator= ( reference_wrapper_object< value_t > && value)
inlinenoexcept

Assignment operator with specified xtd::reference_wrapper_object value.

Parameters
valueThe value to assign.

◆ operator=() [7/11]

template<class type_t>
template<class value_t>
reference_wrapper_object & xtd::reference_wrapper_object< type_t >::operator= ( const std::reference_wrapper< value_t > & value)
inlinenoexcept

Assignment operator with specified xtd::reference_wrapper_object::base_type value.

Parameters
valueThe value to assign.

◆ operator=() [8/11]

template<class type_t>
template<class value_t>
reference_wrapper_object & xtd::reference_wrapper_object< type_t >::operator= ( std::reference_wrapper< value_t > & value)
inlinenoexcept

Assignment operator with specified xtd::reference_wrapper_object::base_type value.

Parameters
valueThe value to assign.

◆ operator=() [9/11]

template<class type_t>
reference_wrapper_object & xtd::reference_wrapper_object< type_t >::operator= ( const base_type & value)
inlinenoexcept

Assignment operator with specified xtd::reference_wrapper_object::base_type value.

Parameters
valueThe value to assign.

◆ operator=() [10/11]

template<class type_t>
reference_wrapper_object & xtd::reference_wrapper_object< type_t >::operator= ( base_type & value)
inlinenoexcept

Assignment operator with specified xtd::reference_wrapper_object::base_type value.

Parameters
valueThe value to assign.

◆ operator=() [11/11]

template<class type_t>
template<class value_t>
reference_wrapper_object & xtd::reference_wrapper_object< type_t >::operator= ( value_t && value)
inlinenoexcept

Assignment operator with specified xtd::reference_wrapper_object::base_type value.

Parameters
valueThe value to assign.

◆ operator type &()

template<class type_t>
xtd::reference_wrapper_object< type_t >::operator type & ( ) const
inline

Gets the stored object.

Returns
The stored object.
Exceptions
xtd::null_pointer_exceptionIf xtd::reference_wrapper_object is empty.
Examples
The following code shows how to use xtd::reference_wrapper_object::operator type& and xtd::reference_wrapper_object::is_empty
template<class value_t>
void print_value(const reference_wrapper_object<value_t>& value) {
if (value.is_empty()) println("value is empty");
else println("value = {}", value.get());
}

◆ operator bool()

template<class type_t>
xtd::reference_wrapper_object< type_t >::operator bool ( ) const
inlineexplicitnoexcept

Checks if the stored reference is not empty.

Returns
trueif stored reference is not empty; otherwise false.

Member Data Documentation

◆ empty

template<class type_t>
const reference_wrapper_object xtd::reference_wrapper_object< type_t >::empty
static

Represents the empty xtd::reference_wrapper_object. This field is constant.


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