【发布时间】:2021-02-22 18:42:11
【问题描述】:
我不想use 整个包,但我确实想导入一些功能,例如"/=" 运算符。我知道renames 允许我使用大多数函数来执行此操作,但是使用不等式运算符我得到了错误explicit definition of inequality not allowed。如何在不引发错误的情况下导入此运算符?
package Integer_Maps is new Ada.Containers.Ordered_Maps
(
Key_Type => Integer,
Element_Type => Integer
);
-- the next line fails!
function "/=" ( Left, Right: Integer_Maps.Cursor ) return Boolean
renames Integer_Maps."/=";
【问题讨论】:
-
“不允许显式重载不等式运算符”,LRM83 6.7 第 4 段。
-
@SimonWright 我在下面的回答中引用了 2012 LRM 6.6,但我发现他们在随后的 LRM 中删除/改写了这句话很有趣。
标签: import package operator-overloading ada inequality