37 template<
class type_t>
46 using type =
typename base_type::type;
55 static const reference_wrapper_object
empty;
68 template<
class value_t>
81 template<
class value_t>
85 template<
class value_t>
89 template<
class value_t>
102 template<
class value_t>
106 template<
class value_t>
110 template<
class value_t>
128 bool is_empty() const noexcept {
return !ref_.has_value();}
158 if (!ref_.has_value() && !obj.ref_.has_value())
return 0;
159 if (ref_.has_value() && !obj.ref_.has_value())
return 1;
160 if (!ref_.has_value() && obj.ref_.has_value())
return -1;
161 return &ref_.value().get() < &obj.ref_.value().get() ? -1 : &ref_.value().get() > &obj.ref_.value().get() ? 1 : 0;
167 bool equals(
const xtd::object& value)
const noexcept override {
return dynamic_cast<const reference_wrapper_object*
>(&value) &&
equals(
static_cast<const reference_wrapper_object&
>(value));}
171 bool equals(
const reference_wrapper_object& value)
const noexcept override {
172 if (!ref_.has_value() && !value.ref_.has_value())
return true;
173 if (ref_.has_value() && !value.ref_.has_value())
return false;
174 if (!ref_.has_value() && value.ref_.has_value())
return false;
175 return &ref_.value().get() == &value.ref_.value().get();
171 bool equals(
const reference_wrapper_object& value)
const noexcept override {
…}
201 void reset() noexcept {ref_.reset();}
205 template<
class value_t>
206 void reset(value_t&& value)
noexcept {ref_ = value;}
214 void swap(reference_wrapper_object& value)
noexcept {std::swap(ref_, value.ref_);}
233 template<
typename target_t>
243 template<
typename target_t>
256 reference_wrapper_object& operator =(const reference_wrapper_object& value) noexcept {
256 reference_wrapper_object& operator =(const reference_wrapper_object& value) noexcept {
…}
262 reference_wrapper_object&
operator =(reference_wrapper_object& value)
noexcept {
262 reference_wrapper_object&
operator =(reference_wrapper_object& value)
noexcept {
…}
268 reference_wrapper_object&
operator =(reference_wrapper_object&& value)
noexcept {
269 ref_ = std::move(value.ref_);
268 reference_wrapper_object&
operator =(reference_wrapper_object&& value)
noexcept {
…}
274 template<
class value_t>
275 reference_wrapper_object&
operator =(
const reference_wrapper_object<value_t>& value)
noexcept {
275 reference_wrapper_object&
operator =(
const reference_wrapper_object<value_t>& value)
noexcept {
…}
281 template<
class value_t>
282 reference_wrapper_object&
operator =(reference_wrapper_object<value_t>& value)
noexcept {
282 reference_wrapper_object&
operator =(reference_wrapper_object<value_t>& value)
noexcept {
…}
288 template<
class value_t>
289 reference_wrapper_object&
operator =(reference_wrapper_object<value_t>&& value)
noexcept {
290 ref_ = std::move(value.ref_);
289 reference_wrapper_object&
operator =(reference_wrapper_object<value_t>&& value)
noexcept {
…}
295 template<
class value_t>
296 reference_wrapper_object&
operator =(
const std::reference_wrapper<value_t>& value)
noexcept {
296 reference_wrapper_object&
operator =(
const std::reference_wrapper<value_t>& value)
noexcept {
…}
302 template<
class value_t>
303 reference_wrapper_object&
operator =(std::reference_wrapper<value_t>& value)
noexcept {
303 reference_wrapper_object&
operator =(std::reference_wrapper<value_t>& value)
noexcept {
…}
321 template<
class value_t>
322 reference_wrapper_object&
operator =(value_t&& value)
noexcept {
322 reference_wrapper_object&
operator =(value_t&& value)
noexcept {
…}
343 explicit operator bool() const noexcept {
return ref_.has_value();}
349 friend bool operator ==(
const reference_wrapper_object& lhs,
const type_t& rhs)
noexcept {
return lhs.equals(rhs);}
354 friend bool operator !=(
const reference_wrapper_object& lhs,
const type_t& rhs)
noexcept {
return !lhs.equals(rhs);}
363 friend std::strong_ordering
operator <=>(
const reference_wrapper_object& lhs,
const type_t& rhs)
noexcept {
365 if (
dynamic_cast<const type_t*
>(rhs_ptr) && lhs.compare_to(
static_cast<const type_t&
>(rhs)) < 0)
return std::strong_ordering::less;
366 if (
dynamic_cast<const type_t*
>(rhs_ptr) && lhs.compare_to(
static_cast<const type_t&
>(rhs)) > 0)
return std::strong_ordering::greater;
367 if (
dynamic_cast<const type_t*
>(rhs_ptr) && lhs.compare_to(
static_cast<const type_t&
>(rhs)) == 0)
return std::strong_ordering::equivalent;
368 return std::strong_ordering::less;
363 friend std::strong_ordering
operator <=>(
const reference_wrapper_object& lhs,
const type_t& rhs)
noexcept {
…}
373 template<
class other_t>
375 std::optional<base_type> ref_;
378 template<
class type_t>
385 template<
class type_t>
386 reference_wrapper_object(type_t&) -> reference_wrapper_object<type_t>;
static xtd::size combine(args_t... values) noexcept
Combines values into a hash code.
Definition hash_code.hpp:70
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
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
Provides a set of static methods for querying objects that implement ienumerable <type_t>.
Definition enumerable.hpp:58
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
The xtd::reference_wrapper_object is a reference wrapper as std::reference_wrapper.
Definition reference_wrapper_object.hpp:38
reference_wrapper_object() noexcept=default
Initializes a new instance of the xtd::reference_wrapper_object class.
bool equals(const xtd::object &value) const noexcept override
Determines whether the specified object is equal to the current object.
Definition reference_wrapper_object.hpp:167
friend bool operator==(const reference_wrapper_object &lhs, const type_t &rhs) noexcept
Equal to operator with specidied lhs ans rhs values.
Definition reference_wrapper_object.hpp:349
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 refer...
Definition reference_wrapper_object.hpp:111
friend bool operator!=(const reference_wrapper_object &lhs, const type_t &rhs) noexcept
Not equal to operator with specidied lhs ans rhs values.
Definition reference_wrapper_object.hpp:354
reference_wrapper_object(reference_wrapper_object &value) noexcept
Initializes a new instance of the xtd::reference_wrapper_object class with specified reference object...
Definition reference_wrapper_object.hpp:72
reference_wrapper_object(value_t &&value) noexcept
Initializes a new instance of the xtd::reference_wrapper_object class with specified reference.
Definition reference_wrapper_object.hpp:69
reference_wrapper_object & operator=(const reference_wrapper_object &value) noexcept
Assignment operator with specified xtd::reference_wrapper_object value.
Definition reference_wrapper_object.hpp:256
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...
Definition reference_wrapper_object.hpp:82
void swap(reference_wrapper_object &value) noexcept
Swaps this current instance with specified reference object.
Definition reference_wrapper_object.hpp:214
static const reference_wrapper_object empty
Represents the empty xtd::reference_wrapper_object. This field is constant.
Definition reference_wrapper_object.hpp:55
friend std::strong_ordering operator<=>(const reference_wrapper_object &lhs, const type_t &rhs) noexcept
Three-way comparison operator with specidied lhs ans rhs values.
Definition reference_wrapper_object.hpp:363
std::reference_wrapper< type_t > base_type
Represents the base type (std::reference_wrapper<type_t>)
Definition reference_wrapper_object.hpp:44
reference_wrapper_object(base_type &value) noexcept
Initializes a new instance of the xtd::reference_wrapper_object::base_type class with specified refer...
Definition reference_wrapper_object.hpp:93
bool equals(const reference_wrapper_object &value) const noexcept override
Indicates whether the current object is equal to another object of the same type.
Definition reference_wrapper_object.hpp:171
base_type & reference()
Returns the underlying base type reference.
Definition reference_wrapper_object.hpp:138
target_t to_object() const
Gets the stored object with specified target_t type.
target_t to_reference() const
Gets the stored reference with specified target_t type.
type_t & to_object() const
Gets the stored object.
Definition reference_wrapper_object.hpp:228
reference_wrapper_object(const reference_wrapper_object &value) noexcept
Initializes a new instance of the xtd::reference_wrapper_object class with specified reference object...
Definition reference_wrapper_object.hpp:75
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...
Definition reference_wrapper_object.hpp:90
type & to_reference() const
Gets the stored reference.
Definition reference_wrapper_object.hpp:238
void reset() noexcept
Resets the current object. Set the current object to null.
Definition reference_wrapper_object.hpp:201
const base_type & reference() const
Returns the underlying base type reference.
Definition reference_wrapper_object.hpp:132
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...
Definition reference_wrapper_object.hpp:86
reference_wrapper_object(const base_type &value) noexcept
Initializes a new instance of the xtd::reference_wrapper_object::base_type class with specified refer...
Definition reference_wrapper_object.hpp:96
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 refer...
Definition reference_wrapper_object.hpp:107
reference_wrapper_object(base_type &&value) noexcept
Initializes a new instance of the xtd::reference_wrapper_object::base_type class with specified refer...
Definition reference_wrapper_object.hpp:99
typename base_type::type reference_type
Represent the referenced type.
Definition reference_wrapper_object.hpp:48
int32 compare_to(const reference_wrapper_object &obj) const noexcept override
Compares the current instance with another object of the same type.
Definition reference_wrapper_object.hpp:157
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
type & get() const
Gets the stored reference.
Definition reference_wrapper_object.hpp:190
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 refer...
Definition reference_wrapper_object.hpp:103
typename base_type::type type
Represent the referenced type.
Definition reference_wrapper_object.hpp:46
reference_wrapper_object(reference_wrapper_object &&value) noexcept
Initializes a new instance of the xtd::reference_wrapper_object class with specified reference object...
Definition reference_wrapper_object.hpp:78
void reset(xtd::null_ptr null) noexcept
Resets the current object. Set the current object with specified null value.
Definition reference_wrapper_object.hpp:209
void reset(value_t &&value) noexcept
Resets the current object. Set the current object with specified reference.
Definition reference_wrapper_object.hpp:206
xtd::size get_hash_code() const noexcept override
Serves as a hash function for a particular type.
Definition reference_wrapper_object.hpp:197
bool is_empty() const noexcept
Checks if the stored reference is empty.
Definition reference_wrapper_object.hpp:128
@ null_pointer
The pointer is null.
Definition exception_case.hpp:77
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
null_ptr null
Represents a null pointer value.
std::nullptr_t null_ptr
Represents the null_opt alias on std::nullptr_t.
Definition null_ptr.hpp:19
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
Contains xtd::hash_code class.
Contains xtd::icomparable interface.
Contains xtd::iequatable interface.
Provides classes and interfaces that support queries that use Language-Integrated Query (LINQ).
Definition enumerable.hpp:41
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::null_ptr alias.
Contains xtd::object class.
Contains xtd::helpers::exception_case enum class.