@@ -593,6 +593,29 @@ inline void ResetOnLoad(TMap& parameter)
593
593
594
594
// //////////////////////////////////////////////////////////////////////////////
595
595
596
+ // Any T.
597
+ template <class T >
598
+ bool CompareValue (const T& lhs, const T& rhs);
599
+
600
+ // TIntrusivePtr.
601
+ template <class T >
602
+ bool CompareValues (const TIntrusivePtr<T>& lhs, const TIntrusivePtr<T>& rhs);
603
+
604
+ // std::optional.
605
+ template <class T >
606
+ bool CompareValues (const std::optional<T>& lhs, const std::optional<T>& rhs);
607
+
608
+ // std::vector.
609
+ template <CStdVector T>
610
+ bool CompareValues (const T& lhs, const T& rhs);
611
+
612
+ // any map.
613
+ template <CAnyMap T>
614
+ bool CompareValues (const T& lhs, const T& rhs);
615
+
616
+ // //////////////////////////////////////////////////////////////////////////////
617
+
618
+ // Any T.
596
619
template <class T >
597
620
bool CompareValues (const T& lhs, const T& rhs)
598
621
{
@@ -603,6 +626,7 @@ bool CompareValues(const T& lhs, const T& rhs)
603
626
}
604
627
}
605
628
629
+ // TIntrusivePtr.
606
630
template <class T >
607
631
bool CompareValues (const TIntrusivePtr<T>& lhs, const TIntrusivePtr<T>& rhs)
608
632
{
@@ -611,12 +635,70 @@ bool CompareValues(const TIntrusivePtr<T>& lhs, const TIntrusivePtr<T>& rhs)
611
635
return rhs == lhs;
612
636
}
613
637
614
- return *lhs == *rhs;
638
+ return CompareValues ( *lhs, *rhs) ;
615
639
} else {
616
640
return false ;
617
641
}
618
642
}
619
643
644
+ // std::optional.
645
+ template <class T >
646
+ bool CompareValues (const std::optional<T>& lhs, const std::optional<T>& rhs)
647
+ {
648
+ if (lhs.has_value () != rhs.has_value ()) {
649
+ return false ;
650
+ }
651
+
652
+ if (!lhs.has_value ()) {
653
+ return true ;
654
+ }
655
+
656
+ return CompareValues (*lhs, *rhs);
657
+ }
658
+
659
+ // std::vector.
660
+ template <CStdVector T>
661
+ bool CompareValues (const T& lhs, const T& rhs)
662
+ {
663
+ if (std::ssize (lhs) != std::ssize (rhs)) {
664
+ return false ;
665
+ }
666
+
667
+ for (int idx = 0 ; idx < std::ssize (lhs); ++idx) {
668
+ if (!CompareValues (lhs[idx], rhs[idx])) {
669
+ return false ;
670
+ }
671
+ }
672
+
673
+ return true ;
674
+ }
675
+
676
+ // any map.
677
+ template <CAnyMap T>
678
+ bool CompareValues (const T& lhs, const T& rhs)
679
+ {
680
+ if (std::ssize (lhs) != std::ssize (rhs)) {
681
+ return false ;
682
+ }
683
+
684
+ for (const auto & [key, value] : lhs) {
685
+ auto rhsIt = rhs.find (key);
686
+ if (rhsIt == std::end (rhs)) {
687
+ return false ;
688
+ }
689
+
690
+ if (!CompareValues (key, rhsIt->first )) {
691
+ return false ;
692
+ }
693
+
694
+ if (!CompareValues (value, rhsIt->second )) {
695
+ return false ;
696
+ }
697
+ }
698
+
699
+ return true ;
700
+ }
701
+
620
702
} // namespace NPrivate
621
703
622
704
// //////////////////////////////////////////////////////////////////////////////
0 commit comments