55#include " collections/generic/icomparer.hpp"
66#include " collections/generic/iequality_comparer.hpp"
77#include " argument_exception.hpp"
8+ #include " as.hpp"
89#include " string_comparison.hpp"
910#include " string.hpp"
1011
@@ -58,13 +59,13 @@ namespace xtd {
5859 // / @remarks The xtd::string_comparer::compare(const string&, const string&) method is slightly more efficient than the xtd::string_comparer::compare(const object_t&, consy object_t&) method because no conversion of the `x` and `y` arguments is needed to perform the comparison.
5960 template <class object_t >
6061 int32 compare (const object_t & x, const object_t & y) const {
61- if (xtd:: is<xtd:: string>(x) && xtd:: is<xtd:: string>(y)) return compare (static_cast < const xtd:: string& >(x), static_cast < const xtd:: string& >(y));
62- if (xtd:: is<xtd:: icomparable<object_t >>(x) && xtd:: is<xtd:: icomparable<object_t >>(y)) return static_cast < const xtd:: icomparable<object_t >& >(x).compare_to (static_cast < const xtd::icomparable< object_t >&>(y) );
63- if (xtd:: is<xtd:: object>(x) && xtd:: is<xtd:: object>(y) && static_cast < const xtd:: object& >(x) == static_cast < const xtd:: object& >(y)) return 0 ;
62+ if (is<string>(x) && is<string>(y)) return compare (as< string>(x), as< string>(y));
63+ if (is<icomparable<object_t >>(x) && is<icomparable<object_t >>(y)) return as< icomparable<object_t >>(x).compare_to (y );
64+ if (is<object>(x) && is<object>(y) && as< object>(x) == as< object>(y)) return 0 ;
6465 throw xtd::argument_exception {};
6566 }
6667 // / @cond
67- int32 compare (const char * x, const char * y) const {return compare (xtd:: string {x}, xtd:: string {y});}
68+ int32 compare (const char * x, const char * y) const {return compare (string {x}, string {y});}
6869 // / @endcond
6970 // / @brief When overridden in a derived class, compares two strings and returns an indication of their relative sort order.
7071 // / @param x An object to compare to `y`.
@@ -81,9 +82,9 @@ namespace xtd {
8182 using xtd::object::equals;
8283 template <class object_t >
8384 bool equals (const object_t & x, const object_t & y) const {
84- if (xtd:: is<xtd:: string>(x) && xtd:: is<xtd:: string>(y)) return equals (static_cast < const xtd:: string& >(x), static_cast < const xtd:: string& >(y));
85- if (xtd:: is<xtd:: iequatable<object_t >>(x) && xtd:: is<xtd:: iequatable<object_t >>(y)) return static_cast < const xtd:: iequatable<object_t >& >(x).equals (static_cast < const xtd::iequatable< object_t >&>(y) );
86- if (xtd:: is<xtd:: object>(x) && xtd:: is<xtd:: object>(y) && static_cast < const xtd:: object& >(x) == static_cast < const xtd:: object& >(y)) return 0 ;
85+ if (is<string>(x) && is<string>(y)) return equals (as< string>(x), as< string>(y));
86+ if (is<iequatable<object_t >>(x) && is<iequatable<object_t >>(y)) return as< iequatable<object_t >>(x).equals (y );
87+ if (is<object>(x) && is<object>(y) && as< object>(x) == as< object>(y)) return 0 ;
8788 throw xtd::argument_exception {};
8889 }
8990 // / @cond
@@ -94,8 +95,8 @@ namespace xtd {
9495 using xtd::object::get_hash_code;
9596 template <class object_t >
9697 xtd::size get_hash_code (const object_t & obj) const {
97- if (xtd:: is<xtd:: string>(obj)) return get_hash_code (static_cast < const xtd:: string& >(obj));
98- if (xtd:: is<xtd:: object>(obj)) return static_cast < const xtd:: object& >(obj).get_hash_code ();
98+ if (is<string>(obj)) return get_hash_code (as< string>(obj));
99+ if (is<object>(obj)) return as< object>(obj).get_hash_code ();
99100 throw xtd::hash_code::combine (obj);
100101 }
101102 // / @cond
0 commit comments