This feature allows declaring subprograms that are associated with a named aspect or attribute of a given type, as an alternative to explicitly specifying the aspect or attribute for the type (using an aspect_specification or attribute_definition_clause), by defining the name of the subprogram using attribute syntax. In effect, this implicitly specifies the aspect or attribute for the type, and is intended to be semantically equivalent to using an explicit aspect specification, but without needing to give a specific name in the aspect and subprogram. This is allowed for the various aspects that denote subprograms (see below for the exact list of supported aspects).
Here is an example of the use of this feature for defining indexing functions for a container type and an integer-literal function for the container’s element type:
package My_Container is
type Container is tagged ...; -- Implicit indexing aspects
type Element_Type is ...; -- Implicit Integer_Literal aspect
type Cursor_Type is ...;
type Reference_Type is ...;
function Container'Constant_Indexing (C : Container; Index : Positive)
return Element_Type;
function Container'Constant_Indexing (C : Container; Index : Cursor_Type)
return Element_Type;
function Container'Variable_Indexing
(C : in out Container; Index : Positive)
return Reference_Type;
function Element_Type'Integer_Literal (S : String) return Element_Type;
end My_Container;