From dff61d2615cc6332fa6205267bae19b4d044b9da Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Sun, 28 Jan 2024 21:16:37 +0100 Subject: [PATCH] Fix Indefinite_Holders "=" operator --- src/aaa-containers-indefinite_holders.adb | 17 +++++++++++++++++ src/aaa-containers-indefinite_holders.ads | 6 +++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/aaa-containers-indefinite_holders.adb b/src/aaa-containers-indefinite_holders.adb index 205a102..c7894f8 100644 --- a/src/aaa-containers-indefinite_holders.adb +++ b/src/aaa-containers-indefinite_holders.adb @@ -2,6 +2,23 @@ with Ada.Unchecked_Deallocation; package body AAA.Containers.Indefinite_Holders is + --------- + -- "=" -- + --------- + + overriding function "=" (L, R : Holder) return Boolean is + begin + if L.Is_Empty xor R.Is_Empty then + return False; + end if; + + if L.Is_Empty and then R.Is_Empty then + return True; + end if; + + return "=" (L.Item.all, R.Item.all); + end "="; + ----------- -- Clear -- ----------- diff --git a/src/aaa-containers-indefinite_holders.ads b/src/aaa-containers-indefinite_holders.ads index 1849acf..d9225fd 100644 --- a/src/aaa-containers-indefinite_holders.ads +++ b/src/aaa-containers-indefinite_holders.ads @@ -2,12 +2,16 @@ with Ada.Finalization; generic type Held (<>) is private; + with function "=" (L, R : Held) return Boolean is <>; package AAA.Containers.Indefinite_Holders with Preelaborate is - -- Simple holder to work around GNAT holders bug + -- Simple holder to work around GNAT holders bug. Comparison uses the held + -- value. type Holder is tagged private; + overriding function "=" (L, R : Holder) return Boolean; + Empty_Holder : constant Holder; procedure Clear (This : in out Holder);