xtd 1.0.0
Loading...
Searching...
No Matches
xtd::iequatable< type_t > Class Template Referenceabstract
Inheritance diagram for xtd::iequatable< type_t >:
xtd::interface xtd::extensions::equality_operators< type_t, iequatable< type_t > > xtd::basic_string< char > xtd::basic_string< xtd::char16 > xtd::basic_string< xtd::char32 > xtd::basic_string< xtd::char8 > xtd::basic_string< xtd::wchar > xtd::box< bool > xtd::collections::generic::key_value_pair< xtd::any_object, xtd::any_object > xtd::collections::generic::key_value_pair< key_type, mapped_type > xtd::collections::generic::key_value_pair< xtd::string, xtd::string > xtd::collections::generic::key_value_pair< xtd::drawing::color, float > xtd::collections::generic::list< xtd::any_object > xtd::collections::generic::list< key_type > xtd::collections::generic::list< mapped_type > xtd::collections::generic::list< xtd::string > xtd::collections::generic::list< value_type > xtd::collections::generic::list< xtd_library > xtd::collections::generic::list< thread_pool_item > xtd::collections::generic::list< thread_pool_asynchronous_io_item > xtd::collections::generic::list< xtd::drawing::drawing_2d::gradient_stop > xtd::collections::generic::list< xtd::usize > xtd::collections::generic::list< item > xtd::collections::generic::list< xtd::ref< xtd::forms::form > > xtd::collections::generic::list< xtd::forms::style_sheets::shadow > xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::string > > xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::drawing::color > > xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::drawing::font > > xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::drawing::font_family > > xtd::collections::generic::list< xtd::tunit::test > xtd::reference_wrapper_object< const xtd::forms::control > xtd::reference_wrapper_object< const xtd::forms::form > xtd::reference_wrapper_object< const xtd::forms::menu_item > xtd::reference_wrapper_object< const xtd::forms::tab_page > xtd::reference_wrapper_object< xtd::forms::context_menu > xtd::reference_wrapper_object< xtd::forms::control > xtd::reference_wrapper_object< xtd::forms::ibutton_control > xtd::reference_wrapper_object< xtd::forms::main_menu > xtd::reference_wrapper_object< xtd::forms::status_bar > xtd::reference_wrapper_object< xtd::forms::tool_bar > xtd::reference_wrapper_object< xtd::forms::form > xtd::reference_wrapper_object< xtd::forms::menu_item > xtd::reference_wrapper_object< xtd::forms::message_notifier_button > xtd::reference_wrapper_object< status_bar_panel > xtd::reference_wrapper_object< xtd::forms::tab_page > xtd::reference_wrapper_object< xtd::forms::tool_bar_button > xtd::text::basic_string_builder< char > xtd::text::basic_string_builder< xtd::char16 > xtd::text::basic_string_builder< xtd::char32 > xtd::text::basic_string_builder< xtd::char8 > xtd::text::basic_string_builder< xtd::wchar > xtd::basic_array< type_t, allocator_t > xtd::text::basic_string_builder< char_t, traits_t, allocator_t >

Definition

template<typename type_t>
class xtd::iequatable< type_t >

Defines a generalized method that a value type or class implements to create a type-specific method for determining equality of instances.

Namespace
xtd
Library
xtd.core
Remarks
This interface is implemented by types whose values can be equated (for example, the numeric and string classes). A value type or class implements the equals method to create a type-specific method suitable for determining equality of instances.
The xtd::icomparable<type_t> interface defines the compare_to method, which determines the sort order of instances of the implementing type. The iequatable<T> interface defines the equals method, which determines the equality of instances of the implementing type.
Examples
The following example shows how to use xtd::iequatable interface.
#include <xtd/xtd>
class foo : public iequatable<foo> {
public:
explicit foo(int value) : value_ {value} {}
auto equals(const foo& value) const noexcept -> bool override {return value_ == value.value_;}
private:
int value_ = 0;
};
auto main() -> int {
console::write_line("foo {{42}}.equals(foo {{42}}) = {}", foo {42}.equals(foo {42}));
console::write_line("foo {{42}}.equals(foo {{84}}) = {}", foo {42}.equals(foo {84}));
console::write_line();
console::write_line("!foo {{42}}.equals(foo {{42}}) = {}", !foo {42}.equals(foo {42}));
console::write_line("!foo {{42}}.equals(foo {{84}}) = {}", !foo {42}.equals(foo {84}));
console::write_line();
console::write_line("foo {{42}} == foo {{42}} = {}", foo {42} == foo {42});
console::write_line("foo {{42}} == foo {{84}} = {}", foo {42} == foo {84});
console::write_line();
console::write_line("foo {{42}} != foo {{42}} = {}", foo {42} != foo {42});
console::write_line("foo {{42}} != foo {{84}} = {}", foo {42} != foo {84});
}
// This code produces the following output :
//
// foo {42}.equals(foo {42}) = true
// foo {42}.equals(foo {84}) = false
// !foo {42}.equals(foo {42}) = false
// !foo {42}.equals(foo {84}) = true
// foo {42} == foo {42} = true
// foo {42} == foo {84} = false
// foo {42} != foo {42} = false
// foo {42} != foo {84} = true
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
virtual auto equals(const type_t &) const noexcept -> bool=0
Indicates whether the current object is equal to another object of the same type.
Remarks
Implementing xtd::iequatable<T> automatically enables the equality operators (operator == and operator !=) based on the equals(const type_t& obj) method.

Public Methods

virtual auto equals (const type_t &) const noexcept -> bool=0
 Indicates whether the current object is equal to another object of the same type.

Member Function Documentation

◆ equals()

template<typename type_t>
virtual auto xtd::iequatable< type_t >::equals ( const type_t & ) const -> bool
nodiscardpure virtualnoexcept

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.

Implemented in xtd::any_object, xtd::basic_string< char_t, traits_t, allocator_t >, xtd::console_key_info, xtd::date_time, xtd::diagnostics::switch_object, xtd::diagnostics::trace_listener_collection, xtd::forms::message_notifier_button, xtd::globalization::culture_info, xtd::guid, xtd::index, xtd::net::dns_end_point, xtd::net::ip_address, xtd::net::ip_end_point, xtd::net::socket_address, xtd::net::sockets::ip_packet_information, xtd::net::sockets::ip_v6_multicast_option, xtd::net::sockets::linger_option, xtd::net::sockets::multicast_option, xtd::range, xtd::reflection::assembly, xtd::reflection::assembly_company_attribute, xtd::reflection::assembly_configuration_attribute, xtd::reflection::assembly_copyright_attribute, xtd::reflection::assembly_culture_attribute, xtd::reflection::assembly_description_attribute, xtd::reflection::assembly_file_version_attribute, xtd::reflection::assembly_guid_attribute, xtd::reflection::assembly_identifier_attribute, xtd::reflection::assembly_name_attribute, xtd::reflection::assembly_product_attribute, xtd::reflection::assembly_title_attribute, xtd::reflection::assembly_trademark_attribute, xtd::reflection::assembly_version_attribute, xtd::time_span, xtd::time_zone_info, xtd::toolkit, xtd::type_object, xtd::uri, and xtd::version.


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