Skip to content

KDBindings::equal_to

An instance of the KDBindings::equal_to struct is used to decide whether two values of type T are equal in the context of data binding. More...

#include <property.h>

Public Functions

Name
auto operator()(const T & x, const T & y) const
template <typename X ,typename Y >
auto
operator()(const X & , const Y & ) const

Detailed Description

1
2
template <typename T >
struct KDBindings::equal_to;

An instance of the KDBindings::equal_to struct is used to decide whether two values of type T are equal in the context of data binding.

If a new value is assigned to a Property and the existing value is equal_to the existing value, the Property will not emit the Property::valueChanged or Property::valueAboutToChange signals and not change the stored value.

By default, all classes T that are equality comparable using std::equal_to delegate to std::equal_to for equality comparison. All other instances are assumed to never be equal. Therefore, to change the equality behavior of a Property, either:

  • Implement operator== for T (std::equal_to uses operator== for equality comparison)
  • Provide a template spezialization of KDBindings::equal_to and implement operator()()

Public Functions Documentation

function operator()

1
2
3
4
inline auto operator()(
    const T & x,
    const T & y
) const

Return: bool - Whether the values are equal.

This implementation of operator()() is only enabled if std::equal_to can be used to compare values of type T. In this case, std::equal_to is used to decide whether values of type T are equal.

function operator()

1
2
3
4
5
6
template <typename X ,
typename Y >
inline auto operator()(
    const X & ,
    const Y & 
) const

Return: bool - Whether the values are equal - always false for this default implementation

The fallback implementation of operator()() if the types are not equality comparable using std::equal_to (i.e. no operator== implementation exists for this type). In this case, two values of type T are assumed to never be equal.


Updated on 2024-04-14 at 00:00:43 +0000